X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Ftorture_test.cc;h=27b4b5d144cd5194c3fa06abb2bb94bfdaea12b2;hb=b29eb5107c5e77fe01e43010e1582e733f6ceea1;hp=b941a5ade66c211034b5ddc6f6d4ec2fcf7f54d6;hpb=3449bc0a6d6e77e851240a0953363f5a07ec6517;p=dcpomatic.git diff --git a/test/torture_test.cc b/test/torture_test.cc index b941a5ade..27b4b5d14 100644 --- a/test/torture_test.cc +++ b/test/torture_test.cc @@ -19,7 +19,8 @@ */ /** @file test/torture_test.cc - * @brief Entire projects that are programmatically created and checked. + * @brief Tricky arrangements of content whose resulting DCPs are checked programmatically. + * @ingroup completedcp */ #include "lib/audio_content.h" @@ -38,10 +39,13 @@ #include #include #include +#include using std::list; +using std::cout; using boost::shared_ptr; using boost::dynamic_pointer_cast; +using namespace dcpomatic; /** Test start/end trim and positioning of some audio content */ BOOST_AUTO_TEST_CASE (torture_test1) @@ -52,43 +56,43 @@ BOOST_AUTO_TEST_CASE (torture_test1) film->set_container (Ratio::from_id ("185")); film->set_sequence (false); - /* Staircase at an offset of 2000 samples, trimmed both start and end, with a gain of 6dB */ - shared_ptr staircase = content_factory(film, "test/data/staircase.wav").front (); + /* 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 (); film->examine_and_add_content (staircase); - wait_for_jobs (); - staircase->set_position (DCPTime::from_frames (2000, film->audio_frame_rate())); + 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_trim_end (ContentTime::from_frames (35, 48000)); staircase->audio->set_gain (20 * log10(2)); - /* And again at an offset of 50000 samples, trimmed both start and end, with a gain of 6dB */ - staircase = content_factory(film, "test/data/staircase.wav").front (); + /* And again at an offset of 50000 samples, trimmed both start and end, with a gain of exactly 2 (linear) */ + staircase = content_factory("test/data/staircase.wav").front (); film->examine_and_add_content (staircase); - wait_for_jobs (); - staircase->set_position (DCPTime::from_frames (50000, film->audio_frame_rate())); + 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->audio->set_gain (20 * log10(2)); /* 1s of red at 5s in */ - shared_ptr red = content_factory(film, "test/data/flat_red.png").front (); + shared_ptr red = content_factory("test/data/flat_red.png").front (); film->examine_and_add_content (red); - wait_for_jobs (); - red->set_position (DCPTime::from_seconds (5)); + 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 (); - wait_for_jobs (); + BOOST_REQUIRE (!wait_for_jobs()); - dcp::DCP dcp ("build/test/torture_test/" + film->dcp_name(false)); + dcp::DCP dcp ("build/test/torture_test1/" + film->dcp_name(false)); dcp.read (); list > cpls = dcp.cpls (); - BOOST_REQUIRE_EQUAL (cpls.size(), 1); + BOOST_REQUIRE_EQUAL (cpls.size(), 1U); list > reels = cpls.front()->reels (); - BOOST_REQUIRE_EQUAL (reels.size(), 1); + BOOST_REQUIRE_EQUAL (reels.size(), 1U); /* Check sound */ @@ -114,49 +118,57 @@ BOOST_AUTO_TEST_CASE (torture_test1) int stair = 12; - fr = sound_reader->get_frame (1); - for (int i = 0; i < fr->samples(); ++i) { - for (int j = 0; j < 6; ++j) { - if (j == 2) { - BOOST_CHECK_EQUAL ((fr->get(j, i) + 128) >> 8, stair * 2); - ++stair; - } else { - BOOST_CHECK_EQUAL (fr->get(j, i), 0); + BOOST_TEST_CONTEXT("First staircase, frame #1") { + fr = sound_reader->get_frame (1); + for (int i = 0; i < fr->samples(); ++i) { + for (int j = 0; j < 6; ++j) { + if (j == 2) { + BOOST_CHECK_EQUAL ((fr->get(j, i) + 128) >> 8, stair * 2); + ++stair; + } else { + BOOST_CHECK_EQUAL (fr->get(j, i), 0); + } } } } - fr = sound_reader->get_frame (2); - for (int i = 0; i < fr->samples(); ++i) { - for (int j = 0; j < 6; ++j) { - if (j == 2) { - BOOST_CHECK_EQUAL ((fr->get(j, i) + 128) >> 8, stair * 2); - ++stair; - } else { - BOOST_CHECK_EQUAL (fr->get(j, i), 0); + BOOST_TEST_CONTEXT("First staircase, frame #2") { + fr = sound_reader->get_frame (2); + for (int i = 0; i < fr->samples(); ++i) { + for (int j = 0; j < 6; ++j) { + if (j == 2) { + BOOST_CHECK_EQUAL ((fr->get(j, i) + 128) >> 8, stair * 2); + ++stair; + } else { + BOOST_CHECK_EQUAL (fr->get(j, i), 0); + } } } } - fr = sound_reader->get_frame (3); - for (int i = 0; i < fr->samples(); ++i) { - for (int j = 0; j < 6; ++j) { - if (j == 2 && i < (4753 - (2000 * 2))) { - BOOST_CHECK_EQUAL ((fr->get(j, i) + 128) >> 8, stair * 2); - ++stair; - } else { - BOOST_CHECK_EQUAL (fr->get(j, i), 0); + BOOST_TEST_CONTEXT("First staircase, frame #3") { + fr = sound_reader->get_frame (3); + for (int i = 0; i < fr->samples(); ++i) { + for (int j = 0; j < 6; ++j) { + if (j == 2 && i < (4753 - (2000 * 2))) { + BOOST_CHECK_EQUAL ((fr->get(j, i) + 128) >> 8, stair * 2); + ++stair; + } else { + BOOST_CHECK_EQUAL (fr->get(j, i), 0); + } } } } /* Then some silence */ - for (int i = 4; i < 24; ++i) { - fr = sound_reader->get_frame (i); - for (int j = 0; j < fr->samples(); ++j) { - for (int k = 0; k < 6; ++k) { - BOOST_CHECK_EQUAL (fr->get(k, j), 0); + BOOST_TEST_CONTEXT("Silence") { + for (int i = 4; i < 24; ++i) { + fr = sound_reader->get_frame (i); + for (int j = 0; j < fr->samples(); ++j) { + for (int k = 0; k < 6; ++k) { + BOOST_CHECK_EQUAL (fr->get(k, j), 0); + } } } }