From: Carl Hetherington Date: Sun, 21 Feb 2021 19:28:59 +0000 (+0100) Subject: Verify a whole bunch of DCPs made by unit tests. X-Git-Tag: v2.15.131~4 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=41262015eb2bb1fc3da8585883420975de381a65 Verify a whole bunch of DCPs made by unit tests. --- diff --git a/test/atmos_test.cc b/test/atmos_test.cc index 50b642c1f..c3e8c341c 100644 --- a/test/atmos_test.cc +++ b/test/atmos_test.cc @@ -40,15 +40,16 @@ BOOST_AUTO_TEST_CASE (atmos_passthrough_test) { Cleanup cl; - auto film = new_test_film2 ("atmos_passthrough_test", &cl); - auto ref = TestPaths::private_data() / "atmos_asset.mxf"; - auto content = content_factory (TestPaths::private_data() / "atmos_asset.mxf").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 ( + "atmos_passthrough_test", + { content_factory(TestPaths::private_data() / "atmos_asset.mxf").front() }, + &cl + ); film->make_dcp (); BOOST_REQUIRE (!wait_for_jobs()); + auto ref = TestPaths::private_data() / "atmos_asset.mxf"; BOOST_REQUIRE (mxf_atmos_files_same(ref, dcp_file(film, "atmos"), true)); cl.run (); @@ -59,16 +60,13 @@ BOOST_AUTO_TEST_CASE (atmos_encrypted_passthrough_test) { Cleanup cl; - auto film = new_test_film2 ("atmos_encrypted_passthrough_test", &cl); auto ref = TestPaths::private_data() / "atmos_asset.mxf"; auto content = content_factory (TestPaths::private_data() / "atmos_asset.mxf").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 ("atmos_encrypted_passthrough_test", {content}, &cl); film->set_encrypted (true); film->_key = dcp::Key ("4fac12927eb122af1c2781aa91f3a4cc"); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_CPL_METADATA }); BOOST_REQUIRE (!mxf_atmos_files_same(ref, dcp_file(film, "atmos"))); @@ -83,14 +81,10 @@ BOOST_AUTO_TEST_CASE (atmos_encrypted_passthrough_test) optional() ); - auto film2 = new_test_film2 ("atmos_encrypted_passthrough_test2", &cl); auto content2 = make_shared(film->dir(film->dcp_name())); content2->add_kdm (kdm); - film2->examine_and_add_content (content2); - BOOST_REQUIRE (!wait_for_jobs()); - - film2->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + auto film2 = new_test_film2 ("atmos_encrypted_passthrough_test2", {content2}, &cl); + make_and_verify_dcp (film2, { dcp::VerificationNote::Code::MISSING_CPL_METADATA }); BOOST_CHECK (mxf_atmos_files_same(ref, dcp_file(film2, "atmos"), true)); diff --git a/test/audio_delay_test.cc b/test/audio_delay_test.cc index f229446f0..d8d69424b 100644 --- a/test/audio_delay_test.cc +++ b/test/audio_delay_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + /** @defgroup feature Tests of features */ /** @file test/audio_delay_test.cc @@ -27,25 +28,29 @@ * The output is checked algorithmically using knowledge of the input. */ -#include -#include + +#include "lib/audio_content.h" +#include "lib/dcp_content_type.h" +#include "lib/ffmpeg_content.h" +#include "lib/film.h" +#include "lib/ratio.h" +#include "test.h" #include #include +#include #include #include -#include -#include "lib/ffmpeg_content.h" -#include "lib/dcp_content_type.h" -#include "lib/ratio.h" -#include "lib/film.h" -#include "lib/audio_content.h" -#include "test.h" +#include +#include #include -using std::string; + using std::cout; -using boost::lexical_cast; +using std::make_shared; using std::shared_ptr; +using std::string; +using boost::lexical_cast; + static void test_audio_delay (int delay_in_ms) @@ -53,18 +58,14 @@ void test_audio_delay (int delay_in_ms) BOOST_TEST_MESSAGE ("Testing delay of " << delay_in_ms); string const film_name = "audio_delay_test_" + lexical_cast (delay_in_ms); - shared_ptr film = new_test_film (film_name); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); - film->set_container (Ratio::from_id ("185")); - film->set_name (film_name); - - shared_ptr content (new FFmpegContent("test/data/staircase.wav")); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); + auto content = make_shared("test/data/staircase.wav"); + shared_ptr film = new_test_film2 ( + film_name, { content } + ); + content->audio->set_delay (delay_in_ms); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_CPL_METADATA }); boost::filesystem::path path = "build/test"; path /= film_name; @@ -73,7 +74,7 @@ void test_audio_delay (int delay_in_ms) dcp::DCP check (path.string ()); check.read (); - shared_ptr sound_asset = check.cpls().front()->reels().front()->main_sound (); + auto sound_asset = check.cpls().front()->reels().front()->main_sound (); BOOST_CHECK (sound_asset); /* Sample index in the DCP */ @@ -103,6 +104,7 @@ void test_audio_delay (int delay_in_ms) } } + /* Test audio delay when specified in a piece of audio content */ BOOST_AUTO_TEST_CASE (audio_delay_test) { diff --git a/test/burnt_subtitle_test.cc b/test/burnt_subtitle_test.cc index 25ad3f66b..1d689e332 100644 --- a/test/burnt_subtitle_test.cc +++ b/test/burnt_subtitle_test.cc @@ -83,8 +83,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_dcp) content->subtitle->set_use (true); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); check_dcp ("test/data/burnt_subtitle_test_dcp", film->dir (film->dcp_name ())); } @@ -98,8 +97,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp) film->set_name ("frobozz"); film->examine_and_add_content (content_factory(film, "test/data/flat_black.png").front()); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); Config::instance()->set_log_types (Config::instance()->log_types() | LogEntry::TYPE_DEBUG_ENCODE); auto film2 = new_test_film ("burnt_subtitle_test_onto_dcp2"); @@ -115,8 +113,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp) sub->subtitle->set_outline (true); film2->examine_and_add_content (sub); BOOST_REQUIRE (!wait_for_jobs()); - film2->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film2); BOOST_CHECK (background_dcp->position() == DCPTime()); BOOST_CHECK (sub->position() == DCPTime()); diff --git a/test/closed_caption_test.cc b/test/closed_caption_test.cc index cc2dca930..434aacde3 100644 --- a/test/closed_caption_test.cc +++ b/test/closed_caption_test.cc @@ -37,10 +37,8 @@ BOOST_AUTO_TEST_CASE (closed_caption_test1) { Cleanup cl; - auto film = new_test_film2 ("closed_caption_test1", &cl); auto content = make_shared("test/data/subrip.srt"); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); + auto film = new_test_film2 ("closed_caption_test1", { content }, &cl); content->only_text()->set_type (TextType::CLOSED_CAPTION); @@ -65,15 +63,10 @@ BOOST_AUTO_TEST_CASE (closed_caption_test1) BOOST_AUTO_TEST_CASE (closed_caption_test2) { Cleanup cl; - - auto film = new_test_film2 ("closed_caption_test2", &cl); auto content1 = make_shared("test/data/subrip.srt"); - film->examine_and_add_content (content1); auto content2 = make_shared("test/data/subrip2.srt"); - film->examine_and_add_content (content2); auto content3 = make_shared("test/data/subrip3.srt"); - film->examine_and_add_content (content3); - BOOST_REQUIRE (!wait_for_jobs ()); + auto film = new_test_film2 ("closed_caption_test2", { content1, content2, content3 }, &cl); content1->only_text()->set_type (TextType::CLOSED_CAPTION); content1->only_text()->set_dcp_track (DCPTextTrack("First track", "fr-FR")); @@ -82,8 +75,14 @@ BOOST_AUTO_TEST_CASE (closed_caption_test2) content3->only_text()->set_type (TextType::CLOSED_CAPTION); content3->only_text()->set_dcp_track (DCPTextTrack("Third track", "it-IT")); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION, + dcp::VerificationNote::Code::INVALID_CLOSED_CAPTION_LINE_LENGTH, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + } + ); dcp::DCP check (film->dir(film->dcp_name())); check.read (); diff --git a/test/content_test.cc b/test/content_test.cc index cf34251f5..ef3b710e7 100644 --- a/test/content_test.cc +++ b/test/content_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2018 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/content_test.cc * @brief Tests which expose problems with certain pieces of content. * @ingroup completedcp */ + #include "lib/audio_content.h" #include "lib/film.h" #include "lib/dcp_content_type.h" @@ -32,63 +34,58 @@ #include "test.h" #include + using std::shared_ptr; using namespace dcpomatic; + /** There has been garbled audio with this piece of content */ BOOST_AUTO_TEST_CASE (content_test1) { - shared_ptr film = new_test_film ("content_test1"); + auto film = new_test_film ("content_test1"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_name ("content_test1"); film->set_container (Ratio::from_id ("185")); - shared_ptr content = content_factory(TestPaths::private_data() / "demo_sound_bug.mkv").front (); + auto content = content_factory(TestPaths::private_data() / "demo_sound_bug.mkv").front (); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp ( + film, + { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE } + ); boost::filesystem::path check; - for ( - boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator("build/test/content_test1/" + film->dcp_name()); - i != boost::filesystem::directory_iterator(); - ++i) { - - if (i->path().leaf().string().substr(0, 4) == "pcm_") { - check = *i; + for (auto i: boost::filesystem::directory_iterator("build/test/content_test1/" + film->dcp_name())) { + if (i.path().leaf().string().substr(0, 4) == "pcm_") { + check = i; } } check_mxf_audio_file (TestPaths::private_data() / "content_test1.mxf", check); } + /** Taking some 23.976fps content and trimming 0.5s (in content time) from the start * has failed in the past; ensure that this is fixed. */ BOOST_AUTO_TEST_CASE (content_test2) { - shared_ptr film = new_test_film2 ("content_test2"); - - shared_ptr content = content_factory("test/data/red_23976.mp4").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); + auto content = content_factory("test/data/red_23976.mp4").front(); + auto film = new_test_film2 ("content_test2", {content}); content->set_trim_start(ContentTime::from_seconds(0.5)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); } + /** Check that position and start trim of video content is forced to a frame boundary */ BOOST_AUTO_TEST_CASE (content_test3) { - shared_ptr film = new_test_film2 ("content_test3"); + auto content = content_factory("test/data/red_24.mp4").front(); + auto film = new_test_film2 ("content_test3", {content}); film->set_sequence (false); - shared_ptr content = content_factory("test/data/red_24.mp4").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); - /* Trim */ /* 12 frames */ @@ -128,9 +125,9 @@ BOOST_AUTO_TEST_CASE (content_test3) /** Content containing video will have its length rounded to the nearest video frame */ BOOST_AUTO_TEST_CASE (content_test4) { - shared_ptr film = new_test_film2 ("content_test4"); + auto film = new_test_film2 ("content_test4"); - shared_ptr video = content_factory("test/data/count300bd24.m2ts").front(); + auto video = content_factory("test/data/count300bd24.m2ts").front(); film->examine_and_add_content (video); BOOST_REQUIRE (!wait_for_jobs()); @@ -142,13 +139,11 @@ BOOST_AUTO_TEST_CASE (content_test4) /** Content containing no video will not have its length rounded to the nearest video frame */ BOOST_AUTO_TEST_CASE (content_test5) { - shared_ptr film = new_test_film2 ("content_test5"); - - shared_ptr audio = content_factory("test/data/sine_16_48_220_10.wav").front(); - film->examine_and_add_content (audio); - BOOST_REQUIRE (!wait_for_jobs()); + auto audio = content_factory("test/data/sine_16_48_220_10.wav").front(); + auto film = new_test_film2 ("content_test5", {audio}); audio->set_trim_end (dcpomatic::ContentTime(3000)); + BOOST_CHECK (audio->length_after_trim(film) == DCPTime(957000)); } @@ -158,11 +153,13 @@ BOOST_AUTO_TEST_CASE (content_test6) { Cleanup cl; - auto film = new_test_film2 ("content_test6", &cl); - film->examine_and_add_content (content_factory(TestPaths::private_data() / "fha.mkv").front()); - BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 ( + "content_test6", + { content_factory(TestPaths::private_data() / "fha.mkv").front() }, + &cl + ); + + make_and_verify_dcp (film); check_dcp (TestPaths::private_data() / "fha", film); cl.run (); @@ -172,11 +169,8 @@ BOOST_AUTO_TEST_CASE (content_test6) /** Reel length error when making the test for #1833 */ BOOST_AUTO_TEST_CASE (content_test7) { - shared_ptr film = new_test_film2 ("content_test7"); - shared_ptr content = content_factory(TestPaths::private_data() / "clapperboard.mp4").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); + auto content = content_factory(TestPaths::private_data() / "clapperboard.mp4").front(); + auto film = new_test_film2 ("content_test7", {content}); content->audio->set_delay (-1000); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K }); } diff --git a/test/cpl_hash_test.cc b/test/cpl_hash_test.cc index 5b15c6ee0..f34c29583 100644 --- a/test/cpl_hash_test.cc +++ b/test/cpl_hash_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,6 +18,7 @@ */ + /** @file test/cpl_hash_test.cc * @brief Make sure that tags are always written to CPLs where required. * @ingroup feature @@ -33,8 +34,9 @@ #include -using std::string; +using std::make_shared; using std::shared_ptr; +using std::string; BOOST_AUTO_TEST_CASE (hash_added_to_imported_dcp_test) @@ -42,46 +44,45 @@ BOOST_AUTO_TEST_CASE (hash_added_to_imported_dcp_test) using namespace boost::filesystem; string const ov_name = "hash_added_to_imported_dcp_test_ov"; - shared_ptr ov = new_test_film2 (ov_name); - ov->examine_and_add_content (content_factory("test/data/flat_red.png").front()); - BOOST_REQUIRE (!wait_for_jobs()); - ov->make_dcp(); - BOOST_REQUIRE (!wait_for_jobs()); + shared_ptr ov = new_test_film2 ( + ov_name, + { content_factory("test/data/flat_red.png").front() } + ); + make_and_verify_dcp (ov); /* Remove tags from the CPL */ - for (directory_iterator i = directory_iterator(String::compose("build/test/%1/%2", ov_name, ov->dcp_name())); i != directory_iterator(); ++i) { - if (boost::algorithm::starts_with(i->path().filename().string(), "cpl_")) { - FILE* in = fopen_boost(i->path(), "r"); + for (auto i: directory_iterator(String::compose("build/test/%1/%2", ov_name, ov->dcp_name()))) { + if (boost::algorithm::starts_with(i.path().filename().string(), "cpl_")) { + auto in = fopen_boost(i.path(), "r"); BOOST_REQUIRE (in); - FILE* out = fopen_boost(i->path().string() + ".tmp", "w"); + auto out = fopen_boost(i.path().string() + ".tmp", "w"); BOOST_REQUIRE (out); char buffer[256]; - while (fgets (buffer, sizeof(buffer), in)) { + while (fgets(buffer, sizeof(buffer), in)) { if (string(buffer).find("Hash") == string::npos) { fputs (buffer, out); } } fclose (in); fclose (out); - rename (i->path().string() + ".tmp", i->path()); + rename (i.path().string() + ".tmp", i.path()); } } string const vf_name = "hash_added_to_imported_dcp_test_vf"; - shared_ptr vf = new_test_film2 (vf_name); - shared_ptr ov_content(new DCPContent(String::compose("build/test/%1/%2", ov_name, ov->dcp_name()))); - vf->examine_and_add_content (ov_content); - BOOST_REQUIRE (!wait_for_jobs()); + auto ov_content = make_shared(String::compose("build/test/%1/%2", ov_name, ov->dcp_name())); + auto vf = new_test_film2 ( + vf_name, { ov_content } + ); ov_content->set_reference_video (true); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); /* Check for Hash tags in the VF DCP */ int hashes = 0; - for (directory_iterator i = directory_iterator(String::compose("build/test/%1/%2", vf_name, vf->dcp_name())); i != directory_iterator(); ++i) { - if (boost::algorithm::starts_with(i->path().filename().string(), "cpl_")) { - FILE* in = fopen_boost(i->path(), "r"); + for (auto i: directory_iterator(String::compose("build/test/%1/%2", vf_name, vf->dcp_name()))) { + if (boost::algorithm::starts_with(i.path().filename().string(), "cpl_")) { + auto in = fopen_boost(i.path(), "r"); BOOST_REQUIRE (in); char buffer[256]; while (fgets (buffer, sizeof(buffer), in)) { diff --git a/test/data b/test/data index 21f386365..3eb05f598 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 21f386365bef1ee6f8073c088679357fbbb13f9d +Subproject commit 3eb05f5989dcb601bde60c4badc95b66cf46a0cb diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc index 1bde43763..d923448d3 100644 --- a/test/dcp_subtitle_test.cc +++ b/test/dcp_subtitle_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2019 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/dcp_subtitle_test.cc * @brief Test DCP subtitle content in various ways. * @ingroup feature */ + #include #include "lib/film.h" #include "lib/dcp_subtitle_content.h" @@ -38,8 +40,10 @@ #include "test.h" #include + using std::cout; using std::list; +using std::make_shared; using std::shared_ptr; using std::vector; using boost::optional; @@ -48,8 +52,10 @@ using namespace boost::placeholders; #endif using namespace dcpomatic; + optional stored; + static void store (ContentStringText sub) { @@ -62,15 +68,16 @@ store (ContentStringText sub) } } + /** Test pass-through of a very simple DCP subtitle file */ BOOST_AUTO_TEST_CASE (dcp_subtitle_test) { - shared_ptr film = new_test_film ("dcp_subtitle_test"); + auto film = new_test_film ("dcp_subtitle_test"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (false); - shared_ptr content (new DCPSubtitleContent ("test/data/dcp_sub.xml")); + auto content = make_shared("test/data/dcp_sub.xml"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); @@ -78,20 +85,26 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test) content->only_text()->set_use (true); content->only_text()->set_burn (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); - - check_dcp ("test/data/dcp_subtitle_test", film->dir (film->dcp_name ())); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); + + check_dcp ("test/data/dcp_subtitle_test", film->dir(film->dcp_name())); } + /** Test parsing of a subtitle within an existing DCP */ BOOST_AUTO_TEST_CASE (dcp_subtitle_within_dcp_test) { - shared_ptr film = new_test_film ("dcp_subtitle_within_dcp_test"); + auto film = new_test_film ("dcp_subtitle_within_dcp_test"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content (new DCPContent(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV")); + auto content = make_shared(TestPaths::private_data() / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); @@ -110,15 +123,15 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_within_dcp_test) /** Test subtitles whose text includes things like <b> */ BOOST_AUTO_TEST_CASE (dcp_subtitle_test2) { - shared_ptr film = new_test_film ("dcp_subtitle_test2"); + auto film = new_test_film ("dcp_subtitle_test2"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); - shared_ptr content (new DCPSubtitleContent("test/data/dcp_sub2.xml")); + auto content = make_shared("test/data/dcp_sub2.xml"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - shared_ptr decoder (new DCPSubtitleDecoder(film, content)); + auto decoder = make_shared(film, content); decoder->only_text()->PlainStart.connect (bind (store, _1)); stored = optional (); @@ -129,28 +142,28 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test2) } } + /** Test a failure case */ BOOST_AUTO_TEST_CASE (dcp_subtitle_test3) { - shared_ptr film = new_test_film ("dcp_subtitle_test3"); + auto film = new_test_film ("dcp_subtitle_test3"); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); film->set_name ("frobozz"); film->set_interop (true); - shared_ptr content (new DCPSubtitleContent ("test/data/dcp_sub3.xml")); + auto content = make_shared("test/data/dcp_sub3.xml"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD }); - shared_ptr decoder (new DCPSubtitleDecoder (film, content)); + auto decoder = make_shared(film, content); stored = optional (); while (!decoder->pass ()) { decoder->only_text()->PlainStart.connect (bind (store, _1)); if (stored && stored->from() == ContentTime::from_seconds(0.08)) { - list s = stored->subs; - list::const_iterator i = s.begin (); + auto s = stored->subs; + auto i = s.begin (); BOOST_CHECK_EQUAL (i->text(), "This"); ++i; BOOST_REQUIRE (i != s.end ()); @@ -164,29 +177,26 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_test3) } } + /** Check that Interop DCPs aren't made with more than one (#1273) */ BOOST_AUTO_TEST_CASE (dcp_subtitle_test4) { - shared_ptr film = new_test_film2 ("dcp_subtitle_test4"); + auto content = make_shared("test/data/dcp_sub3.xml"); + auto content2 = make_shared("test/data/dcp_sub3.xml"); + auto film = new_test_film2 ("dcp_subtitle_test4", {content, content2}); film->set_interop (true); - shared_ptr content (new DCPSubtitleContent ("test/data/dcp_sub3.xml")); - film->examine_and_add_content (content); - shared_ptr content2 (new DCPSubtitleContent ("test/data/dcp_sub3.xml")); - film->examine_and_add_content (content2); - BOOST_REQUIRE (!wait_for_jobs ()); - content->only_text()->add_font (shared_ptr (new Font ("font1"))); content2->only_text()->add_font (shared_ptr (new Font ("font2"))); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD }); cxml::Document doc ("DCSubtitle"); doc.read_file (subtitle_file (film)); BOOST_REQUIRE_EQUAL (doc.node_children("LoadFont").size(), 1U); } + static void check_font_tags (vector nodes) @@ -199,21 +209,17 @@ check_font_tags (vector nodes) } } + /** Check that imported tags with empty IDs (or corresponding Font tags with empty IDs) * are not passed through into the DCP. */ BOOST_AUTO_TEST_CASE (dcp_subtitle_test5) { - shared_ptr film = new_test_film2 ("dcp_subtitle_test5"); + auto content = make_shared("test/data/dcp_sub6.xml"); + auto film = new_test_film2 ("dcp_subtitle_test5", {content}); film->set_interop (true); - shared_ptr content (new DCPSubtitleContent("test/data/dcp_sub6.xml")); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); - - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); - film->write_metadata (); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD }); cxml::Document doc ("DCSubtitle"); doc.read_file (subtitle_file(film)); diff --git a/test/ffmpeg_dcp_test.cc b/test/ffmpeg_dcp_test.cc index ea3b8d4f9..0d56f4290 100644 --- a/test/ffmpeg_dcp_test.cc +++ b/test/ffmpeg_dcp_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + /** @file test/ffmpeg_dcp_test.cc * @brief Test creation of a very simple DCP from some FFmpegContent (data/test.mp4). * @ingroup feature @@ -25,6 +26,7 @@ * Also a quick test of Film::have_dcp (). */ + #include #include #include @@ -35,35 +37,38 @@ #include "lib/video_content.h" #include "test.h" + +using std::make_shared; using std::shared_ptr; + BOOST_AUTO_TEST_CASE (ffmpeg_dcp_test) { - shared_ptr film = new_test_film ("ffmpeg_dcp_test"); + auto film = new_test_film ("ffmpeg_dcp_test"); film->set_name ("test_film2"); - shared_ptr c (new FFmpegContent("test/data/test.mp4")); + auto c = make_shared("test/data/test.mp4"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); - film->make_dcp (); - film->write_metadata (); + make_and_verify_dcp (film); BOOST_REQUIRE (!wait_for_jobs()); } -/** Briefly test Film::cpls(). Requires the output from ffmpeg_dcp_test above */ + +/** Briefly test Film::cpls() */ BOOST_AUTO_TEST_CASE (ffmpeg_have_dcp_test, * boost::unit_test::depends_on("ffmpeg_dcp_test")) { - boost::filesystem::path p = test_film_dir ("ffmpeg_dcp_test"); - shared_ptr film (new Film (p)); + auto p = test_film_dir ("ffmpeg_dcp_test"); + auto film = make_shared(p); film->read_metadata (); BOOST_CHECK (!film->cpls().empty()); p /= film->dcp_name(); - boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (p); + auto i = boost::filesystem::directory_iterator (p); while (i != boost::filesystem::directory_iterator() && !boost::algorithm::starts_with (i->path().leaf().string(), "j2c")) { ++i; } diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index aab3fd8ef..4654723b0 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -63,14 +63,11 @@ ffmpeg_content_test (int number, boost::filesystem::path content, ExportFormat f name = String::compose("%1_test%2", name, number); - shared_ptr film = new_test_film2 (name, &cl); - film->set_name (name); auto c = make_shared(content); + shared_ptr film = new_test_film2 (name, {c}, &cl); + film->set_name (name); film->set_audio_channels (6); - film->examine_and_add_content (c); - BOOST_REQUIRE (!wait_for_jobs ()); - film->write_metadata (); auto job = make_shared(film); auto file = boost::filesystem::path("build") / "test" / String::compose("%1.%2", name, extension); diff --git a/test/image_content_fade_test.cc b/test/image_content_fade_test.cc index 61f1c4848..1fcf98443 100644 --- a/test/image_content_fade_test.cc +++ b/test/image_content_fade_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington + Copyright (C) 2019-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,27 +18,29 @@ */ -#include "test.h" -#include "lib/film.h" -#include "lib/content_factory.h" + #include "lib/content.h" +#include "lib/content_factory.h" +#include "lib/film.h" #include "lib/video_content.h" +#include "test.h" #include + using std::string; using std::list; using std::shared_ptr; + BOOST_AUTO_TEST_CASE (image_content_fade_test) { - shared_ptr film = new_test_film2 ("image_content_fade_test"); - shared_ptr content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("image_content_fade_test"); + auto content = content_factory("test/data/flat_red.png").front(); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); content->video->set_fade_in (1); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); check_dcp ("test/data/image_content_fade_test", film->dir(film->dcp_name())); } diff --git a/test/import_dcp_test.cc b/test/import_dcp_test.cc index 44f3c7d44..54cea296b 100644 --- a/test/import_dcp_test.cc +++ b/test/import_dcp_test.cc @@ -111,10 +111,8 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test) Cleanup cl; /* Make a DCP with some markers */ - auto film = new_test_film2 ("import_dcp_markers_test", &cl); auto content = content_factory("test/data/flat_red.png").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 ("import_dcp_markers_test", {content}, &cl); content->video->set_length (24 * 60 * 10); @@ -126,10 +124,8 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test) BOOST_REQUIRE (!wait_for_jobs()); /* Import the DCP to a new film and check the markers */ - auto film2 = new_test_film2 ("import_dcp_markers_test2", &cl); auto imported = make_shared(film->dir(film->dcp_name())); - film2->examine_and_add_content (imported); - BOOST_REQUIRE (!wait_for_jobs()); + auto film2 = new_test_film2 ("import_dcp_markers_test2", {imported}, &cl); film2->write_metadata (); /* When import_dcp_markers_test was made a LFOC marker will automatically @@ -149,7 +145,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test) auto film3 = make_shared(boost::filesystem::path("build/test/import_dcp_markers_test2")); film3->read_metadata (); BOOST_REQUIRE_EQUAL (film3->content().size(), 1U); - shared_ptr reloaded = dynamic_pointer_cast(film3->content().front()); + auto reloaded = dynamic_pointer_cast(film3->content().front()); BOOST_REQUIRE (reloaded); BOOST_CHECK_EQUAL (reloaded->markers().size(), 4U); diff --git a/test/kdm_naming_test.cc b/test/kdm_naming_test.cc index fb0f37dcf..c58de3471 100644 --- a/test/kdm_naming_test.cc +++ b/test/kdm_naming_test.cc @@ -79,10 +79,8 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) 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()); @@ -93,8 +91,8 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) string const from_string = from.date() + " " + from.time_of_day(true, false); string 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, @@ -105,11 +103,8 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test) 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 @@ -133,15 +128,15 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( /* 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,18 +147,16 @@ 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; for (auto i: screens) { - KDMWithMetadataPtr kdm = kdm_for_screen ( + auto kdm = kdm_for_screen ( film, cpls.front().cpl_file, i, @@ -190,9 +183,9 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on( &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"; diff --git a/test/no_use_video_test.cc b/test/no_use_video_test.cc index e64a21621..3c21675c7 100644 --- a/test/no_use_video_test.cc +++ b/test/no_use_video_test.cc @@ -62,8 +62,7 @@ BOOST_AUTO_TEST_CASE (no_use_video_test1) B->set_position (film, dcpomatic::DCPTime()); A->video->set_use (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); check_dcp ("test/data/no_use_video_test1", film); } @@ -83,8 +82,7 @@ BOOST_AUTO_TEST_CASE (no_use_video_test2) B->set_position (film, dcpomatic::DCPTime()); A->video->set_use (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); check_dcp (TestPaths::private_data() / "no_use_video_test2", film); } @@ -101,8 +99,7 @@ BOOST_AUTO_TEST_CASE (no_use_video_test3) ov_a->examine_and_add_content (ov_a_pic); ov_a->examine_and_add_content (ov_a_snd); BOOST_REQUIRE (!wait_for_jobs()); - ov_a->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov_a); auto ov_b = new_test_film2("no_use_video_test3_ov_b"); auto ov_b_pic = content_factory("test/data/flat_green.png").front(); @@ -112,8 +109,7 @@ BOOST_AUTO_TEST_CASE (no_use_video_test3) ov_b->examine_and_add_content (ov_b_pic); ov_b->examine_and_add_content (ov_b_snd); BOOST_REQUIRE (!wait_for_jobs()); - ov_b->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov_b); auto vf = new_test_film2 ("no_use_video_test3_vf"); auto A = make_shared(ov_a->dir(ov_a->dcp_name())); @@ -132,8 +128,7 @@ BOOST_AUTO_TEST_CASE (no_use_video_test3) A->set_reference_audio (true); B->set_reference_video (true); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); dcp::DCP ov_a_check (ov_a->dir(ov_a->dcp_name())); ov_a_check.read (); diff --git a/test/recover_test.cc b/test/recover_test.cc index bdbd6f273..164bf2322 100644 --- a/test/recover_test.cc +++ b/test/recover_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/recover_test.cc * @brief Test recovery of a DCP transcode after a crash. * @ingroup feature */ + #include "test.h" #include "lib/film.h" #include "lib/dcp_content_type.h" @@ -35,6 +37,7 @@ #include #include + using std::cout; using std::make_shared; using std::shared_ptr; @@ -43,6 +46,7 @@ using std::string; using namespace boost::placeholders; #endif + static void note (dcp::NoteType t, string n) { @@ -51,6 +55,7 @@ note (dcp::NoteType t, string n) } } + BOOST_AUTO_TEST_CASE (recover_test_2d) { shared_ptr film = new_test_film ("recover_test_2d"); @@ -74,8 +79,7 @@ BOOST_AUTO_TEST_CASE (recover_test_2d) boost::filesystem::resize_file (video, 2 * 1024 * 1024); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE }); shared_ptr A (new dcp::MonoPictureAsset ("build/test/recover_test_2d/original.mxf")); shared_ptr B (new dcp::MonoPictureAsset (video)); @@ -84,6 +88,7 @@ BOOST_AUTO_TEST_CASE (recover_test_2d) BOOST_CHECK (A->equals (B, eq, boost::bind (¬e, _1, _2))); } + BOOST_AUTO_TEST_CASE (recover_test_3d, * boost::unit_test::depends_on("recover_test_2d")) { auto film = new_test_film ("recover_test_3d"); @@ -98,8 +103,7 @@ BOOST_AUTO_TEST_CASE (recover_test_3d, * boost::unit_test::depends_on("recover_t film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE }); boost::filesystem::path const video = "build/test/recover_test_3d/video/185_2K_70e6661af92ae94458784c16a21a9748_24_100000000_P_S_3D_0_96000.mxf"; @@ -110,8 +114,7 @@ BOOST_AUTO_TEST_CASE (recover_test_3d, * boost::unit_test::depends_on("recover_t boost::filesystem::resize_file (video, 2 * 1024 * 1024); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE }); auto A = make_shared("build/test/recover_test_3d/original.mxf"); auto B = make_shared(video); @@ -135,8 +138,7 @@ BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted, * boost::unit_test::depends_on( film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE }); boost::filesystem::path const video = "build/test/recover_test_2d_encrypted/video/185_2K_02543352c540f4b083bff3f1e309d4a9_24_100000000_Eeafcb91c9f5472edf01f3a2404c57258_S_0_1200000.mxf"; @@ -148,8 +150,7 @@ BOOST_AUTO_TEST_CASE (recover_test_2d_encrypted, * boost::unit_test::depends_on( boost::filesystem::resize_file (video, 2 * 1024 * 1024); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE }); auto A = make_shared("build/test/recover_test_2d_encrypted/original.mxf"); A->set_key (film->key ()); diff --git a/test/reel_writer_test.cc b/test/reel_writer_test.cc index 9e567fb2a..6fa571500 100644 --- a/test/reel_writer_test.cc +++ b/test/reel_writer_test.cc @@ -110,8 +110,7 @@ BOOST_AUTO_TEST_CASE (reel_reuse_video_test) auto audio = content_factory("test/data/white.wav").front(); film->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); /* Find main picture and sound asset IDs */ dcp::DCP dcp1 (film->dir(film->dcp_name())); @@ -125,8 +124,7 @@ BOOST_AUTO_TEST_CASE (reel_reuse_video_test) /* Change the audio and re-make */ audio->audio->set_gain (-3); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); /* Video ID should be the same, sound different */ dcp::DCP dcp2 (film->dir(film->dcp_name())); @@ -140,8 +138,7 @@ BOOST_AUTO_TEST_CASE (reel_reuse_video_test) /* Crop video and re-make */ video->video->set_left_crop (5); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); /* Video and sound IDs should be different */ dcp::DCP dcp3 (film->dir(film->dcp_name())); diff --git a/test/reels_test.cc b/test/reels_test.cc index 402005339..47ead7e12 100644 --- a/test/reels_test.cc +++ b/test/reels_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2020 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/reels_test.cc * @brief Check manipulation of reels in various ways. * @ingroup feature */ + #include "lib/film.h" #include "lib/ratio.h" #include "lib/ffmpeg_content.h" @@ -36,6 +38,7 @@ #include #include + using std::list; using std::cout; using std::vector; @@ -45,6 +48,7 @@ using std::make_shared; using boost::function; using namespace dcpomatic; + /** Test Film::reels() */ BOOST_AUTO_TEST_CASE (reels_test1) { @@ -88,6 +92,7 @@ BOOST_AUTO_TEST_CASE (reels_test1) BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_frames(144, 24).get()); } + /** Make a short DCP with multi reels split by video content, then import * this into a new project and make a new DCP referencing it. */ @@ -124,20 +129,13 @@ BOOST_AUTO_TEST_CASE (reels_test2) BOOST_CHECK_EQUAL (film->reels().size(), 3U); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); check_dcp ("test/data/reels_test2", film->dir (film->dcp_name())); - shared_ptr film2 = new_test_film ("reels_test2b"); - film2->set_name ("reels_test2b"); - film2->set_container (Ratio::from_id ("185")); - film2->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); - film2->set_reel_type (ReelType::BY_VIDEO_CONTENT); - auto c = make_shared(film->dir(film->dcp_name())); - film2->examine_and_add_content (c); - BOOST_REQUIRE (!wait_for_jobs ()); + auto film2 = new_test_film2 ("reels_test2b", {c}); + film2->set_reel_type (ReelType::BY_VIDEO_CONTENT); auto r = film2->reels (); BOOST_CHECK_EQUAL (r.size(), 3U); @@ -154,26 +152,19 @@ BOOST_AUTO_TEST_CASE (reels_test2) c->set_reference_video (true); c->set_reference_audio (true); - film2->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film2, {dcp::VerificationNote::Code::EXTERNAL_ASSET}); } + /** Check that ReelType::BY_VIDEO_CONTENT adds an extra reel, if necessary, at the end * of all the video content to mop up anything afterward. */ BOOST_AUTO_TEST_CASE (reels_test3) { - auto film = new_test_film ("reels_test3"); - film->set_name ("reels_test3"); - film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); - film->set_reel_type (ReelType::BY_VIDEO_CONTENT); - auto dcp = make_shared("test/data/reels_test2"); - film->examine_and_add_content (dcp); auto sub = make_shared("test/data/subrip.srt"); - film->examine_and_add_content (sub); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 ("reels_test3", {dcp, sub}); + film->set_reel_type (ReelType::BY_VIDEO_CONTENT); auto reels = film->reels(); BOOST_REQUIRE_EQUAL (reels.size(), 4U); @@ -191,15 +182,13 @@ BOOST_AUTO_TEST_CASE (reels_test3) BOOST_CHECK_EQUAL (i->to.get(), sub->full_length(film).ceil(film->video_frame_rate()).get()); } + /** Check creation of a multi-reel DCP with a single .srt subtitle file; * make sure that the reel subtitle timing is done right. */ BOOST_AUTO_TEST_CASE (reels_test4) { - auto film = new_test_film ("reels_test4"); - film->set_name ("reels_test4"); - film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); + auto film = new_test_film2 ("reels_test4"); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); film->set_interop (false); @@ -212,7 +201,7 @@ BOOST_AUTO_TEST_CASE (reels_test4) content[i]->video->set_length (24); } - shared_ptr subs (new StringTextFileContent("test/data/subrip3.srt")); + auto subs = make_shared("test/data/subrip3.srt"); film->examine_and_add_content (subs); BOOST_REQUIRE (!wait_for_jobs()); @@ -231,19 +220,23 @@ BOOST_AUTO_TEST_CASE (reels_test4) BOOST_CHECK_EQUAL (i->from.get(), 96000 * 3); BOOST_CHECK_EQUAL (i->to.get(), 96000 * 4); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION + }); check_dcp ("test/data/reels_test4", film->dir (film->dcp_name())); } + BOOST_AUTO_TEST_CASE (reels_test5) { - auto film = new_test_film ("reels_test5"); + auto dcp = make_shared("test/data/reels_test4"); + auto film = new_test_film2 ("reels_test5", {dcp}); film->set_sequence (false); - shared_ptr dcp (new DCPContent("test/data/reels_test4")); - film->examine_and_add_content (dcp); - BOOST_REQUIRE (!wait_for_jobs ()); /* Set to 2123 but it will be rounded up to the next frame (4000) */ dcp->set_position(film, DCPTime(2123)); @@ -291,40 +284,34 @@ BOOST_AUTO_TEST_CASE (reels_test5) } } + /** Check reel split with a muxed video/audio source */ BOOST_AUTO_TEST_CASE (reels_test6) { - auto film = new_test_film ("reels_test6"); - film->set_name ("reels_test6"); - film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); - shared_ptr A (new FFmpegContent("test/data/test2.mp4")); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs ()); + auto A = make_shared("test/data/test2.mp4"); + auto film = new_test_film2 ("reels_test6", {A}); film->set_j2k_bandwidth (100000000); film->set_reel_type (ReelType::BY_LENGTH); /* This is just over 2.5s at 100Mbit/s; should correspond to 60 frames */ film->set_reel_length (31253154); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::INVALID_INTRINSIC_DURATION, + dcp::VerificationNote::Code::INVALID_DURATION, + }); } + /** Check the case where the last bit of audio hangs over the end of the video * and we are using ReelType::BY_VIDEO_CONTENT. */ BOOST_AUTO_TEST_CASE (reels_test7) { - auto film = new_test_film ("reels_test7"); - film->set_name ("reels_test7"); - film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); auto A = content_factory("test/data/flat_red.png").front(); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs ()); auto B = content_factory("test/data/awkward_length.wav").front(); - film->examine_and_add_content (B); - BOOST_REQUIRE (!wait_for_jobs ()); + auto film = new_test_film2 ("reels_test7", { A, B }); film->set_video_frame_rate (24); A->video->set_length (2 * 24); @@ -333,51 +320,45 @@ BOOST_AUTO_TEST_CASE (reels_test7) BOOST_CHECK (film->reels().front() == DCPTimePeriod(DCPTime(0), DCPTime::from_frames(2 * 24, 24))); BOOST_CHECK (film->reels().back() == DCPTimePeriod(DCPTime::from_frames(2 * 24, 24), DCPTime::from_frames(3 * 24 + 1, 24))); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); } + /** Check a reels-related error; make_dcp() would raise a ProgrammingError */ BOOST_AUTO_TEST_CASE (reels_test8) { - shared_ptr film = new_test_film ("reels_test8"); - film->set_name ("reels_test8"); - film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); auto A = make_shared("test/data/test2.mp4"); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs ()); + auto film = new_test_film2 ("reels_test8", {A}); A->set_trim_end (ContentTime::from_seconds (1)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + make_and_verify_dcp (film); } + /** Check another reels-related error; make_dcp() would raise a ProgrammingError */ BOOST_AUTO_TEST_CASE (reels_test9) { - shared_ptr film = new_test_film2("reels_test9a"); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content(A); - BOOST_REQUIRE(!wait_for_jobs()); + auto A = make_shared("test/data/flat_red.png"); + auto film = new_test_film2("reels_test9a", {A}); A->video->set_length(5 * 24); film->set_video_frame_rate(24); - film->make_dcp(); - BOOST_REQUIRE(!wait_for_jobs()); + make_and_verify_dcp (film); - shared_ptr film2 = new_test_film2("reels_test9b"); - shared_ptr B(new DCPContent(film->dir(film->dcp_name()))); - film2->examine_and_add_content(B); - film2->examine_and_add_content(content_factory("test/data/dcp_sub4.xml").front()); + auto B = make_shared(film->dir(film->dcp_name())); + auto film2 = new_test_film2("reels_test9b", {B, content_factory("test/data/dcp_sub4.xml").front()}); B->set_reference_video(true); B->set_reference_audio(true); - BOOST_REQUIRE(!wait_for_jobs()); film2->set_reel_type(ReelType::BY_VIDEO_CONTENT); film2->write_metadata(); - film2->make_dcp(); - BOOST_REQUIRE(!wait_for_jobs()); + make_and_verify_dcp ( + film2, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME + }); } + /** Another reels-related error; make_dcp() would raise a ProgrammingError * in AudioBuffers::allocate due to an attempt to allocate a negatively-sized buffer. * This was triggered by a VF where there are referenced audio reels followed by @@ -387,58 +368,50 @@ BOOST_AUTO_TEST_CASE (reels_test9) BOOST_AUTO_TEST_CASE (reels_test10) { /* Make the OV */ - shared_ptr ov = new_test_film2("reels_test10_ov"); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - ov->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs()); + auto A = make_shared("test/data/flat_red.png"); + auto B = make_shared("test/data/flat_red.png"); + auto ov = new_test_film2("reels_test10_ov", {A, B}); A->video->set_length (5 * 24); - - shared_ptr B(new FFmpegContent("test/data/flat_red.png")); - ov->examine_and_add_content (B); - BOOST_REQUIRE (!wait_for_jobs()); B->video->set_length (5 * 24); ov->set_reel_type (ReelType::BY_VIDEO_CONTENT); - ov->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (ov); ov->write_metadata (); /* Now try to make the VF; this used to fail */ - shared_ptr vf = new_test_film2("reels_test10_vf"); - shared_ptr ov_dcp(new DCPContent(ov->dir(ov->dcp_name()))); - vf->examine_and_add_content (ov_dcp); - BOOST_REQUIRE (!wait_for_jobs()); + auto ov_dcp = make_shared(ov->dir(ov->dcp_name())); + auto vf = new_test_film2("reels_test10_vf", {ov_dcp, content_factory("test/data/15s.srt").front()}); vf->set_reel_type (ReelType::BY_VIDEO_CONTENT); ov_dcp->set_reference_video (true); ov_dcp->set_reference_audio (true); - vf->examine_and_add_content (content_factory("test/data/15s.srt").front()); - BOOST_REQUIRE (!wait_for_jobs()); - vf->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); - vf->write_metadata (); + make_and_verify_dcp ( + vf, + { + dcp::VerificationNote::Code::EXTERNAL_ASSET, + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME + }); } + /** Another reels error; ReelType::BY_VIDEO_CONTENT when the first content is not * at time 0. */ BOOST_AUTO_TEST_CASE (reels_test11) { - shared_ptr film = new_test_film2 ("reels_test11"); + auto A = make_shared("test/data/flat_red.png"); + auto film = new_test_film2 ("reels_test11", {A}); film->set_video_frame_rate (24); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs()); A->video->set_length (240); A->set_video_frame_rate (24); A->set_position (film, DCPTime::from_seconds(1)); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); BOOST_CHECK_EQUAL (A->position().get(), DCPTime::from_seconds(1).get()); BOOST_CHECK_EQUAL (A->end(film).get(), DCPTime::from_seconds(1 + 10).get()); - list r = film->reels (); + auto r = film->reels (); BOOST_CHECK_EQUAL (r.size(), 2U); BOOST_CHECK_EQUAL (r.front().from.get(), 0); BOOST_CHECK_EQUAL (r.front().to.get(), DCPTime::from_seconds(1).get()); @@ -446,33 +419,30 @@ BOOST_AUTO_TEST_CASE (reels_test11) BOOST_CHECK_EQUAL (r.back().to.get(), DCPTime::from_seconds(1 + 10).get()); } + /** For VFs to work right we have to make separate reels for empty bits between * video content. */ BOOST_AUTO_TEST_CASE (reels_test12) { - shared_ptr film = new_test_film2 ("reels_test12"); + auto A = make_shared("test/data/flat_red.png"); + auto B = make_shared("test/data/flat_red.png"); + auto film = new_test_film2 ("reels_test12", {A, B}); film->set_video_frame_rate (24); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); film->set_sequence (false); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs()); A->video->set_length (240); A->set_video_frame_rate (24); A->set_position (film, DCPTime::from_seconds(1)); - shared_ptr B(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (B); - BOOST_REQUIRE (!wait_for_jobs()); B->video->set_length (120); B->set_video_frame_rate (24); B->set_position (film, DCPTime::from_seconds(14)); - list r = film->reels (); + auto r = film->reels (); BOOST_REQUIRE_EQUAL (r.size(), 4U); - list::const_iterator i = r.begin (); + auto i = r.begin (); BOOST_CHECK_EQUAL (i->from.get(), 0); BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_seconds(1).get()); @@ -487,6 +457,7 @@ BOOST_AUTO_TEST_CASE (reels_test12) BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_seconds(19).get()); } + static void no_op () { @@ -507,109 +478,95 @@ dump_notes (vector const & notes) */ BOOST_AUTO_TEST_CASE (reels_should_not_be_short1) { - shared_ptr film = new_test_film2 ("reels_should_not_be_short1"); + auto A = make_shared("test/data/flat_red.png"); + auto B = make_shared("test/data/flat_red.png"); + auto film = new_test_film2 ("reels_should_not_be_short1", {A, B}); film->set_video_frame_rate (24); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs()); A->video->set_length (23); - shared_ptr B(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (B); - BOOST_REQUIRE (!wait_for_jobs()); B->video->set_length (23); B->set_position (film, DCPTime::from_frames(23, 24)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); - vector dirs; - dirs.push_back (film->dir(film->dcp_name(false))); + vector dirs = { film->dir(film->dcp_name(false)) }; auto notes = dcp::verify(dirs, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd()); dump_notes (notes); BOOST_REQUIRE (notes.empty()); } + /** Leaving less than 1 second's gap between two pieces of content with * ReelType::BY_VIDEO_CONTENT should not make a <1s reel. */ BOOST_AUTO_TEST_CASE (reels_should_not_be_short2) { - shared_ptr film = new_test_film2 ("reels_should_not_be_short2"); + auto A = make_shared("test/data/flat_red.png"); + auto B = make_shared("test/data/flat_red.png"); + auto film = new_test_film2 ("reels_should_not_be_short2", {A, B}); film->set_video_frame_rate (24); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs()); A->video->set_length (240); - shared_ptr B(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (B); - BOOST_REQUIRE (!wait_for_jobs()); B->video->set_length (240); B->set_position (film, DCPTime::from_seconds(10.2)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); - vector dirs; - dirs.push_back (film->dir(film->dcp_name(false))); + vector dirs = { film->dir(film->dcp_name(false)) }; auto const notes = dcp::verify(dirs, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd()); dump_notes (notes); BOOST_REQUIRE (notes.empty()); } + /** Setting ReelType::BY_LENGTH and using a small length value should not make * <1s reels. */ BOOST_AUTO_TEST_CASE (reels_should_not_be_short3) { - shared_ptr film = new_test_film2 ("reels_should_not_be_short3"); + auto A = make_shared("test/data/flat_red.png"); + auto film = new_test_film2 ("reels_should_not_be_short3", {A}); film->set_video_frame_rate (24); film->set_reel_type (ReelType::BY_LENGTH); film->set_reel_length (1024 * 1024 * 10); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs()); A->video->set_length (240); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); - vector dirs; - auto const notes = dcp::verify(dirs, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd()); + auto const notes = dcp::verify({}, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd()); dump_notes (notes); BOOST_REQUIRE (notes.empty()); } + /** Having one piece of content less than 1s long in ReelType::BY_VIDEO_CONTENT * should not make a reel less than 1s long. */ BOOST_AUTO_TEST_CASE (reels_should_not_be_short4) { - shared_ptr film = new_test_film2 ("reels_should_not_be_short4"); + auto A = make_shared("test/data/flat_red.png"); + auto B = make_shared("test/data/flat_red.png"); + auto film = new_test_film2 ("reels_should_not_be_short4", {A, B}); film->set_video_frame_rate (24); film->set_reel_type (ReelType::BY_VIDEO_CONTENT); - shared_ptr A(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (A); - BOOST_REQUIRE (!wait_for_jobs()); A->video->set_length (240); - shared_ptr B(new FFmpegContent("test/data/flat_red.png")); - film->examine_and_add_content (B); - BOOST_REQUIRE (!wait_for_jobs()); B->video->set_length (23); B->set_position (film, DCPTime::from_frames(240, 24)); + BOOST_CHECK_EQUAL (film->reels().size(), 1U); + BOOST_CHECK (film->reels().front() == dcpomatic::DCPTimePeriod(dcpomatic::DCPTime(), dcpomatic::DCPTime::from_frames(263, 24))); + + film->write_metadata (); film->make_dcp (); BOOST_REQUIRE (!wait_for_jobs()); - vector dirs; - dirs.push_back (film->dir(film->dcp_name(false))); + vector dirs = { film->dir(film->dcp_name(false)) }; auto const notes = dcp::verify(dirs, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd()); dump_notes (notes); BOOST_REQUIRE (notes.empty()); diff --git a/test/repeat_frame_test.cc b/test/repeat_frame_test.cc index fbbaba3f1..b43312e59 100644 --- a/test/repeat_frame_test.cc +++ b/test/repeat_frame_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2016 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + /** @file test/repeat_frame_test.cc * @brief Test the repeat of frames by the player when putting a 24fps * source into a 48fps DCP. @@ -26,6 +27,7 @@ * @see test/skip_frame_test.cc */ + #include #include "test.h" #include "lib/film.h" @@ -34,23 +36,20 @@ #include "lib/dcp_content_type.h" #include "lib/video_content.h" + +using std::make_shared; using std::shared_ptr; + BOOST_AUTO_TEST_CASE (repeat_frame_test) { - shared_ptr film = new_test_film ("repeat_frame_test"); - film->set_name ("repeat_frame_test"); - film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); + auto c = make_shared("test/data/red_24.mp4"); + auto film = new_test_film2 ("repeat_frame_test", {c}); film->set_interop (false); - shared_ptr c (new FFmpegContent("test/data/red_24.mp4")); - film->examine_and_add_content (c); - BOOST_REQUIRE (!wait_for_jobs()); c->video->set_custom_ratio (1.85); film->set_video_frame_rate (48); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); /* Should be 32 frames of red followed by 16 frames of black to fill the DCP up to 1 second */ check_dcp ("test/data/repeat_frame_test", film->dir (film->dcp_name ())); diff --git a/test/silence_padding_test.cc b/test/silence_padding_test.cc index d3382f30a..328f9bef7 100644 --- a/test/silence_padding_test.cc +++ b/test/silence_padding_test.cc @@ -46,18 +46,15 @@ static void test_silence_padding (int channels) { string const film_name = "silence_padding_test_" + lexical_cast (channels); - auto film = new_test_film (film_name); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); - film->set_container (Ratio::from_id ("185")); - film->set_name (film_name); - - auto content = make_shared("test/data/staircase.wav"); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 ( + film_name, + { + make_shared("test/data/flat_red.png"), + make_shared("test/data/staircase.wav") + }); film->set_audio_channels (channels); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); boost::filesystem::path path = "build/test"; path /= film_name; @@ -138,16 +135,13 @@ BOOST_AUTO_TEST_CASE (silence_padding_test2) { Cleanup cl; - auto film = new_test_film2 ("silence_padding_test2", &cl); auto content = make_shared(TestPaths::private_data() / "cars.mov"); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 ("silence_padding_test2", { content }, &cl); film->set_video_frame_rate (24); content->set_trim_start (dcpomatic::ContentTime(4003)); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); cl.run (); } diff --git a/test/srt_subtitle_test.cc b/test/srt_subtitle_test.cc index 3fe9bc2d2..1d8fb89da 100644 --- a/test/srt_subtitle_test.cc +++ b/test/srt_subtitle_test.cc @@ -100,21 +100,17 @@ BOOST_AUTO_TEST_CASE (srt_subtitle_test3) { Cleanup cl; - shared_ptr film = new_test_film2 ("srt_subtitle_test3", &cl); + shared_ptr content (new StringTextFileContent(TestPaths::private_data() / "Ankoemmling_short.srt")); + shared_ptr film = new_test_film2 ("srt_subtitle_test3", { content }, &cl); - film->set_container (Ratio::from_id ("185")); film->set_name ("frobozz"); film->set_interop (true); film->set_audio_channels (6); - shared_ptr content (new StringTextFileContent(TestPaths::private_data() / "Ankoemmling_short.srt")); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs()); content->only_text()->set_use (true); content->only_text()->set_burn (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD}); check_subtitle_file (film, TestPaths::private_data() / "Ankoemmling_short.xml"); diff --git a/test/ssa_subtitle_test.cc b/test/ssa_subtitle_test.cc index c7e4c39a6..5c2e61b7e 100644 --- a/test/ssa_subtitle_test.cc +++ b/test/ssa_subtitle_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/ssa_subtitle_test.cc * @brief Test use of SSA subtitle files. * @ingroup feature */ + #include "lib/film.h" #include "lib/string_text_file_content.h" #include "lib/dcp_content_type.h" @@ -32,36 +34,35 @@ #include "test.h" #include #include -#include + using std::string; using std::list; using std::shared_ptr; +using std::make_shared; + /** Make a DCP with subs from a .ssa file */ BOOST_AUTO_TEST_CASE (ssa_subtitle_test1) { Cleanup cl; - shared_ptr film = new_test_film2 ("ssa_subtitle_test1", &cl); + auto film = new_test_film2 ("ssa_subtitle_test1", {}, &cl); film->set_container (Ratio::from_id ("185")); film->set_name ("frobozz"); film->set_interop (true); - shared_ptr content (new StringTextFileContent(TestPaths::private_data() / "DKH_UT_EN20160601def.ssa")); + auto content = make_shared(TestPaths::private_data() / "DKH_UT_EN20160601def.ssa"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); content->only_text()->set_use (true); content->only_text()->set_burn (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD }); /* Find the subtitle file and check it */ - list ignore; - ignore.push_back ("SubtitleID"); - check_xml (subtitle_file(film), TestPaths::private_data() / "DKH_UT_EN20160601def.xml", ignore); + check_xml (subtitle_file(film), TestPaths::private_data() / "DKH_UT_EN20160601def.xml", {"SubtitleID"}); cl.run (); } diff --git a/test/subtitle_language_test.cc b/test/subtitle_language_test.cc index 28c278c94..f43a3721c 100644 --- a/test/subtitle_language_test.cc +++ b/test/subtitle_language_test.cc @@ -39,18 +39,15 @@ using std::shared_ptr; BOOST_AUTO_TEST_CASE (subtitle_language_interop_test) { string const name = "subtitle_language_interop_test"; - shared_ptr film = new_test_film2 (name); - film->examine_and_add_content (content_factory("test/data/frames.srt").front()); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 (name, { content_factory("test/data/frames.srt").front() }); - vector langs; - langs.push_back(dcp::LanguageTag("fr-FR")); - langs.push_back(dcp::LanguageTag("de-DE")); + vector langs = { + dcp::LanguageTag("fr-FR"), dcp::LanguageTag("de-DE") + }; film->set_subtitle_languages(langs); film->set_interop (true); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD}); check_dcp (String::compose("test/data/%1", name), String::compose("build/test/%1/%2", name, film->dcp_name())); } @@ -59,18 +56,23 @@ BOOST_AUTO_TEST_CASE (subtitle_language_interop_test) BOOST_AUTO_TEST_CASE (subtitle_language_smpte_test) { string const name = "subtitle_language_smpte_test"; - shared_ptr film = new_test_film2 (name); - film->examine_and_add_content (content_factory("test/data/frames.srt").front()); - BOOST_REQUIRE (!wait_for_jobs()); + auto film = new_test_film2 (name, { content_factory("test/data/frames.srt").front() }); - vector langs; - langs.push_back(dcp::LanguageTag("fr-FR")); - langs.push_back(dcp::LanguageTag("de-DE")); - film->set_subtitle_languages(langs); + vector langs = { + dcp::LanguageTag("fr-FR"), dcp::LanguageTag("de-DE") + }; + film->set_subtitle_languages (langs); film->set_interop (false); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION, + dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING, + dcp::VerificationNote::Code::MISSING_CPL_METADATA + }); check_dcp (String::compose("test/data/%1", name), String::compose("build/test/%1/%2", name, film->dcp_name())); } diff --git a/test/test.cc b/test/test.cc index 292b4e1d9..eba0fc490 100644 --- a/test/test.cc +++ b/test/test.cc @@ -176,7 +176,7 @@ new_test_film (string name) } shared_ptr -new_test_film2 (string name, Cleanup* cleanup) +new_test_film2 (string name, vector> content, Cleanup* cleanup) { auto p = test_film_dir (name); if (boost::filesystem::exists (p)) { @@ -190,6 +190,12 @@ new_test_film2 (string name, Cleanup* cleanup) film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST")); film->set_container (Ratio::from_id ("185")); film->write_metadata (); + + for (auto i: content) { + film->examine_and_add_content (i); + BOOST_REQUIRE (!wait_for_jobs()); + } + return film; } @@ -830,3 +836,26 @@ Cleanup::run () boost::filesystem::remove_all (i, ec); } } + + +void stage (string, boost::optional) {} +void progress (float) {} + + +void +make_and_verify_dcp (shared_ptr film, vector ignore) +{ + film->write_metadata (); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + auto notes = dcp::verify ({film->dir(film->dcp_name())}, &stage, &progress, TestPaths::xsd()); + bool ok = true; + for (auto i: notes) { + if (find(ignore.begin(), ignore.end(), i.code()) == ignore.end()) { + std::cout << "\t" << dcp::note_to_string(i) << "\n"; + ok = false; + } + } + BOOST_CHECK(ok); +} + diff --git a/test/test.h b/test/test.h index 5a2246894..a4b6bedd1 100644 --- a/test/test.h +++ b/test/test.h @@ -21,7 +21,9 @@ #include "lib/warnings.h" #include "lib/types.h" +#include #include +#include class Film; @@ -56,7 +58,7 @@ private: extern bool wait_for_jobs (); extern void setup_test_config (); extern std::shared_ptr new_test_film (std::string); -extern std::shared_ptr new_test_film2 (std::string, Cleanup* cleanup = nullptr); +extern std::shared_ptr new_test_film2 (std::string, std::vector> content = {}, Cleanup* cleanup = nullptr); extern void check_dcp (boost::filesystem::path, boost::filesystem::path); extern void check_dcp (boost::filesystem::path, std::shared_ptr); extern void check_file (boost::filesystem::path ref, boost::filesystem::path check); @@ -73,6 +75,7 @@ boost::filesystem::path dcp_file (std::shared_ptr film, std::string void check_one_frame (boost::filesystem::path dcp, int64_t index, boost::filesystem::path ref); extern boost::filesystem::path subtitle_file (std::shared_ptr film); extern void make_random_file (boost::filesystem::path path, size_t size); +extern void make_and_verify_dcp (std::shared_ptr film, std::vector ignore = {}); class LogSwitcher diff --git a/test/torture_test.cc b/test/torture_test.cc index 434ed0b5e..6b8cbffbf 100644 --- a/test/torture_test.cc +++ b/test/torture_test.cc @@ -50,18 +50,15 @@ using namespace dcpomatic; /** Test start/end trim and positioning of some audio content */ BOOST_AUTO_TEST_CASE (torture_test1) { - shared_ptr film = new_test_film ("torture_test1"); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); - film->set_name ("torture_test1"); - film->set_container (Ratio::from_id ("185")); + auto film = new_test_film2 ("torture_test1"); film->set_sequence (false); /* Staircase at an offset of 2000 samples, trimmed both start and end, with a gain of exactly 2 (linear) */ - shared_ptr staircase = content_factory("test/data/staircase.wav").front (); + auto staircase = content_factory("test/data/staircase.wav").front(); film->examine_and_add_content (staircase); BOOST_REQUIRE (!wait_for_jobs()); - staircase->set_position (film, DCPTime::from_frames (2000, film->audio_frame_rate())); - staircase->set_trim_start (ContentTime::from_frames (12, 48000)); + staircase->set_position (film, DCPTime::from_frames(2000, film->audio_frame_rate())); + staircase->set_trim_start (ContentTime::from_frames(12, 48000)); staircase->set_trim_end (ContentTime::from_frames (35, 48000)); staircase->audio->set_gain (20 * log10(2)); @@ -70,21 +67,19 @@ BOOST_AUTO_TEST_CASE (torture_test1) film->examine_and_add_content (staircase); BOOST_REQUIRE (!wait_for_jobs()); staircase->set_position (film, DCPTime::from_frames(50000, film->audio_frame_rate())); - staircase->set_trim_start (ContentTime::from_frames (12, 48000)); - staircase->set_trim_end (ContentTime::from_frames (35, 48000)); + staircase->set_trim_start (ContentTime::from_frames(12, 48000)); + staircase->set_trim_end (ContentTime::from_frames(35, 48000)); staircase->audio->set_gain (20 * log10(2)); /* 1s of red at 5s in */ - shared_ptr red = content_factory("test/data/flat_red.png").front (); + auto red = content_factory("test/data/flat_red.png").front(); film->examine_and_add_content (red); BOOST_REQUIRE (!wait_for_jobs()); red->set_position (film, DCPTime::from_seconds(5)); red->video->set_length (24); film->set_video_frame_rate (24); - film->write_metadata (); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); dcp::DCP dcp ("build/test/torture_test1/" + film->dcp_name(false)); dcp.read (); @@ -102,7 +97,7 @@ BOOST_AUTO_TEST_CASE (torture_test1) BOOST_REQUIRE (sound); BOOST_CHECK_EQUAL (sound->intrinsic_duration(), 144); - shared_ptr sound_reader = sound->start_read (); + auto sound_reader = sound->start_read (); /* First frame silent */ auto fr = sound_reader->get_frame (0); @@ -226,21 +221,21 @@ BOOST_AUTO_TEST_CASE (torture_test1) /* Check picture */ - shared_ptr reel_picture = reels.front()->main_picture(); + auto reel_picture = reels.front()->main_picture(); BOOST_REQUIRE (reel_picture); - shared_ptr picture = dynamic_pointer_cast (reel_picture->asset()); + auto picture = dynamic_pointer_cast (reel_picture->asset()); BOOST_REQUIRE (picture); BOOST_CHECK_EQUAL (picture->intrinsic_duration(), 144); - shared_ptr picture_reader = picture->start_read (); + auto picture_reader = picture->start_read (); /* First 5 * 24 = 120 frames should be black, possibly with a little noise to raise the bitrate */ shared_ptr ref; for (int i = 0; i < 120; ++i) { - shared_ptr fr = picture_reader->get_frame (i); - shared_ptr image = fr->xyz_image (); - dcp::Size const size = image->size (); + auto fr = picture_reader->get_frame (i); + auto image = fr->xyz_image (); + auto const size = image->size (); if (i == 0) { /* Check the first frame pixel by pixel... */ for (int c = 0; c < 3; ++c) { @@ -265,9 +260,9 @@ BOOST_AUTO_TEST_CASE (torture_test1) /* Then 24 red, perhaps also with some noise */ for (int i = 120; i < 144; ++i) { - shared_ptr fr = picture_reader->get_frame (i); - shared_ptr image = fr->xyz_image (); - dcp::Size const size = image->size (); + auto fr = picture_reader->get_frame (i); + auto image = fr->xyz_image (); + auto const size = image->size (); if (i == 120) { for (int y = 0; y < size.height; ++y) { for (int x = 0; x < size.width; ++x) { diff --git a/test/video_level_test.cc b/test/video_level_test.cc index 9514e29a0..88fb2390c 100644 --- a/test/video_level_test.cc +++ b/test/video_level_test.cc @@ -401,8 +401,7 @@ static pair dcp_range (shared_ptr film) { - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film); return pixel_range (film->dir(film->dcp_name())); } diff --git a/test/video_mxf_content_test.cc b/test/video_mxf_content_test.cc index 60422ecf9..f110062d1 100644 --- a/test/video_mxf_content_test.cc +++ b/test/video_mxf_content_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,14 @@ */ + /** @file test/video_mxf_content_test.cc * @brief Test use of Video MXF content. * @ingroup feature */ + + #include "lib/film.h" #include "lib/video_mxf_content.h" #include "lib/content_factory.h" @@ -32,35 +35,39 @@ #include #include + +using std::make_shared; using std::shared_ptr; using std::dynamic_pointer_cast; + static boost::filesystem::path ref_mxf = "test/data/scaling_test_185_185/j2c_74b946f4-1c33-4209-b639-b834de675eac.mxf"; + static void note (dcp::NoteType, std::string) { } + /** Basic test of using video MXF content */ BOOST_AUTO_TEST_CASE (video_mxf_content_test) { - shared_ptr film = new_test_film ("video_mxf_content_test"); + auto film = new_test_film ("video_mxf_content_test"); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_container (Ratio::from_id ("185")); film->set_name ("video_mxf_content_test"); - shared_ptr content = content_factory(ref_mxf).front(); - shared_ptr check = dynamic_pointer_cast (content); + auto content = content_factory(ref_mxf).front(); + auto check = dynamic_pointer_cast (content); BOOST_REQUIRE (check); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE }); - shared_ptr ref (new dcp::MonoPictureAsset (ref_mxf)); + auto ref = make_shared(ref_mxf); boost::filesystem::directory_iterator i ("build/test/video_mxf_content_test/video"); - shared_ptr comp (new dcp::MonoPictureAsset (*i)); + auto comp = make_shared(*i); dcp::EqualityOptions op; BOOST_CHECK (ref->equals (comp, op, note)); }