No-op: whitespace.
[libdcp.git] / test / write_subtitle_test.cc
1 /*
2     Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "interop_subtitle_asset.h"
21 #include "subtitle_string.h"
22 #include "test.h"
23 #include <boost/test/unit_test.hpp>
24
25 using std::list;
26 using std::string;
27 using boost::shared_ptr;
28
29 /* Write some subtitle content as Interop XML and check that it is right */
30 BOOST_AUTO_TEST_CASE (write_subtitle_test)
31 {
32         dcp::InteropSubtitleAsset c;
33         c.set_reel_number ("1");
34         c.set_language ("EN");
35         c.set_movie_title ("Test");
36
37         c.add (
38                 dcp::SubtitleString (
39                         string ("Frutiger"),
40                         false,
41                         dcp::Colour (255, 255, 255),
42                         48,
43                         1.0,
44                         dcp::Time (0, 4,  9, 22, 24),
45                         dcp::Time (0, 4, 11, 22, 24),
46                         0,
47                         dcp::HALIGN_CENTER,
48                         0.8,
49                         dcp::VALIGN_TOP,
50                         "Hello world",
51                         dcp::NONE,
52                         dcp::Colour (0, 0, 0),
53                         dcp::Time (0, 0, 0, 0, 24),
54                         dcp::Time (0, 0, 0, 0, 24)
55                         )
56                 );
57
58         c.add (
59                 dcp::SubtitleString (
60                         boost::optional<string> (),
61                         true,
62                         dcp::Colour (128, 0, 64),
63                         91,
64                         1.0,
65                         dcp::Time (5, 41,  0, 21, 24),
66                         dcp::Time (6, 12, 15, 21, 24),
67                         0,
68                         dcp::HALIGN_CENTER,
69                         0.4,
70                         dcp::VALIGN_BOTTOM,
71                         "What's going on",
72                         dcp::BORDER,
73                         dcp::Colour (1, 2, 3),
74                         dcp::Time (1, 2, 3, 4, 24),
75                         dcp::Time (5, 6, 7, 8, 24)
76                         )
77                 );
78
79         c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
80
81         check_xml (
82                 c.xml_as_string (),
83                 "<DCSubtitle Version=\"1.0\">\n"
84                 "  <SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>\n"
85                 "  <MovieTitle>Test</MovieTitle>\n"
86                 "  <ReelNumber>1</ReelNumber>\n"
87                 "  <Language>EN</Language>\n"
88                 "  <Font Id=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
89                 "    <Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">\n"
90                 "      <Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>\n"
91                 "    </Subtitle>\n"
92                 "  </Font>\n"
93                 "  <Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
94                 "    <Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930790\" FadeDownTime=\"4591830\">\n"
95                 "      <Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>\n"
96                 "    </Subtitle>\n"
97                 "  </Font>\n"
98                 "</DCSubtitle>",
99                 list<string> ()
100                 );
101 }
102