From 5b734ff2d8d9c26fceaa7804fb2aebcc0c60aa50 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 3 Sep 2020 12:09:39 +0200 Subject: [PATCH] Add some new verification tests. --- test/verify_test.cc | 119 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/test/verify_test.cc b/test/verify_test.cc index f70c53e7..47828ca5 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -743,3 +743,122 @@ BOOST_AUTO_TEST_CASE (verify_test22) } +/* DCP with valid CompositionMetadataAsset */ +BOOST_AUTO_TEST_CASE (verify_test23) +{ + boost::filesystem::path const dir("build/test/verify_test23"); + boost::filesystem::remove_all (dir); + boost::filesystem::create_directories (dir); + + boost::filesystem::copy_file ("test/data/subs.mxf", dir / "subs.mxf"); + shared_ptr asset(new dcp::SMPTESubtitleAsset(dir / "subs.mxf")); + shared_ptr reel_asset(new dcp::ReelSubtitleAsset(asset, dcp::Fraction(24, 1), 16 * 24, 0)); + + shared_ptr reel(new dcp::Reel()); + reel->add (reel_asset); + shared_ptr cpl(new dcp::CPL("hello", dcp::FEATURE)); + cpl->add (reel); + cpl->set_main_sound_configuration ("L,C,R,Lfe,-,-"); + cpl->set_main_sound_sample_rate (48000); + cpl->set_main_picture_stored_area (dcp::Size(1998, 1080)); + cpl->set_main_picture_active_area (dcp::Size(1440, 1080)); + + dcp::DCP dcp (dir); + dcp.add (cpl); + dcp.write_xml (dcp::SMPTE); + + vector dirs; + dirs.push_back (dir); + list notes = dcp::verify (dirs, &stage, &progress, xsd_test); +} + + +boost::filesystem::path find_cpl (boost::filesystem::path dir) +{ + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator(dir); i != boost::filesystem::directory_iterator(); i++) { + if (boost::starts_with(i->path().filename().string(), "cpl_")) { + return i->path(); + } + } + + BOOST_REQUIRE (false); + return boost::filesystem::path(); +} + + +/* DCP with invalid CompositionMetadataAsset */ +BOOST_AUTO_TEST_CASE (verify_test24) +{ + boost::filesystem::path const dir("build/test/verify_test24"); + boost::filesystem::remove_all (dir); + boost::filesystem::create_directories (dir); + + shared_ptr reel(new dcp::Reel()); + reel->add (black_picture_asset(dir)); + shared_ptr cpl(new dcp::CPL("hello", dcp::FEATURE)); + cpl->add (reel); + cpl->set_main_sound_configuration ("L,C,R,Lfe,-,-"); + cpl->set_main_sound_sample_rate (48000); + cpl->set_main_picture_stored_area (dcp::Size(1998, 1080)); + cpl->set_main_picture_active_area (dcp::Size(1440, 1080)); + + dcp::DCP dcp (dir); + dcp.add (cpl); + dcp.write_xml (dcp::SMPTE); + + { + Editor e (find_cpl("build/test/verify_test24")); + e.replace ("MainSound", "MainSoundX"); + } + + vector dirs; + dirs.push_back (dir); + list notes = dcp::verify (dirs, &stage, &progress, xsd_test); + BOOST_REQUIRE_EQUAL (notes.size(), 4); + + list::const_iterator i = notes.begin (); + BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::XML_VALIDATION_ERROR); + ++i; + BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::XML_VALIDATION_ERROR); + ++i; + BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::XML_VALIDATION_ERROR); + ++i; + BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::CPL_HASH_INCORRECT); + ++i; +} + + +/* DCP with invalid CompositionMetadataAsset */ +BOOST_AUTO_TEST_CASE (verify_test25) +{ + boost::filesystem::path const dir("build/test/verify_test25"); + boost::filesystem::remove_all (dir); + boost::filesystem::create_directories (dir); + + boost::filesystem::copy_file ("test/data/subs.mxf", dir / "subs.mxf"); + shared_ptr asset(new dcp::SMPTESubtitleAsset(dir / "subs.mxf")); + shared_ptr reel_asset(new dcp::ReelSubtitleAsset(asset, dcp::Fraction(24, 1), 16 * 24, 0)); + + shared_ptr reel(new dcp::Reel()); + reel->add (reel_asset); + shared_ptr cpl(new dcp::CPL("hello", dcp::FEATURE)); + cpl->add (reel); + cpl->set_main_sound_configuration ("L,C,R,Lfe,-,-"); + cpl->set_main_sound_sample_rate (48000); + cpl->set_main_picture_stored_area (dcp::Size(1998, 1080)); + cpl->set_main_picture_active_area (dcp::Size(1440, 1080)); + + dcp::DCP dcp (dir); + dcp.add (cpl); + dcp.write_xml (dcp::SMPTE); + + { + Editor e (find_cpl("build/test/verify_test25")); + e.replace ("", ""); + } + + vector dirs; + dirs.push_back (dir); + list notes = dcp::verify (dirs, &stage, &progress, xsd_test); +} + -- 2.30.2