From a4e6a2cf1b0b85904f57a8604ea7757a13d865e4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 6 Feb 2023 02:56:31 +0100 Subject: Add failing test. --- test/atmos_test.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/data | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/atmos_test.cc b/test/atmos_test.cc index 5c624a871..c2b0cb6d8 100644 --- a/test/atmos_test.cc +++ b/test/atmos_test.cc @@ -25,10 +25,17 @@ #include "lib/dcp_content.h" #include "lib/film.h" #include "test.h" +#include +#include +#include +#include +#include #include using std::make_shared; +using std::shared_ptr; +using std::shared_ptr; using std::string; using std::vector; using boost::optional; @@ -103,3 +110,42 @@ BOOST_AUTO_TEST_CASE (atmos_trim_test) make_and_verify_dcp (film, { dcp::VerificationNote::Code::MISSING_CPL_METADATA }); } + +BOOST_AUTO_TEST_CASE(atmos_replace_test) +{ + auto const frames = 240; + + auto check = [](shared_ptr film, int data) { + dcp::DCP dcp(film->dir(film->dcp_name())); + dcp.read(); + BOOST_REQUIRE_EQUAL(dcp.cpls().size(), 1U); + BOOST_REQUIRE_EQUAL(dcp.cpls()[0]->reels().size(), 1U); + BOOST_REQUIRE(dcp.cpls()[0]->reels()[0]->atmos()); + auto asset = dcp.cpls()[0]->reels()[0]->atmos()->asset(); + BOOST_REQUIRE(asset); + auto reader = asset->start_read(); + for (int i = 0; i < frames; ++i) { + auto frame = reader->get_frame(i); + BOOST_REQUIRE(frame); + for (int j = 0; j < frame->size(); ++j) { + BOOST_REQUIRE_EQUAL(frame->data()[j], data); + } + } + }; + + auto atmos_0 = content_factory("test/data/atmos_0.mxf"); + auto ov = new_test_film2("atmos_merge_test_ov", atmos_0); + make_and_verify_dcp(ov, { dcp::VerificationNote::Code::MISSING_CPL_METADATA }); + // atmos_0.mxf should contain all zeros for its data + check(ov, 0); + + auto atmos_1 = content_factory("test/data/atmos_1.mxf"); + auto ov_content = std::make_shared(boost::filesystem::path("build/test/atmos_merge_test_ov") / ov->dcp_name()); + auto vf = new_test_film2("atmos_merge_test_vf", { ov_content, atmos_1.front() }); + ov_content->set_reference_video(true); + atmos_1.front()->set_position(vf, dcpomatic::DCPTime()); + make_and_verify_dcp(vf, { dcp::VerificationNote::Code::MISSING_CPL_METADATA, dcp::VerificationNote::Code::EXTERNAL_ASSET }); + // atmos_1.mxf should contain all ones for its data, and it should have replaced atmos_0 in this DCP + check(vf, 1); +} + diff --git a/test/data b/test/data index ff060de6b..3e257c17f 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit ff060de6bba8c07d1a63b0e059fd8d0c4e72c51e +Subproject commit 3e257c17fa5aa43b907af78d23c3fb810eaabdb2 -- cgit v1.2.3