Fill test disk partitions with random noise to expose more bugs.
[dcpomatic.git] / test / markers_test.cc
index f187057321ff92db311d1e484ea754fd8cf8e486..844f25660a34d82d4c7aea3330632f90fa197ec1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 using std::string;
 using boost::optional;
-using boost::shared_ptr;
+using std::shared_ptr;
 
 
 /** Check that FFOC and LFOC are automatically added if not specified */
 BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test1)
 {
        string const name = "automatic_ffoc_lfoc_markers_test1";
-       shared_ptr<Film> film = new_test_film2 (name);
+       auto film = new_test_film2 (name);
        film->examine_and_add_content (content_factory("test/data/flat_red.png").front());
        BOOST_REQUIRE (!wait_for_jobs());
 
        film->set_interop (false);
-       film->make_dcp ();
-       BOOST_REQUIRE (!wait_for_jobs());
+       make_and_verify_dcp (film);
 
        dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name()));
        dcp.read ();
-       BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1);
-       shared_ptr<dcp::CPL> cpl = dcp.cpls().front();
-       BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1);
-       shared_ptr<dcp::Reel> reel = cpl->reels().front();
-       shared_ptr<dcp::ReelMarkersAsset> markers = reel->main_markers();
+       BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
+       auto cpl = dcp.cpls().front();
+       BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1U);
+       auto reel = cpl->reels()[0];
+       auto markers = reel->main_markers();
        BOOST_REQUIRE (markers);
 
-       optional<dcp::Time> ffoc = markers->get (dcp::Marker::FFOC);
+       auto ffoc = markers->get (dcp::Marker::FFOC);
        BOOST_REQUIRE (ffoc);
-       BOOST_CHECK (*ffoc == dcp::Time (0, 0, 0, 0, 24));
-       optional<dcp::Time> lfoc = markers->get (dcp::Marker::LFOC);
+       BOOST_CHECK (*ffoc == dcp::Time(0, 0, 0, 1, 24));
+       auto lfoc = markers->get (dcp::Marker::LFOC);
        BOOST_REQUIRE (lfoc);
        BOOST_CHECK (*lfoc == dcp::Time(0, 0, 9, 23, 24));
 }
@@ -74,29 +73,33 @@ BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test1)
 BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test2)
 {
        string const name = "automatic_ffoc_lfoc_markers_test2";
-       shared_ptr<Film> film = new_test_film2 (name);
+       auto film = new_test_film2 (name);
        film->examine_and_add_content (content_factory("test/data/flat_red.png").front());
        BOOST_REQUIRE (!wait_for_jobs());
 
        film->set_interop (false);
        film->set_marker (dcp::Marker::FFOC, dcpomatic::DCPTime::from_seconds(1));
        film->set_marker (dcp::Marker::LFOC, dcpomatic::DCPTime::from_seconds(9));
-       film->make_dcp ();
-       BOOST_REQUIRE (!wait_for_jobs());
+       make_and_verify_dcp (
+               film,
+               {
+                       dcp::VerificationNote::Code::INCORRECT_FFOC,
+                       dcp::VerificationNote::Code::INCORRECT_LFOC
+               });
 
        dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name()));
        dcp.read ();
-       BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1);
-       shared_ptr<dcp::CPL> cpl = dcp.cpls().front();
-       BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1);
-       shared_ptr<dcp::Reel> reel = cpl->reels().front();
-       shared_ptr<dcp::ReelMarkersAsset> markers = reel->main_markers();
+       BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
+       auto cpl = dcp.cpls().front();
+       BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1U);
+       auto reel = cpl->reels()[0];
+       auto markers = reel->main_markers();
        BOOST_REQUIRE (markers);
 
-       optional<dcp::Time> ffoc = markers->get (dcp::Marker::FFOC);
+       auto ffoc = markers->get (dcp::Marker::FFOC);
        BOOST_REQUIRE (ffoc);
        BOOST_CHECK (*ffoc == dcp::Time (0, 0, 1, 0, 24));
-       optional<dcp::Time> lfoc = markers->get (dcp::Marker::LFOC);
+       auto lfoc = markers->get (dcp::Marker::LFOC);
        BOOST_REQUIRE (lfoc);
        BOOST_CHECK (*lfoc == dcp::Time(0, 0, 9, 0, 24));
 }