Move some tests from write_subtitle_test into interop_subtitle_test.
authorCarl Hetherington <cth@carlh.net>
Wed, 14 Apr 2021 09:26:08 +0000 (11:26 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 14 Apr 2021 09:26:08 +0000 (11:26 +0200)
test/interop_subtitle_test.cc
test/write_subtitle_test.cc

index 48892db58b0ff6b81eb36694186fa3718d401b8a..7fa0e2d142afb8c80e3809210de9701b52953b60 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-202]1 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
     files in the program, then also delete it here.
 */
 
+
 #include "interop_subtitle_asset.h"
 #include "interop_load_font_node.h"
+#include "reel_interop_subtitle_asset.h"
 #include "subtitle_string.h"
 #include "subtitle_image.h"
+#include "test.h"
 #include <boost/test/unit_test.hpp>
 #include <iostream>
 
+
+using std::dynamic_pointer_cast;
 using std::list;
-using std::string;
+using std::make_shared;
 using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::string;
+using std::vector;
+
 
 /** Load some subtitle content from Interop XML and check that it is read correctly */
 BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
@@ -622,3 +629,239 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test3)
        BOOST_REQUIRE (si);
        BOOST_CHECK (si->png_image() == dcp::ArrayData("test/data/sub.png"));
 }
+
+
+/** Write some subtitle content as Interop XML and check that it is right */
+BOOST_AUTO_TEST_CASE (write_interop_subtitle_test)
+{
+       dcp::InteropSubtitleAsset c;
+       c.set_reel_number ("1");
+       c.set_language ("EN");
+       c.set_movie_title ("Test");
+
+       c.add (
+               make_shared<dcp::SubtitleString>(
+                       string ("Frutiger"),
+                       false,
+                       false,
+                       false,
+                       dcp::Colour (255, 255, 255),
+                       48,
+                       1.0,
+                       dcp::Time (0, 4,  9, 22, 24),
+                       dcp::Time (0, 4, 11, 22, 24),
+                       0,
+                       dcp::HAlign::CENTER,
+                       0.8,
+                       dcp::VAlign::TOP,
+                       dcp::Direction::LTR,
+                       "Hello world",
+                       dcp::Effect::NONE,
+                       dcp::Colour (0, 0, 0),
+                       dcp::Time (0, 0, 0, 0, 24),
+                       dcp::Time (0, 0, 0, 0, 24)
+                       )
+               );
+
+       c.add (
+               make_shared<dcp::SubtitleString>(
+                       boost::optional<string> (),
+                       true,
+                       true,
+                       true,
+                       dcp::Colour (128, 0, 64),
+                       91,
+                       1.0,
+                       dcp::Time (5, 41,  0, 21, 24),
+                       dcp::Time (6, 12, 15, 21, 24),
+                       0,
+                       dcp::HAlign::CENTER,
+                       0.4,
+                       dcp::VAlign::BOTTOM,
+                       dcp::Direction::LTR,
+                       "What's going on",
+                       dcp::Effect::BORDER,
+                       dcp::Colour (1, 2, 3),
+                       dcp::Time (1, 2, 3, 4, 24),
+                       dcp::Time (5, 6, 7, 8, 24)
+                       )
+               );
+
+       c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
+
+       check_xml (
+               "<DCSubtitle Version=\"1.0\">"
+                 "<SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>"
+                 "<MovieTitle>Test</MovieTitle>"
+                 "<ReelNumber>1</ReelNumber>"
+                 "<Language>EN</Language>"
+                 "<Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" Id=\"Frutiger\" Italic=\"no\" Script=\"normal\" Size=\"48\" Underlined=\"no\" Weight=\"normal\">"
+                   "<Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">"
+                     "<Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>"
+                   "</Subtitle>"
+                 "</Font>"
+                 "<Font AspectAdjust=\"1.0\" Color=\"FF800040\" Effect=\"border\" EffectColor=\"FF010203\" Italic=\"yes\" Script=\"normal\" Size=\"91\" Underlined=\"yes\" Weight=\"bold\">"
+                   "<Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">"
+                     "<Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>"
+                   "</Subtitle>"
+                 "</Font>"
+               "</DCSubtitle>",
+               c.xml_as_string (),
+               vector<string>()
+               );
+}
+
+/** Write some subtitle content as Interop XML and check that it is right.
+ *  This test includes some horizontal alignment.
+ */
+BOOST_AUTO_TEST_CASE (write_interop_subtitle_test2)
+{
+       dcp::InteropSubtitleAsset c;
+       c.set_reel_number ("1");
+       c.set_language ("EN");
+       c.set_movie_title ("Test");
+
+       c.add (
+               make_shared<dcp::SubtitleString>(
+                       string ("Frutiger"),
+                       false,
+                       false,
+                       false,
+                       dcp::Colour (255, 255, 255),
+                       48,
+                       1.0,
+                       dcp::Time (0, 4,  9, 22, 24),
+                       dcp::Time (0, 4, 11, 22, 24),
+                       -0.2,
+                       dcp::HAlign::CENTER,
+                       0.8,
+                       dcp::VAlign::TOP,
+                       dcp::Direction::LTR,
+                       "Hello world",
+                       dcp::Effect::NONE,
+                       dcp::Colour (0, 0, 0),
+                       dcp::Time (0, 0, 0, 0, 24),
+                       dcp::Time (0, 0, 0, 0, 24)
+                       )
+               );
+
+       c.add (
+               make_shared<dcp::SubtitleString>(
+                       boost::optional<string>(),
+                       true,
+                       true,
+                       true,
+                       dcp::Colour (128, 0, 64),
+                       91,
+                       1.0,
+                       dcp::Time (5, 41,  0, 21, 24),
+                       dcp::Time (6, 12, 15, 21, 24),
+                       -0.2,
+                       dcp::HAlign::CENTER,
+                       0.4,
+                       dcp::VAlign::BOTTOM,
+                       dcp::Direction::LTR,
+                       "What's going on",
+                       dcp::Effect::BORDER,
+                       dcp::Colour (1, 2, 3),
+                       dcp::Time (1, 2, 3, 4, 24),
+                       dcp::Time (5, 6, 7, 8, 24)
+                       )
+               );
+
+       c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
+
+       check_xml (
+               "<DCSubtitle Version=\"1.0\">"
+                 "<SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>"
+                 "<MovieTitle>Test</MovieTitle>"
+                 "<ReelNumber>1</ReelNumber>"
+                 "<Language>EN</Language>"
+                 "<Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" Id=\"Frutiger\" Italic=\"no\" Script=\"normal\" Size=\"48\" Underlined=\"no\" Weight=\"normal\">"
+                   "<Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">"
+                     "<Text HPosition=\"-20\" VAlign=\"top\" VPosition=\"80\">Hello world</Text>"
+                   "</Subtitle>"
+                 "</Font>"
+                 "<Font AspectAdjust=\"1.0\" Color=\"FF800040\" Effect=\"border\" EffectColor=\"FF010203\" Italic=\"yes\" Script=\"normal\" Size=\"91\" Underlined=\"yes\" Weight=\"bold\">"
+                   "<Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">"
+                     "<Text HPosition=\"-20\" VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>"
+                   "</Subtitle>"
+                 "</Font>"
+               "</DCSubtitle>",
+               c.xml_as_string (),
+               vector<string>()
+               );
+}
+
+/* Write some subtitle content as Interop XML using bitmaps and check that it is right */
+BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
+{
+       RNGFixer fix;
+
+       auto c = make_shared<dcp::InteropSubtitleAsset>();
+       c->set_reel_number ("1");
+       c->set_language ("EN");
+       c->set_movie_title ("Test");
+
+       c->add (
+               make_shared<dcp::SubtitleImage>(
+                       dcp::ArrayData ("test/data/sub.png"),
+                       dcp::Time (0, 4,  9, 22, 24),
+                       dcp::Time (0, 4, 11, 22, 24),
+                       0,
+                       dcp::HAlign::CENTER,
+                       0.8,
+                       dcp::VAlign::TOP,
+                       dcp::Time (0, 0, 0, 0, 24),
+                       dcp::Time (0, 0, 0, 0, 24)
+                       )
+               );
+
+       c->_id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
+       boost::filesystem::remove_all ("build/test/write_interop_subtitle_test3");
+       boost::filesystem::create_directories ("build/test/write_interop_subtitle_test3");
+       c->write ("build/test/write_interop_subtitle_test3/subs.xml");
+
+       auto reel = make_shared<dcp::Reel>();
+       reel->add(make_shared<dcp::ReelInteropSubtitleAsset>(c, dcp::Fraction(24, 1), 6046, 0));
+
+       string const issue_date = "2018-09-02T04:45:18+00:00";
+       string const issuer = "libdcp";
+       string const creator = "libdcp";
+       string const annotation_text = "Created by libdcp";
+
+       auto cpl = make_shared<dcp::CPL>("My film", dcp::ContentKind::FEATURE, dcp::Standard::INTEROP);
+       cpl->add (reel);
+       cpl->set_issuer (issuer);
+       cpl->set_creator (creator);
+       cpl->set_issue_date (issue_date);
+       cpl->set_annotation_text (annotation_text);
+       auto cv = cpl->content_version();
+       BOOST_REQUIRE (cv);
+       cv->label_text = "foo";
+       cpl->set_content_version (*cv);
+
+       dcp::DCP dcp ("build/test/write_interop_subtitle_test3");
+       dcp.add (cpl);
+       dcp.write_xml (issuer, creator, issue_date, annotation_text);
+
+       check_xml (
+               dcp::file_to_string("test/ref/write_interop_subtitle_test3/subs.xml"),
+               dcp::file_to_string("build/test/write_interop_subtitle_test3/subs.xml"),
+               vector<string>()
+               );
+       check_file ("build/test/write_interop_subtitle_test3/d36f4bb3-c4fa-4a95-9915-6fec3110cd71.png", "test/data/sub.png");
+
+       check_xml (
+               dcp::file_to_string("test/ref/write_interop_subtitle_test3/ASSETMAP"),
+               dcp::file_to_string("build/test/write_interop_subtitle_test3/ASSETMAP"),
+               vector<string>()
+               );
+
+       check_xml (
+               dcp::file_to_string("test/ref/write_interop_subtitle_test3/pkl.xml"),
+               dcp::file_to_string("build/test/write_interop_subtitle_test3/pkl_6a9e31a6-50a4-4ecb-8683-fa667848470a.xml"),
+               vector<string>()
+               );
+}
+
index c1b01c05935518c540ae0031567b9a7cb417b82d..2918325bbc95bd4d546e940d6634860de7217486 100644 (file)
@@ -159,237 +159,3 @@ BOOST_AUTO_TEST_CASE (pull_fonts_test3)
        BOOST_CHECK_EQUAL (sub1->font._values["size"], "42");
 }
 
