2 Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file test/render_subtitles_test.cc
22 * @brief Check markup of subtitles for rendering.
26 #include "lib/render_subtitles.h"
27 #include <dcp/subtitle_string.h>
28 #include <boost/test/unit_test.hpp>
31 add (std::list<SubtitleString>& s, std::string text, bool italic, bool bold, bool underline)
36 boost::optional<std::string> (),
40 dcp::Colour (255, 255, 255),
52 dcp::Colour (0, 0, 0),
60 /** Test marked_up() in render_subtitles.cc */
61 BOOST_AUTO_TEST_CASE (render_markup_test1)
63 std::list<SubtitleString> s;
64 add (s, "Hello", false, false, false);
65 BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
68 /** Test marked_up() in render_subtitles.cc */
69 BOOST_AUTO_TEST_CASE (render_markup_test2)
71 std::list<SubtitleString> s;
72 add (s, "Hello", false, true, false);
73 BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
77 /** Test marked_up() in render_subtitles.cc */
78 BOOST_AUTO_TEST_CASE (render_markup_test3)
80 std::list<SubtitleString> s;
81 add (s, "Hello", true, true, false);
82 BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
85 /** Test marked_up() in render_subtitles.cc */
86 BOOST_AUTO_TEST_CASE (render_markup_test4)
88 std::list<SubtitleString> s;
89 add (s, "Hello", true, true, true);
90 BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" underline=\"single\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
93 /** Test marked_up() in render_subtitles.cc */
94 BOOST_AUTO_TEST_CASE (render_markup_test5)
96 std::list<SubtitleString> s;
97 add (s, "Hello", false, true, false);
98 add (s, " world.", false, false, false);
99 BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span><span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\"> world.</span>");
102 /** Test marked_up() in render_subtitles.cc */
103 BOOST_AUTO_TEST_CASE (render_markup_test6)
105 std::list<SubtitleString> s;
106 add (s, "Hello", true, false, false);
107 add (s, " world ", false, false, false);
108 add (s, "we are bold.", false, true, false);
109 BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span><span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\"> world </span><span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">we are bold.</span>");