Update test signer chain again.
[dcpomatic.git] / test / film_metadata_test.cc
index f1313497adae172d82fbe3396a9c29d1a169ee97..62cb5cf1d562f47a95868b70a3416cba03bb9e5b 100644 (file)
@@ -41,7 +41,7 @@
 using std::string;
 using std::list;
 using std::make_shared;
-using std::shared_ptr;
+using std::vector;
 
 
 BOOST_AUTO_TEST_CASE (film_metadata_test)
@@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE (film_metadata_test)
        film->set_release_territory (dcp::LanguageTag::RegionSubtag("US"));
        film->write_metadata ();
 
-       list<string> ignore = { "Key", "ContextID" };
+       list<string> ignore = { "Key", "ContextID", "LastWrittenBy" };
        check_xml ("test/data/metadata.xml.ref", dir.string() + "/metadata.xml", ignore);
 
        auto g = make_shared<Film>(dir);
@@ -107,8 +107,11 @@ BOOST_AUTO_TEST_CASE (multiple_text_nodes_are_allowed)
 BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_1)
 {
        namespace fs = boost::filesystem;
-       auto film = make_shared<Film>(fs::path("build/test/metadata_loads_from_2_14_x_1"));
-       auto notes = film->read_metadata(fs::path("test/data/2.14.x.metadata.1.xml"));
+       auto dir = fs::path("build/test/metadata_loads_from_2_14_x_1");
+       fs::remove_all(dir);
+       auto film = make_shared<Film>(dir);
+       fs::copy_file("test/data/2.14.x.metadata.1.xml", dir / "metadata.xml");
+       auto notes = film->read_metadata(dir / "metadata.xml");
        BOOST_REQUIRE_EQUAL (notes.size(), 0U);
 }
 
@@ -117,8 +120,11 @@ BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_1)
 BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_2)
 {
        namespace fs = boost::filesystem;
-       auto film = make_shared<Film>(fs::path("build/test/metadata_loads_from_2_14_x_2"));
-       auto notes = film->read_metadata(fs::path("test/data/2.14.x.metadata.2.xml"));
+       auto dir = fs::path("build/test/metadata_loads_from_2_14_x_2");
+       fs::remove_all(dir);
+       auto film = make_shared<Film>(dir);
+       fs::copy_file("test/data/2.14.x.metadata.2.xml", dir / "metadata.xml");
+       auto notes = film->read_metadata(dir / "metadata.xml");
        BOOST_REQUIRE_EQUAL (notes.size(), 1U);
        BOOST_REQUIRE_EQUAL (notes.front(),
                       "A subtitle or closed caption file in this project is marked with the language 'eng', "
@@ -126,3 +132,45 @@ BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_2)
                       );
 }
 
+
+BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_3)
+{
+       namespace fs = boost::filesystem;
+       auto dir = fs::path("build/test/metadata_loads_from_2_14_x_3");
+       fs::remove_all(dir);
+       auto film = make_shared<Film>(dir);
+       fs::copy_file("test/data/2.14.x.metadata.3.xml", dir / "metadata.xml");
+       auto notes = film->read_metadata(dir / "metadata.xml");
+
+       BOOST_REQUIRE (film->release_territory());
+       BOOST_REQUIRE (film->release_territory()->subtag() == dcp::LanguageTag::RegionSubtag("de").subtag());
+
+       BOOST_REQUIRE (film->audio_language());
+       BOOST_REQUIRE (*film->audio_language() == dcp::LanguageTag("sv-SE"));
+
+       BOOST_REQUIRE (film->content_versions() == vector<string>{"3"});
+       BOOST_REQUIRE (film->ratings() == vector<dcp::Rating>{ dcp::Rating("", "214rating") });
+       BOOST_REQUIRE_EQUAL (film->studio().get_value_or(""), "214studio");
+       BOOST_REQUIRE_EQUAL (film->facility().get_value_or(""), "214facility");
+       BOOST_REQUIRE_EQUAL (film->temp_version(), true);
+       BOOST_REQUIRE_EQUAL (film->pre_release(), true);
+       BOOST_REQUIRE_EQUAL (film->red_band(), true);
+       BOOST_REQUIRE_EQUAL (film->two_d_version_of_three_d(), true);
+       BOOST_REQUIRE_EQUAL (film->chain().get_value_or(""), "214chain");
+       BOOST_REQUIRE (film->luminance() == dcp::Luminance(14, dcp::Luminance::Unit::FOOT_LAMBERT));
+}
+
+
+/** Check that an empty <MasteredLuminance> tag results in the film's luminance being unset */
+BOOST_AUTO_TEST_CASE (metadata_loads_from_2_14_x_4)
+{
+       namespace fs = boost::filesystem;
+       auto dir = fs::path("build/test/metadata_loads_from_2_14_x_4");
+       fs::remove_all(dir);
+       auto film = make_shared<Film>(dir);
+       fs::copy_file("test/data/2.14.x.metadata.4.xml", dir / "metadata.xml");
+       auto notes = film->read_metadata(dir / "metadata.xml");
+
+       BOOST_REQUIRE (!film->luminance());
+}
+