-/** Write some subtitle content as Interop XML and check that it is right */
-BOOST_AUTO_TEST_CASE (write_interop_subtitle_test)
-{
-       dcp::InteropSubtitleAsset c;
-       c.set_reel_number ("1");
-       c.set_language ("EN");
-       c.set_movie_title ("Test");
-
-       c.add (
-               make_shared<dcp::SubtitleString>(
-                       string ("Frutiger"),
-                       false,
-                       false,
-                       false,
-                       dcp::Colour (255, 255, 255),
-                       48,
-                       1.0,
-                       dcp::Time (0, 4,  9, 22, 24),
-                       dcp::Time (0, 4, 11, 22, 24),
-                       0,
-                       dcp::HAlign::CENTER,
-                       0.8,
-                       dcp::VAlign::TOP,
-                       dcp::Direction::LTR,
-                       "Hello world",
-                       dcp::Effect::NONE,
-                       dcp::Colour (0, 0, 0),
-                       dcp::Time (0, 0, 0, 0, 24),
-                       dcp::Time (0, 0, 0, 0, 24)
-                       )
-               );
-
-       c.add (
-               make_shared<dcp::SubtitleString>(
-                       boost::optional<string> (),
-                       true,
-                       true,
-                       true,
-                       dcp::Colour (128, 0, 64),
-                       91,
-                       1.0,
-                       dcp::Time (5, 41,  0, 21, 24),
-                       dcp::Time (6, 12, 15, 21, 24),
-                       0,
-                       dcp::HAlign::CENTER,
-                       0.4,
-                       dcp::VAlign::BOTTOM,
-                       dcp::Direction::LTR,
-                       "What's going on",
-                       dcp::Effect::BORDER,
-                       dcp::Colour (1, 2, 3),
-                       dcp::Time (1, 2, 3, 4, 24),
-                       dcp::Time (5, 6, 7, 8, 24)
-                       )
-               );
-
-       c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
-
-       check_xml (
-               "<DCSubtitle Version=\"1.0\">"
-                 "<SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>"
-                 "<MovieTitle>Test</MovieTitle>"
-                 "<ReelNumber>1</ReelNumber>"
-                 "<Language>EN</Language>"
-                 "<Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" Id=\"Frutiger\" Italic=\"no\" Script=\"normal\" Size=\"48\" Underlined=\"no\" Weight=\"normal\">"
-                   "<Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">"
-                     "<Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>"
-                   "</Subtitle>"
-                 "</Font>"
-                 "<Font AspectAdjust=\"1.0\" Color=\"FF800040\" Effect=\"border\" EffectColor=\"FF010203\" Italic=\"yes\" Script=\"normal\" Size=\"91\" Underlined=\"yes\" Weight=\"bold\">"
-                   "<Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">"
-                     "<Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>"
-                   "</Subtitle>"
-                 "</Font>"
-               "</DCSubtitle>",
-               c.xml_as_string (),
-               vector<string>()
-               );
-}
-
-/** Write some subtitle content as Interop XML and check that it is right.
- *  This test includes some horizontal alignment.
- */
-BOOST_AUTO_TEST_CASE (write_interop_subtitle_test2)
-{
-       dcp::InteropSubtitleAsset c;
-       c.set_reel_number ("1");
-       c.set_language ("EN");
-       c.set_movie_title ("Test");
-
-       c.add (
-               make_shared<dcp::SubtitleString>(
-                       string ("Frutiger"),
-                       false,
-                       false,
-                       false,
-                       dcp::Colour (255, 255, 255),
-                       48,
-                       1.0,
-                       dcp::Time (0, 4,  9, 22, 24),
-                       dcp::Time (0, 4, 11, 22, 24),
-                       -0.2,
-                       dcp::HAlign::CENTER,
-                       0.8,
-                       dcp::VAlign::TOP,
-                       dcp::Direction::LTR,
-                       "Hello world",
-                       dcp::Effect::NONE,
-                       dcp::Colour (0, 0, 0),
-                       dcp::Time (0, 0, 0, 0, 24),
-                       dcp::Time (0, 0, 0, 0, 24)
-                       )
-               );
-
-       c.add (
-               make_shared<dcp::SubtitleString>(
-                       boost::optional<string>(),
-                       true,
-                       true,
-                       true,
-                       dcp::Colour (128, 0, 64),
-                       91,
-                       1.0,
-                       dcp::Time (5, 41,  0, 21, 24),
-                       dcp::Time (6, 12, 15, 21, 24),
-                       -0.2,
-                       dcp::HAlign::CENTER,
-                       0.4,
-                       dcp::VAlign::BOTTOM,
-                       dcp::Direction::LTR,
-                       "What's going on",
-                       dcp::Effect::BORDER,
-                       dcp::Colour (1, 2, 3),
-                       dcp::Time (1, 2, 3, 4, 24),
-                       dcp::Time (5, 6, 7, 8, 24)
-                       )
-               );
-
-       c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
-
-       check_xml (
-               "<DCSubtitle Version=\"1.0\">"
-                 "<SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>"
-                 "<MovieTitle>Test</MovieTitle>"
-                 "<ReelNumber>1</ReelNumber>"
-                 "<Language>EN</Language>"
-                 "<Font AspectAdjust=\"1.0\" Color=\"FFFFFFFF\" Effect=\"none\" EffectColor=\"FF000000\" Id=\"Frutiger\" Italic=\"no\" Script=\"normal\" Size=\"48\" Underlined=\"no\" Weight=\"normal\">"
-                   "<Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:229\" TimeOut=\"00:04:11:229\" FadeUpTime=\"0\" FadeDownTime=\"0\">"
-                     "<Text HPosition=\"-20\" VAlign=\"top\" VPosition=\"80\">Hello world</Text>"
-                   "</Subtitle>"
-                 "</Font>"
-                 "<Font AspectAdjust=\"1.0\" Color=\"FF800040\" Effect=\"border\" EffectColor=\"FF010203\" Italic=\"yes\" Script=\"normal\" Size=\"91\" Underlined=\"yes\" Weight=\"bold\">"
-                   "<Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:219\" TimeOut=\"06:12:15:219\" FadeUpTime=\"930792\" FadeDownTime=\"4591834\">"
-                     "<Text HPosition=\"-20\" VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>"
-                   "</Subtitle>"
-                 "</Font>"
-               "</DCSubtitle>",
-               c.xml_as_string (),
-               vector<string>()
-               );
-}
-
-/* Write some subtitle content as Interop XML using bitmaps and check that it is right */
-BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
-{
-       RNGFixer fix;
-
-       auto c = make_shared<dcp::InteropSubtitleAsset>();
-       c->set_reel_number ("1");
-       c->set_language ("EN");
-       c->set_movie_title ("Test");
-
-       c->add (
-               make_shared<dcp::SubtitleImage>(
-                       dcp::ArrayData ("test/data/sub.png"),
-                       dcp::Time (0, 4,  9, 22, 24),
-                       dcp::Time (0, 4, 11, 22, 24),
-                       0,
-                       dcp::HAlign::CENTER,
-                       0.8,
-                       dcp::VAlign::TOP,
-                       dcp::Time (0, 0, 0, 0, 24),
-                       dcp::Time (0, 0, 0, 0, 24)
-                       )
-               );
-
-       c->_id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
-       boost::filesystem::remove_all ("build/test/write_interop_subtitle_test3");
-       boost::filesystem::create_directories ("build/test/write_interop_subtitle_test3");
-       c->write ("build/test/write_interop_subtitle_test3/subs.xml");
-
-       auto reel = make_shared<dcp::Reel>();
-       reel->add(make_shared<dcp::ReelInteropSubtitleAsset>(c, dcp::Fraction(24, 1), 6046, 0));
-
-       string const issue_date = "2018-09-02T04:45:18+00:00";
-       string const issuer = "libdcp";
-       string const creator = "libdcp";
-       string const annotation_text = "Created by libdcp";
-
-       auto cpl = make_shared<dcp::CPL>("My film", dcp::ContentKind::FEATURE, dcp::Standard::INTEROP);
-       cpl->add (reel);
-       cpl->set_issuer (issuer);
-       cpl->set_creator (creator);
-       cpl->set_issue_date (issue_date);
-       cpl->set_annotation_text (annotation_text);
-       auto cv = cpl->content_version();
-       BOOST_REQUIRE (cv);
-       cv->label_text = "foo";
-       cpl->set_content_version (*cv);
-
-       dcp::DCP dcp ("build/test/write_interop_subtitle_test3");
-       dcp.add (cpl);
-       dcp.write_xml (issuer, creator, issue_date, annotation_text);
-
-       check_xml (
-               dcp::file_to_string("test/ref/write_interop_subtitle_test3/subs.xml"),
-               dcp::file_to_string("build/test/write_interop_subtitle_test3/subs.xml"),
-               vector<string>()
-               );
-       check_file ("build/test/write_interop_subtitle_test3/d36f4bb3-c4fa-4a95-9915-6fec3110cd71.png", "test/data/sub.png");
-
-       check_xml (
-               dcp::file_to_string("test/ref/write_interop_subtitle_test3/ASSETMAP"),
-               dcp::file_to_string("build/test/write_interop_subtitle_test3/ASSETMAP"),
-               vector<string>()
-               );
-
-       check_xml (
-               dcp::file_to_string("test/ref/write_interop_subtitle_test3/pkl.xml"),
-               dcp::file_to_string("build/test/write_interop_subtitle_test3/pkl_6a9e31a6-50a4-4ecb-8683-fa667848470a.xml"),
-               vector<string>()
-               );
-}
-