Remove XMLMetadata from DCP::write_xml and DCP::write_assetmap.
[libdcp.git] / test / write_subtitle_test.cc
1 /*
2     Copyright (C) 2015-2019 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp 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.
10
11     libdcp 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.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18
19     In addition, as a special exception, the copyright holders give
20     permission to link the code of portions of this program with the
21     OpenSSL library under certain conditions as described in each
22     individual source file, and distribute linked combinations
23     including the two.
24
25     You must obey the GNU General Public License in all respects
26     for all of the code used other than OpenSSL.  If you modify
27     file(s) with this exception, you may extend this exception to your
28     version of the file(s), but you are not obligated to do so.  If you
29     do not wish to do so, delete this exception statement from your
30     version.  If you delete this exception statement from all source
31     files in the program, then also delete it here.
32 */
33
34 #include "interop_subtitle_asset.h"
35 #include "smpte_subtitle_asset.h"
36 #include "subtitle_string.h"
37 #include "subtitle_image.h"
38 #include "subtitle_asset_internal.h"
39 #include "reel_subtitle_asset.h"
40 #include "reel.h"
41 #include "cpl.h"
42 #include "dcp.h"
43 #include "test.h"
44 #include "util.h"
45 #include <boost/test/unit_test.hpp>
46
47 using std::list;
48 using std::string;
49 using boost::shared_ptr;
50
51 /** Test dcp::order::Font::take_intersection */
52 BOOST_AUTO_TEST_CASE (take_intersection_test)
53 {
54         dcp::order::Font A;
55         A._values["foo"] = "bar";
56         A._values["fred"] = "jim";
57
58         dcp::order::Font B;
59         B._values["foo"] = "bar";
60         B._values["sheila"] = "baz";
61
62         A.take_intersection (B);
63         BOOST_REQUIRE_EQUAL (A._values.size(), 1);
64         BOOST_CHECK_EQUAL (A._values["foo"], "bar");
65
66         A._values.clear ();
67         B._values.clear ();
68
69         A._values["foo"] = "bar";
70         A._values["fred"] = "jim";
71
72         B._values["foo"] = "hello";
73         B._values["sheila"] = "baz";
74
75         A.take_intersection (B);
76         BOOST_CHECK_EQUAL (A._values.size(), 0);
77 }
78
79 /** Test dcp::order::Font::take_difference */
80 BOOST_AUTO_TEST_CASE (take_difference_test)
81 {
82         dcp::order::Font A;
83         A._values["foo"] = "bar";
84         A._values["fred"] = "jim";
85
86         dcp::order::Font B;
87         B._values["foo"] = "bar";
88         B._values["sheila"] = "baz";
89
90         A.take_difference (B);
91         BOOST_REQUIRE_EQUAL (A._values.size(), 1);
92         BOOST_CHECK_EQUAL (A._values["fred"], "jim");
93 }
94
95 /** Test dcp::order::Subtitle::pull_fonts */
96 BOOST_AUTO_TEST_CASE (pull_fonts_test1)
97 {
98         shared_ptr<dcp::order::Part> root (new dcp::order::Part (shared_ptr<dcp::order::Part> ()));
99         shared_ptr<dcp::order::Subtitle> sub1 (new dcp::order::Subtitle (root, dcp::Time(), dcp::Time(), dcp::Time(), dcp::Time()));
100         root->children.push_back (sub1);
101         shared_ptr<dcp::order::Text> text1 (new dcp::order::Text (sub1, dcp::HALIGN_CENTER, 0, dcp::VALIGN_TOP, 0, dcp::DIRECTION_LTR));
102         sub1->children.push_back (text1);
103         text1->font._values["font"] = "Inconsolata";
104         text1->font._values["size"] = "42";
105
106         dcp::SubtitleAsset::pull_fonts (root);
107
108         BOOST_REQUIRE_EQUAL (sub1->font._values.size(), 2);
109         BOOST_CHECK_EQUAL (sub1->font._values["font"], "Inconsolata");
110         BOOST_CHECK_EQUAL (sub1->font._values["size"], "42");
111         BOOST_CHECK_EQUAL (text1->font._values.size(), 0);
112 }
113
114 /** Test dcp::order::Subtitle::pull_fonts */
115 BOOST_AUTO_TEST_CASE (pull_fonts_test2)
116 {
117         shared_ptr<dcp::order::Part> root (new dcp::order::Part (shared_ptr<dcp::order::Part> ()));
118         shared_ptr<dcp::order::Subtitle> sub1 (new dcp::order::Subtitle (root, dcp::Time(), dcp::Time(), dcp::Time(), dcp::Time()));
119         root->children.push_back (sub1);
120         shared_ptr<dcp::order::Text> text1 (new dcp::order::Text (sub1, dcp::HALIGN_CENTER, 0, dcp::VALIGN_TOP, 0, dcp::DIRECTION_LTR));
121         sub1->children.push_back (text1);
122         text1->font._values["font"] = "Inconsolata";
123         text1->font._values["size"] = "42";
124         shared_ptr<dcp::order::Text> text2 (new dcp::order::Text (sub1, dcp::HALIGN_CENTER, 0, dcp::VALIGN_TOP, 0, dcp::DIRECTION_LTR));
125         sub1->children.push_back (text2);
126         text2->font._values["font"] = "Inconsolata";
127         text2->font._values["size"] = "48";
128
129         dcp::SubtitleAsset::pull_fonts (root);
130
131         BOOST_REQUIRE_EQUAL (sub1->font._values.size(), 1);
132         BOOST_CHECK_EQUAL (sub1->font._values["font"], "Inconsolata");
133         BOOST_REQUIRE_EQUAL (text1->font._values.size(), 1);
134         BOOST_CHECK_EQUAL (text1->font._values["size"], "42");
135         BOOST_REQUIRE_EQUAL (text2->font._values.size(), 1);
136         BOOST_CHECK_EQUAL (text2->font._values["size"], "48");
137 }
138
139 /** Test dcp::order::Subtitle::pull_fonts */
140 BOOST_AUTO_TEST_CASE (pull_fonts_test3)
141 {
142         shared_ptr<dcp::order::Part> root (new dcp::order::Part (shared_ptr<dcp::order::Part> ()));
143         shared_ptr<dcp::order::Subtitle> sub1 (new dcp::order::Subtitle (root, dcp::Time(), dcp::Time(), dcp::Time(), dcp::Time()));
144         root->children.push_back (sub1);
145         shared_ptr<dcp::order::Text> text1 (new dcp::order::Text (sub1, dcp::HALIGN_CENTER, 0, dcp::VALIGN_TOP, 0, dcp::DIRECTION_LTR));
146         sub1->children.push_back (text1);
147         dcp::order::Font font;
148         font._values["font"] = "Inconsolata";
149         font._values["size"] = "42";
150         shared_ptr<dcp::order::String> string1 (new dcp::order::String (text1, font, "Hello world"));
151         text1->children.push_back (string1);
152
153         dcp::SubtitleAsset::pull_fonts (root);
154
155         BOOST_REQUIRE_EQUAL (sub1->font._values.size(), 2);
156         BOOST_CHECK_EQUAL (sub1->font._values["font"], "Inconsolata");
157         BOOST_CHECK_EQUAL (sub1->font._values["size"], "42");
158 }
159
160 /** Write some subtitle content as Interop XML and check that it is right */
161 BOOST_AUTO_TEST_CASE (write_interop_subtitle_test)
162 {
163         dcp::InteropSubtitleAsset c;
164         c.set_reel_number ("1");
165         c.set_language ("EN");
166         c.set_movie_title ("Test");
167
168         c.add (
169                 shared_ptr<dcp::Subtitle> (
170                         new dcp::SubtitleString (
171                                 string ("Frutiger"),
172                                 false,
173                                 false,
174                                 false,
175                                 dcp::Colour (255, 255, 255),
176                                 48,
177                                 1.0,
178                                 dcp::Time (0, 4,  9, 22, 24),
179                                 dcp::Time (0, 4, 11, 22, 24),
180                                 0,
181                                 dcp::HALIGN_CENTER,
182                                 0.8,
183                                 dcp::VALIGN_TOP,
184                                 dcp::DIRECTION_LTR,
185                                 "Hello world",
186                                 dcp::NONE,
187                                 dcp::Colour (0, 0, 0),
188                                 dcp::Time (0, 0, 0, 0, 24),
189                                 dcp::Time (0, 0, 0, 0, 24)
190                                 )
191                         )
192                 );
193
194         c.add (
195                 shared_ptr<dcp::Subtitle> (
196                         new dcp::SubtitleString (
197                                 boost::optional<string> (),
198                                 true,
199                                 true,
200                                 true,
201                                 dcp::Colour (128, 0, 64),
202                                 91,
203                                 1.0,
204                                 dcp::Time (5, 41,  0, 21, 24),
205                                 dcp::Time (6, 12, 15, 21, 24),
206                                 0,
207                                 dcp::HALIGN_CENTER,
208                                 0.4,
209                                 dcp::VALIGN_BOTTOM,
210                                 dcp::DIRECTION_LTR,
211                                 "What's going on",
212                                 dcp::BORDER,
213                                 dcp::Colour (1, 2, 3),
214                                 dcp::Time (1, 2, 3, 4, 24),
215                                 dcp::Time (5, 6, 7, 8, 24)
216                                 )
217                         )
218                 );
219
220         c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
221
222         check_xml (
223                 "<DCSubtitle Version=\"1.0\">"
224                   "<SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>"
225                   "<MovieTitle>Test</MovieTitle>"
226                   "<ReelNumber>1</ReelNumber>"
227                   "<Language>EN</Language>"
228                   "<Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" Id=\"Frutiger\" Italic=\"no\" Script=\"normal\" Size=\"48\" Underlined=\"no\" Weight=\"normal\">"
229                     "<Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">"
230                       "<Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>"
231                     "</Subtitle>"
232                   "</Font>"
233                   "<Font AspectAdjust=\"1.0\" Color=\"FF800040\" Effect=\"border\" EffectColor=\"FF010203\" Italic=\"yes\" Script=\"normal\" Size=\"91\" Underlined=\"yes\" Weight=\"bold\">"
234                     "<Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">"
235                       "<Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>"
236                     "</Subtitle>"
237                   "</Font>"
238                 "</DCSubtitle>",
239                 c.xml_as_string (),
240                 list<string> ()
241                 );
242 }
243
244 /** Write some subtitle content as Interop XML and check that it is right.
245  *  This test includes some horizontal alignment.
246  */
247 BOOST_AUTO_TEST_CASE (write_interop_subtitle_test2)
248 {
249         dcp::InteropSubtitleAsset c;
250         c.set_reel_number ("1");
251         c.set_language ("EN");
252         c.set_movie_title ("Test");
253
254         c.add (
255                 shared_ptr<dcp::Subtitle> (
256                         new dcp::SubtitleString (
257                                 string ("Frutiger"),
258                                 false,
259                                 false,
260                                 false,
261                                 dcp::Colour (255, 255, 255),
262                                 48,
263                                 1.0,
264                                 dcp::Time (0, 4,  9, 22, 24),
265                                 dcp::Time (0, 4, 11, 22, 24),
266                                 -0.2,
267                                 dcp::HALIGN_CENTER,
268                                 0.8,
269                                 dcp::VALIGN_TOP,
270                                 dcp::DIRECTION_LTR,
271                                 "Hello world",
272                                 dcp::NONE,
273                                 dcp::Colour (0, 0, 0),
274                                 dcp::Time (0, 0, 0, 0, 24),
275                                 dcp::Time (0, 0, 0, 0, 24)
276                                 )
277                         )
278                 );
279
280         c.add (
281                 shared_ptr<dcp::Subtitle> (
282                         new dcp::SubtitleString (
283                                 boost::optional<string> (),
284                                 true,
285                                 true,
286                                 true,
287                                 dcp::Colour (128, 0, 64),
288                                 91,
289                                 1.0,
290                                 dcp::Time (5, 41,  0, 21, 24),
291                                 dcp::Time (6, 12, 15, 21, 24),
292                                 -0.2,
293                                 dcp::HALIGN_CENTER,
294                                 0.4,
295                                 dcp::VALIGN_BOTTOM,
296                                 dcp::DIRECTION_LTR,
297                                 "What's going on",
298                                 dcp::BORDER,
299                                 dcp::Colour (1, 2, 3),
300                                 dcp::Time (1, 2, 3, 4, 24),
301                                 dcp::Time (5, 6, 7, 8, 24)
302                                 )
303                         )
304                 );
305
306         c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
307
308         check_xml (
309                 "<DCSubtitle Version=\"1.0\">"
310                   "<SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>"
311                   "<MovieTitle>Test</MovieTitle>"
312                   "<ReelNumber>1</ReelNumber>"
313                   "<Language>EN</Language>"
314                   "<Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" Id=\"Frutiger\" Italic=\"no\" Script=\"normal\" Size=\"48\" Underlined=\"no\" Weight=\"normal\">"
315                     "<Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">"
316                       "<Text HPosition=\"-20\" VAlign=\"top\" VPosition=\"80\">Hello world</Text>"
317                     "</Subtitle>"
318                   "</Font>"
319                   "<Font AspectAdjust=\"1.0\" Color=\"FF800040\" Effect=\"border\" EffectColor=\"FF010203\" Italic=\"yes\" Script=\"normal\" Size=\"91\" Underlined=\"yes\" Weight=\"bold\">"
320                     "<Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">"
321                       "<Text HPosition=\"-20\" VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>"
322                     "</Subtitle>"
323                   "</Font>"
324                 "</DCSubtitle>",
325                 c.xml_as_string (),
326                 list<string> ()
327                 );
328 }
329
330 /* Write some subtitle content as Interop XML using bitmaps and check that it is right */
331 BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
332 {
333         RNGFixer fix;
334
335         shared_ptr<dcp::InteropSubtitleAsset> c (new dcp::InteropSubtitleAsset());
336         c->set_reel_number ("1");
337         c->set_language ("EN");
338         c->set_movie_title ("Test");
339
340         c->add (
341                 shared_ptr<dcp::Subtitle> (
342                         new dcp::SubtitleImage (
343                                 dcp::Data ("test/data/sub.png"),
344                                 dcp::Time (0, 4,  9, 22, 24),
345                                 dcp::Time (0, 4, 11, 22, 24),
346                                 0,
347                                 dcp::HALIGN_CENTER,
348                                 0.8,
349                                 dcp::VALIGN_TOP,
350                                 dcp::Time (0, 0, 0, 0, 24),
351                                 dcp::Time (0, 0, 0, 0, 24)
352                                 )
353                         )
354                 );
355
356         c->_id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
357         boost::filesystem::remove_all ("build/test/write_interop_subtitle_test3");
358         boost::filesystem::create_directories ("build/test/write_interop_subtitle_test3");
359         c->write ("build/test/write_interop_subtitle_test3/subs.xml");
360
361         shared_ptr<dcp::Reel> reel (new dcp::Reel());
362         reel->add(shared_ptr<dcp::ReelSubtitleAsset>(new dcp::ReelSubtitleAsset(c, dcp::Fraction(24, 1), 6046, 0)));
363
364         dcp::XMLMetadata xml_meta;
365         xml_meta.issue_date = "2018-09-02T04:45:18+00:00";
366         xml_meta.issuer = "libdcp";
367         xml_meta.creator = "libdcp";
368         xml_meta.annotation_text = "Created by libdcp";
369
370         shared_ptr<dcp::CPL> cpl (new dcp::CPL ("My film", dcp::FEATURE));
371         cpl->add (reel);
372         cpl->set_issuer (xml_meta.issuer);
373         cpl->set_creator (xml_meta.creator);
374         cpl->set_issue_date (xml_meta.issue_date);
375         cpl->set_annotation_text (xml_meta.annotation_text);
376         cpl->set_content_version_label_text ("foo");
377
378         dcp::DCP dcp ("build/test/write_interop_subtitle_test3");
379         dcp.add (cpl);
380         dcp.write_xml (dcp::INTEROP, xml_meta.issuer, xml_meta.creator, xml_meta.issue_date, xml_meta.annotation_text);
381
382         check_xml (
383                 dcp::file_to_string("test/ref/write_interop_subtitle_test3/subs.xml"),
384                 dcp::file_to_string("build/test/write_interop_subtitle_test3/subs.xml"),
385                 list<string>()
386                 );
387         check_file ("build/test/write_interop_subtitle_test3/d36f4bb3-c4fa-4a95-9915-6fec3110cd71.png", "test/data/sub.png");
388
389         check_xml (
390                 dcp::file_to_string("test/ref/write_interop_subtitle_test3/ASSETMAP"),
391                 dcp::file_to_string("build/test/write_interop_subtitle_test3/ASSETMAP"),
392                 list<string>()
393                 );
394
395         check_xml (
396                 dcp::file_to_string("test/ref/write_interop_subtitle_test3/pkl.xml"),
397                 dcp::file_to_string("build/test/write_interop_subtitle_test3/pkl_6a9e31a6-50a4-4ecb-8683-fa667848470a.xml"),
398                 list<string>()
399                 );
400 }
401
402 /* Write some subtitle content as SMPTE XML and check that it is right */
403 BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test)
404 {
405         dcp::SMPTESubtitleAsset c;
406         c.set_reel_number (1);
407         c.set_language ("EN");
408         c.set_content_title_text ("Test");
409         c.set_issue_date (dcp::LocalTime ("2016-04-01T03:52:00+00:00"));
410
411         c.add (
412                 shared_ptr<dcp::Subtitle> (
413                         new dcp::SubtitleString (
414                                 string ("Frutiger"),
415                                 false,
416                                 false,
417                                 false,
418                                 dcp::Colour (255, 255, 255),
419                                 48,
420                                 1.0,
421                                 dcp::Time (0, 4,  9, 22, 24),
422                                 dcp::Time (0, 4, 11, 22, 24),
423                                 0,
424                                 dcp::HALIGN_CENTER,
425                                 0.8,
426                                 dcp::VALIGN_TOP,
427                                 dcp::DIRECTION_LTR,
428                                 "Hello world",
429                                 dcp::NONE,
430                                 dcp::Colour (0, 0, 0),
431                                 dcp::Time (0, 0, 0, 0, 24),
432                                 dcp::Time (0, 0, 0, 0, 24)
433                                 )
434                         )
435                 );
436
437         c.add (
438                 shared_ptr<dcp::Subtitle> (
439                         new dcp::SubtitleString (
440                                 boost::optional<string> (),
441                                 true,
442                                 true,
443                                 true,
444                                 dcp::Colour (128, 0, 64),
445                                 91,
446                                 1.0,
447                                 dcp::Time (5, 41,  0, 21, 24),
448                                 dcp::Time (6, 12, 15, 21, 24),
449                                 0,
450                                 dcp::HALIGN_CENTER,
451                                 0.4,
452                                 dcp::VALIGN_BOTTOM,
453                                 dcp::DIRECTION_RTL,
454                                 "What's going on",
455                                 dcp::BORDER,
456                                 dcp::Colour (1, 2, 3),
457                                 dcp::Time (1, 2, 3, 4, 24),
458                                 dcp::Time (5, 6, 7, 8, 24)
459                                 )
460                         )
461                 );
462
463         c._xml_id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
464
465         check_xml (
466                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
467                 "<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
468                   "<dcst:Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</dcst:Id>"
469                   "<dcst:ContentTitleText>Test</dcst:ContentTitleText>"
470                   "<dcst:IssueDate>2016-04-01T03:52:00.000+00:00</dcst:IssueDate>"
471                   "<dcst:ReelNumber>1</dcst:ReelNumber>"
472                   "<dcst:Language>EN</dcst:Language>"
473                   "<dcst:EditRate>24 1</dcst:EditRate>"
474                   "<dcst:TimeCodeRate>24</dcst:TimeCodeRate>"
475                   "<dcst:SubtitleList>"
476                     "<dcst:Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" ID=\"Frutiger\" Italic=\"no\" Script=\"normal\" Size=\"48\" Underline=\"no\" Weight=\"normal\">"
477                       "<dcst:Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:22\" TimeOut=\"00:04:11:22\" FadeUpTime=\"00:00:00:00\" FadeDownTime=\"00:00:00:00\">"
478                         "<dcst:Text Valign=\"top\" Vposition=\"80\">Hello world</dcst:Text>"
479                       "</dcst:Subtitle>"
480                     "</dcst:Font>"
481                     "<dcst:Font AspectAdjust=\"1.0\" Color=\"FF800040\" Effect=\"border\" EffectColor=\"FF010203\" Italic=\"yes\" Script=\"normal\" Size=\"91\" Underline=\"yes\" Weight=\"bold\">"
482                       "<dcst:Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:21\" TimeOut=\"06:12:15:21\" FadeUpTime=\"01:02:03:04\" FadeDownTime=\"05:06:07:08\">"
483                         "<dcst:Text Valign=\"bottom\" Vposition=\"40\" Direction=\"rtl\">What's going on</dcst:Text>"
484                       "</dcst:Subtitle>"
485                     "</dcst:Font>"
486                   "</dcst:SubtitleList>"
487                 "</dcst:SubtitleReel>",
488                 c.xml_as_string (),
489                 list<string> ()
490                 );
491 }
492
493 /* Write some subtitle content as SMPTE XML and check that it is right.
494    This includes in-line font changes.
495 */
496 BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test2)
497 {
498         dcp::SMPTESubtitleAsset c;
499         c.set_reel_number (1);
500         c.set_language ("EN");
501         c.set_content_title_text ("Test");
502         c.set_issue_date (dcp::LocalTime ("2016-04-01T03:52:00+00:00"));
503
504         c.add (
505                 shared_ptr<dcp::Subtitle> (
506                         new dcp::SubtitleString (
507                                 string ("Arial"),
508                                 false,
509                                 false,
510                                 false,
511                                 dcp::Colour (255, 255, 255),
512                                 48,
513                                 1.0,
514                                 dcp::Time (0, 0, 1, 0, 24),
515                                 dcp::Time (0, 0, 9, 0, 24),
516                                 0,
517                                 dcp::HALIGN_CENTER,
518                                 0.8,
519                                 dcp::VALIGN_TOP,
520                                 dcp::DIRECTION_LTR,
521                                 "Testing is ",
522                                 dcp::NONE,
523                                 dcp::Colour (0, 0, 0),
524                                 dcp::Time (0, 0, 0, 0, 24),
525                                 dcp::Time (0, 0, 0, 0, 24)
526                                 )
527                         )
528                 );
529
530         c.add (
531                 shared_ptr<dcp::Subtitle> (
532                         new dcp::SubtitleString (
533                                 string ("Arial"),
534                                 true,
535                                 false,
536                                 false,
537                                 dcp::Colour (255, 255, 255),
538                                 48,
539                                 1.0,
540                                 dcp::Time (0, 0, 1, 0, 24),
541                                 dcp::Time (0, 0, 9, 0, 24),
542                                 0,
543                                 dcp::HALIGN_CENTER,
544                                 0.8,
545                                 dcp::VALIGN_TOP,
546                                 dcp::DIRECTION_LTR,
547                                 "really",
548                                 dcp::NONE,
549                                 dcp::Colour (0, 0, 0),
550                                 dcp::Time (0, 0, 0, 0, 24),
551                                 dcp::Time (0, 0, 0, 0, 24)
552                                 )
553                         )
554                 );
555
556         c.add (
557                 shared_ptr<dcp::Subtitle> (
558                         new dcp::SubtitleString (
559                                 string ("Arial"),
560                                 false,
561                                 false,
562                                 false,
563                                 dcp::Colour (255, 255, 255),
564                                 48,
565                                 1.0,
566                                 dcp::Time (0, 0, 1, 0, 24),
567                                 dcp::Time (0, 0, 9, 0, 24),
568                                 0,
569                                 dcp::HALIGN_CENTER,
570                                 0.8,
571                                 dcp::VALIGN_TOP,
572                                 dcp::DIRECTION_LTR,
573                                 " fun",
574                                 dcp::NONE,
575                                 dcp::Colour (0, 0, 0),
576                                 dcp::Time (0, 0, 0, 0, 24),
577                                 dcp::Time (0, 0, 0, 0, 24)
578                                 )
579                         )
580                 );
581
582         c.add (
583                 shared_ptr<dcp::Subtitle> (
584                         new dcp::SubtitleString (
585                                 string ("Arial"),
586                                 false,
587                                 false,
588                                 false,
589                                 dcp::Colour (255, 255, 255),
590                                 48,
591                                 1.0,
592                                 dcp::Time (0, 0, 1, 0, 24),
593                                 dcp::Time (0, 0, 9, 0, 24),
594                                 0,
595                                 dcp::HALIGN_CENTER,
596                                 0.9,
597                                 dcp::VALIGN_TOP,
598                                 dcp::DIRECTION_LTR,
599                                 "This is the ",
600                                 dcp::NONE,
601                                 dcp::Colour (0, 0, 0),
602                                 dcp::Time (0, 0, 0, 0, 24),
603                                 dcp::Time (0, 0, 0, 0, 24)
604                                 )
605                         )
606                 );
607
608         c.add (
609                 shared_ptr<dcp::Subtitle> (
610                         new dcp::SubtitleString (
611                                 string ("Arial"),
612                                 true,
613                                 false,
614                                 false,
615                                 dcp::Colour (255, 255, 255),
616                                 48,
617                                 1.0,
618                                 dcp::Time (0, 0, 1, 0, 24),
619                                 dcp::Time (0, 0, 9, 0, 24),
620                                 0,
621                                 dcp::HALIGN_CENTER,
622                                 0.9,
623                                 dcp::VALIGN_TOP,
624                                 dcp::DIRECTION_LTR,
625                                 "second",
626                                 dcp::NONE,
627                                 dcp::Colour (0, 0, 0),
628                                 dcp::Time (0, 0, 0, 0, 24),
629                                 dcp::Time (0, 0, 0, 0, 24)
630                                 )
631                         )
632                 );
633
634         c.add (
635                 shared_ptr<dcp::Subtitle> (
636                         new dcp::SubtitleString (
637                                 string ("Arial"),
638                                 false,
639                                 false,
640                                 false,
641                                 dcp::Colour (255, 255, 255),
642                                 48,
643                                 1.0,
644                                 dcp::Time (0, 0, 1, 0, 24),
645                                 dcp::Time (0, 0, 9, 0, 24),
646                                 0,
647                                 dcp::HALIGN_CENTER,
648                                 0.9,
649                                 dcp::VALIGN_TOP,
650                                 dcp::DIRECTION_LTR,
651                                 " line",
652                                 dcp::NONE,
653                                 dcp::Colour (0, 0, 0),
654                                 dcp::Time (0, 0, 0, 0, 24),
655                                 dcp::Time (0, 0, 0, 0, 24)
656                                 )
657                         )
658                 );
659
660         c._xml_id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
661
662         check_xml (
663                 c.xml_as_string (),
664                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
665                 "<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">"
666                   "<dcst:Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</dcst:Id>"
667                   "<dcst:ContentTitleText>Test</dcst:ContentTitleText>"
668                   "<dcst:IssueDate>2016-04-01T03:52:00.000+00:00</dcst:IssueDate>"
669                   "<dcst:ReelNumber>1</dcst:ReelNumber>"
670                   "<dcst:Language>EN</dcst:Language>"
671                   "<dcst:EditRate>24 1</dcst:EditRate>"
672                   "<dcst:TimeCodeRate>24</dcst:TimeCodeRate>"
673                   "<dcst:SubtitleList>"
674                     "<dcst:Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" ID=\"Arial\" Script=\"normal\" Size=\"48\" Underline=\"no\" Weight=\"normal\">"
675                       "<dcst:Subtitle SpotNumber=\"1\" TimeIn=\"00:00:01:00\" TimeOut=\"00:00:09:00\" FadeUpTime=\"00:00:00:00\" FadeDownTime=\"00:00:00:00\">"
676                         "<dcst:Text Valign=\"top\" Vposition=\"80\">"
677                           "<dcst:Font Italic=\"no\">Testing is </dcst:Font>"
678                           "<dcst:Font Italic=\"yes\">really</dcst:Font>"
679                           "<dcst:Font Italic=\"no\"> fun</dcst:Font>"
680                         "</dcst:Text>"
681                         "<dcst:Text Valign=\"top\" Vposition=\"90\">"
682                           "<dcst:Font Italic=\"no\">This is the </dcst:Font>"
683                           "<dcst:Font Italic=\"yes\">second</dcst:Font>"
684                           "<dcst:Font Italic=\"no\"> line</dcst:Font>"
685                         "</dcst:Text>"
686                       "</dcst:Subtitle>"
687                     "</dcst:Font>"
688                   "</dcst:SubtitleList>"
689                 "</dcst:SubtitleReel>",
690                 list<string> ()
691                 );
692 }
693
694 /* Write some subtitle content as SMPTE using bitmaps and check that it is right */
695 BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test3)
696 {
697         dcp::SMPTESubtitleAsset c;
698         c.set_reel_number (1);
699         c.set_language ("EN");
700         c.set_content_title_text ("Test");
701
702         c.add (
703                 shared_ptr<dcp::Subtitle> (
704                         new dcp::SubtitleImage (
705                                 dcp::Data ("test/data/sub.png"),
706                                 dcp::Time (0, 4,  9, 22, 24),
707                                 dcp::Time (0, 4, 11, 22, 24),
708                                 0,
709                                 dcp::HALIGN_CENTER,
710                                 0.8,
711                                 dcp::VALIGN_TOP,
712                                 dcp::Time (0, 0, 0, 0, 24),
713                                 dcp::Time (0, 0, 0, 0, 24)
714                                 )
715                         )
716                 );
717
718         c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
719
720         boost::filesystem::create_directories ("build/test/write_smpte_subtitle_test3");
721         c.write ("build/test/write_smpte_subtitle_test3/subs.mxf");
722
723         /* XXX: check this result when we can read them back in again */
724 }