X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fkdm_naming_test.cc;h=f692c165d6edde466efde8dcf97a58ea036c7e82;hb=72218f61297458b142e5a2397b01e482d2097270;hp=d45e4a44e7302c1d5e97e7670a3595bca6b77f48;hpb=61dfa6671f042eda2267d7c179ad0468d9bdb5d0;p=dcpomatic.git diff --git a/test/kdm_naming_test.cc b/test/kdm_naming_test.cc index d45e4a44e..f692c165d 100644 --- a/test/kdm_naming_test.cc +++ b/test/kdm_naming_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,22 +18,25 @@ */ + #include "lib/cinema.h" -#include "lib/screen.h" #include "lib/config.h" #include "lib/content_factory.h" #include "lib/film.h" #include "lib/kdm_with_metadata.h" +#include "lib/screen.h" #include "test.h" #include -#include + +using std::dynamic_pointer_cast; using std::list; +using std::make_shared; +using std::shared_ptr; using std::string; using std::vector; -using boost::shared_ptr; using boost::optional; -using boost::dynamic_pointer_cast; + static bool @@ -42,47 +45,47 @@ confirm_overwrite (boost::filesystem::path) return true; } + static shared_ptr cinema_a_screen_1; static shared_ptr cinema_a_screen_2; static shared_ptr cinema_b_screen_x; static shared_ptr cinema_b_screen_y; static shared_ptr cinema_b_screen_z; + BOOST_AUTO_TEST_CASE (single_kdm_naming_test) { - Config* c = Config::instance(); + auto c = Config::instance(); - dcp::Certificate cert = c->decryption_chain()->leaf(); + auto cert = c->decryption_chain()->leaf(); /* Cinema A: UTC +4:30 */ - shared_ptr cinema_a (new Cinema("Cinema A", list(), "", 4, 30)); - cinema_a_screen_1.reset(new dcpomatic::Screen("Screen 1", "", cert, vector())); + auto cinema_a = make_shared("Cinema A", list(), "", 4, 30); + cinema_a_screen_1 = make_shared("Screen 1", "", cert, vector()); cinema_a->add_screen (cinema_a_screen_1); - cinema_a_screen_2.reset(new dcpomatic::Screen("Screen 2", "", cert, vector())); + cinema_a_screen_2 = make_shared("Screen 2", "", cert, vector()); cinema_a->add_screen (cinema_a_screen_2); c->add_cinema (cinema_a); /* Cinema B: UTC -1:00 */ - shared_ptr cinema_b (new Cinema("Cinema B", list(), "", -1, 0)); - cinema_b_screen_x.reset(new dcpomatic::Screen("Screen X", "", cert, vector())); + auto cinema_b = make_shared("Cinema B", list(), "", -1, 0); + cinema_b_screen_x = make_shared("Screen X", "", cert, vector()); cinema_b->add_screen (cinema_b_screen_x); - cinema_b_screen_y.reset(new dcpomatic::Screen("Screen Y", "", cert, vector())); + cinema_b_screen_y = make_shared("Screen Y", "", cert, vector()); cinema_b->add_screen (cinema_b_screen_y); - cinema_b_screen_z.reset(new dcpomatic::Screen("Screen Z", "", cert, vector())); + cinema_b_screen_z = make_shared("Screen Z", "", cert, vector()); cinema_b->add_screen (cinema_b_screen_z); c->add_cinema (cinema_a); /* Film */ boost::filesystem::remove_all ("build/test/single_kdm_naming_test"); - shared_ptr film = new_test_film2 ("single_kdm_naming_test"); + auto film = new_test_film2 ("single_kdm_naming_test"); film->set_name ("my_great_film"); film->examine_and_add_content (content_factory("test/data/flat_black.png").front()); BOOST_REQUIRE (!wait_for_jobs()); film->set_encrypted (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); - film->write_metadata (); - vector cpls = film->cpls (); + make_and_verify_dcp (film); + auto cpls = film->cpls (); BOOST_REQUIRE(cpls.size() == 1); dcp::LocalTime from (cert.not_before()); @@ -90,37 +93,34 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) dcp::LocalTime until (cert.not_after()); until.add_months (-2); - string const from_string = from.date() + " " + from.time_of_day(true, false); - string const until_string = until.date() + " " + until.time_of_day(true, false); + auto const from_string = from.date() + " " + from.time_of_day(true, false); + auto const until_string = until.date() + " " + until.time_of_day(true, false); - boost::filesystem::path cpl = cpls.front().cpl_file; - KDMWithMetadataPtr kdm = kdm_for_screen ( + auto cpl = cpls.front().cpl_file; + auto kdm = kdm_for_screen ( film, cpls.front().cpl_file, cinema_a_screen_1, boost::posix_time::time_from_string(from_string), boost::posix_time::time_from_string(until_string), - dcp::MODIFIED_TRANSITIONAL_1, + dcp::Formulation::MODIFIED_TRANSITIONAL_1, false, optional() ); - list kdms; - kdms.push_back (kdm); - write_files ( - kdms, + { kdm }, boost::filesystem::path("build/test/single_kdm_naming_test"), dcp::NameFormat("KDM %c - %s - %f - %b - %e"), &confirm_overwrite ); - string from_time = from.time_of_day (true, false); + auto from_time = from.time_of_day (true, false); boost::algorithm::replace_all (from_time, ":", "-"); - string until_time = until.time_of_day (true, false); + auto until_time = until.time_of_day (true, false); boost::algorithm::replace_all (until_time, ":", "-"); - string const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time); + auto const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time); BOOST_CHECK_MESSAGE (boost::filesystem::exists("build/test/single_kdm_naming_test/" + ref), "File " << ref << " not found"); } @@ -129,19 +129,19 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( { using boost::filesystem::path; - dcp::Certificate cert = Config::instance()->decryption_chain()->leaf(); + auto cert = Config::instance()->decryption_chain()->leaf(); /* Film */ boost::filesystem::remove_all ("build/test/directory_kdm_naming_test"); - shared_ptr film = new_test_film2 ("directory_kdm_naming_test"); + auto film = new_test_film2 ( + "directory_kdm_naming_test", + { content_factory("test/data/flat_black.png").front() } + ); + film->set_name ("my_great_film"); - film->examine_and_add_content (content_factory("test/data/flat_black.png").front()); - BOOST_REQUIRE (!wait_for_jobs()); film->set_encrypted (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); - film->write_metadata (); - vector cpls = film->cpls (); + make_and_verify_dcp (film); + auto cpls = film->cpls (); BOOST_REQUIRE(cpls.size() == 1); dcp::LocalTime from (cert.not_before()); @@ -152,24 +152,22 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( string const from_string = from.date() + " " + from.time_of_day(true, false); string const until_string = until.date() + " " + until.time_of_day(true, false); - list > screens; - screens.push_back (cinema_a_screen_2); - screens.push_back (cinema_b_screen_x); - screens.push_back (cinema_a_screen_1); - screens.push_back (cinema_b_screen_z); + list> screens = { + cinema_a_screen_2, cinema_b_screen_x, cinema_a_screen_1, (cinema_b_screen_z) + }; - path const cpl = cpls.front().cpl_file; - string const cpl_id = cpls.front().cpl_id; + auto const cpl = cpls.front().cpl_file; + auto const cpl_id = cpls.front().cpl_id; list kdms; - BOOST_FOREACH (shared_ptr i, screens) { - KDMWithMetadataPtr kdm = kdm_for_screen ( + for (auto i: screens) { + auto kdm = kdm_for_screen ( film, cpls.front().cpl_file, i, boost::posix_time::time_from_string(from_string), boost::posix_time::time_from_string(until_string), - dcp::MODIFIED_TRANSITIONAL_1, + dcp::Formulation::MODIFIED_TRANSITIONAL_1, false, optional() ); @@ -181,33 +179,53 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( collect(kdms), path("build/test/directory_kdm_naming_test"), dcp::NameFormat("%c - %s - %f - %b - %e"), +#ifdef DCPOMATIC_WINDOWS + /* With %i in the format the path is too long for Windows */ + dcp::NameFormat("KDM %c - %s - %f - %b - %e"), +#else dcp::NameFormat("KDM %c - %s - %f - %b - %e - %i"), +#endif &confirm_overwrite ); - string from_time = from.time_of_day (true, false); + auto from_time = from.time_of_day (true, false); boost::algorithm::replace_all (from_time, ":", "-"); - string until_time = until.time_of_day (true, false); + auto until_time = until.time_of_day (true, false); boost::algorithm::replace_all (until_time, ":", "-"); path const base = "build/test/directory_kdm_naming_test"; - list::const_iterator i = kdms.begin (); path dir_a = String::compose("Cinema_A_-_%s_-_my_great_film_-_%1_%2_-_%3_%4", from.date(), from_time, until.date(), until_time); BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a), "Directory " << dir_a << " not found"); path dir_b = String::compose("Cinema_B_-_%s_-_my_great_film_-_%1_%2_-_%3_%4", from.date(), from_time, until.date(), until_time); BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b), "Directory " << dir_b << " not found"); +#ifdef DCPOMATIC_WINDOWS + path ref = String::compose("KDM_Cinema_A_-_Screen_2_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time); +#else path ref = String::compose("KDM_Cinema_A_-_Screen_2_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); +#endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found"); +#ifdef DCPOMATIC_WINDOWS + ref = String::compose("KDM_Cinema_B_-_Screen_X_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time); +#else ref = String::compose("KDM_Cinema_B_-_Screen_X_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); +#endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found"); +#ifdef DCPOMATIC_WINDOWS + ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time); +#else ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); +#endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found"); +#ifdef DCPOMATIC_WINDOWS + ref = String::compose("KDM_Cinema_B_-_Screen_Z_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time); +#else ref = String::compose("KDM_Cinema_B_-_Screen_Z_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id); +#endif BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found"); }