<ContentVersion> is optional in Interop so we can't assume it's there.
[libdcp.git] / test / write_subtitle_test.cc
index affc23c6762ee58cd636c35242cee4bb1abff3e2..4bdc6e9d04995f027bfc6bc97c51536d3dd5eb6d 100644 (file)
@@ -46,6 +46,7 @@
 
 using std::list;
 using std::string;
+using boost::optional;
 using boost::shared_ptr;
 
 /** Test dcp::order::Font::take_intersection */
@@ -330,6 +331,8 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test2)
 /* 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;
+
        shared_ptr<dcp::InteropSubtitleAsset> c (new dcp::InteropSubtitleAsset());
        c->set_reel_number ("1");
        c->set_language ("EN");
@@ -352,33 +355,39 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
                );
 
        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");
 
        shared_ptr<dcp::Reel> reel (new dcp::Reel());
        reel->add(shared_ptr<dcp::ReelSubtitleAsset>(new dcp::ReelSubtitleAsset(c, dcp::Fraction(24, 1), 6046, 0)));
 
-       dcp::XMLMetadata xml_meta;
-       xml_meta.issue_date = "2018-09-02T04:45:18+00:00";
-       xml_meta.issuer = "libdcp";
-       xml_meta.creator = "libdcp";
-       xml_meta.annotation_text = "Created by libdcp";
+       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";
 
        shared_ptr<dcp::CPL> cpl (new dcp::CPL ("My film", dcp::FEATURE));
        cpl->add (reel);
-       cpl->set_metadata (xml_meta);
-       cpl->set_content_version_label_text ("foo");
+       cpl->set_issuer (issuer);
+       cpl->set_creator (creator);
+       cpl->set_issue_date (issue_date);
+       cpl->set_annotation_text (annotation_text);
+       optional<dcp::ContentVersion> 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 (dcp::INTEROP, xml_meta);
+       dcp.write_xml (dcp::INTEROP, 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"),
                list<string>()
                );
-       check_file ("build/test/write_interop_subtitle_test3/ef5c6baa-be2d-4f86-9f15-b1acc792ee8b.png", "test/data/sub.png");
+       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"),
@@ -388,7 +397,7 @@ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test3)
 
        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_f5aab304-8145-44e3-a265-aa8d8812d8a2.xml"),
+               dcp::file_to_string("build/test/write_interop_subtitle_test3/pkl_6a9e31a6-50a4-4ecb-8683-fa667848470a.xml"),
                list<string>()
                );
 }