diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-09-01 23:32:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-09-01 23:32:22 +0100 |
| commit | 33330f6e2cccb3be51788e919e763139d679cc8b (patch) | |
| tree | 683c781a9fc83830eed0d1b189166dd668aa4086 | |
| parent | bfd3eb677d687080f10c2e6b79724b98180317e5 (diff) | |
Fix up remake_with_subtitle_test.
| -rw-r--r-- | test/remake_with_subtitle_test.cc | 6 | ||||
| -rw-r--r-- | test/test.cc | 43 | ||||
| -rw-r--r-- | test/test.h | 2 |
3 files changed, 49 insertions, 2 deletions
diff --git a/test/remake_with_subtitle_test.cc b/test/remake_with_subtitle_test.cc index 0190e9837..bc6d41798 100644 --- a/test/remake_with_subtitle_test.cc +++ b/test/remake_with_subtitle_test.cc @@ -28,6 +28,9 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; +/** Check that if we remake a DCP having turned off subtitles the code notices + * and doesn't re-use the old video data. + */ BOOST_AUTO_TEST_CASE (remake_with_subtitle_test) { shared_ptr<Film> film = new_test_film2 ("remake_with_subtitle_test"); @@ -45,6 +48,5 @@ BOOST_AUTO_TEST_CASE (remake_with_subtitle_test) film->make_dcp (); BOOST_REQUIRE (!wait_for_jobs ()); - /* Nothing is being checked here so this test is not complete */ - DCPOMATIC_ASSERT (false); + check_one_frame (film->dir(film->dcp_name()), 325, private_data / "prophet_frame_325_no_subs.j2c"); } diff --git a/test/test.cc b/test/test.cc index a2593dca4..9027b8b71 100644 --- a/test/test.cc +++ b/test/test.cc @@ -35,6 +35,12 @@ #include "lib/dcp_content_type.h" #include "lib/log_entry.h" #include <dcp/dcp.h> +#include <dcp/cpl.h> +#include <dcp/reel.h> +#include <dcp/reel_picture_asset.h> +#include <dcp/mono_picture_frame.h> +#include <dcp/mono_picture_asset.h> +#include <dcp/openjpeg_image.h> #include <asdcp/AS_DCP.h> #include <sndfile.h> #include <libxml++/libxml++.h> @@ -45,6 +51,7 @@ extern "C" { #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE dcpomatic_test #include <boost/test/unit_test.hpp> +#include <boost/algorithm/string.hpp> #include <list> #include <vector> #include <iostream> @@ -58,6 +65,7 @@ using std::list; using std::abs; using boost::shared_ptr; using boost::scoped_array; +using boost::dynamic_pointer_cast; boost::filesystem::path private_data = boost::filesystem::path ("..") / boost::filesystem::path ("dcpomatic-test-private"); @@ -459,3 +467,38 @@ check_ffmpeg (boost::filesystem::path ref, boost::filesystem::path check, int sk BOOST_REQUIRE_EQUAL (memcmp (ref_p.buf->data, check_p.buf->data, ref_p.buf->size), 0); } } + +void +check_one_frame (boost::filesystem::path dcp_dir, int64_t index, boost::filesystem::path ref) +{ + dcp::DCP dcp (dcp_dir); + dcp.read (); + shared_ptr<dcp::MonoPictureAsset> asset = dynamic_pointer_cast<dcp::MonoPictureAsset> (dcp.cpls().front()->reels().front()->main_picture()->asset()); + BOOST_REQUIRE (asset); + shared_ptr<const dcp::MonoPictureFrame> frame = asset->start_read()->get_frame(index); + + boost::uintmax_t const ref_size = boost::filesystem::file_size(ref); + BOOST_CHECK_EQUAL (frame->j2k_size(), ref_size); + + FILE* ref_file = fopen_boost(ref, "rb"); + BOOST_REQUIRE (ref_file); + + uint8_t* ref_data = new uint8_t[ref_size]; + fread (ref_data, ref_size, 1, ref_file); + fclose (ref_file); + + BOOST_CHECK (memcmp(ref_data, frame->j2k_data(), ref_size) == 0); + delete[] ref_data; +} + +boost::filesystem::path +video_file (shared_ptr<const Film> film) +{ + boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (film->dir(film->dcp_name())); + while (i != boost::filesystem::directory_iterator() && !boost::algorithm::starts_with (i->path().leaf().string(), "j2c")) { + ++i; + } + + BOOST_REQUIRE (i != boost::filesystem::directory_iterator()); + return i->path(); +} diff --git a/test/test.h b/test/test.h index 33807bee8..75ab7b7f6 100644 --- a/test/test.h +++ b/test/test.h @@ -38,3 +38,5 @@ extern void check_ffmpeg (boost::filesystem::path, boost::filesystem::path, int extern void check_image (boost::filesystem::path, boost::filesystem::path); extern boost::filesystem::path test_film_dir (std::string); extern void write_image (boost::shared_ptr<const Image> image, boost::filesystem::path file, std::string format); +boost::filesystem::path video_file (boost::shared_ptr<const Film> film); +void check_one_frame (boost::filesystem::path dcp, int64_t index, boost::filesystem::path ref); |
