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_text_test.cc
22 * @brief Check markup of subtitles for rendering.
26 #include "lib/render_text.h"
27 #include <dcp/subtitle_string.h>
28 #include <boost/test/unit_test.hpp>
31 add (std::list<StringText>& 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),
62 /** Test marked_up() in render_text.cc */
63 BOOST_AUTO_TEST_CASE (render_markup_test1)
65 std::list<StringText> s;
66 add (s, "Hello", false, false, false);
67 BOOST_CHECK_EQUAL (marked_up(s, 1024, 1, ""), "<span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
70 /** Test marked_up() in render_text.cc */
71 BOOST_AUTO_TEST_CASE (render_markup_test2)
73 std::list<StringText> s;
74 add (s, "Hello", false, true, false);
75 BOOST_CHECK_EQUAL (marked_up(s, 1024, 1, ""), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
79 /** Test marked_up() in render_text.cc */
80 BOOST_AUTO_TEST_CASE (render_markup_test3)
82 std::list<StringText> s;
83 add (s, "Hello", true, true, false);
84 BOOST_CHECK_EQUAL (marked_up(s, 1024, 1, ""), "<span style=\"italic\" weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
87 /** Test marked_up() in render_text.cc */
88 BOOST_AUTO_TEST_CASE (render_markup_test4)
90 std::list<StringText> s;
91 add (s, "Hello", true, true, true);
92 BOOST_CHECK_EQUAL (marked_up(s, 1024, 1, ""), "<span style=\"italic\" weight=\"bold\" underline=\"single\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
95 /** Test marked_up() in render_text.cc */
96 BOOST_AUTO_TEST_CASE (render_markup_test5)
98 std::list<StringText> s;
99 add (s, "Hello", false, true, false);
100 add (s, " world.", false, false, false);
101 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>");
104 /** Test marked_up() in render_text.cc */
105 BOOST_AUTO_TEST_CASE (render_markup_test6)
107 std::list<StringText> s;
108 add (s, "Hello", true, false, false);
109 add (s, " world ", false, false, false);
110 add (s, "we are bold.", false, true, false);
111 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>");