Fill test disk partitions with random noise to expose more bugs.
[dcpomatic.git] / test / import_dcp_test.cc
index 44f3c7d444d7008e98d42284a2204d90cff27758..cfac511b32e9e78f285eab944e58f8436b781a5c 100644 (file)
@@ -54,6 +54,8 @@ using std::make_shared;
 /** Make an encrypted DCP, import it and make a new unencrypted DCP */
 BOOST_AUTO_TEST_CASE (import_dcp_test)
 {
+       ConfigRestorer cr;
+
        auto A = new_test_film ("import_dcp_test");
        A->set_container (Ratio::from_id ("185"));
        A->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
@@ -65,15 +67,13 @@ BOOST_AUTO_TEST_CASE (import_dcp_test)
        A->set_encrypted (true);
        BOOST_CHECK (!wait_for_jobs ());
 
-       A->make_dcp ();
-       BOOST_CHECK (!wait_for_jobs ());
+       make_and_verify_dcp (A);
 
        dcp::DCP A_dcp ("build/test/import_dcp_test/" + A->dcp_name());
        A_dcp.read ();
 
-       Config::instance()->set_decryption_chain (make_shared<dcp::CertificateChain>(openssl_path()));
+       Config::instance()->set_decryption_chain (make_shared<dcp::CertificateChain>(openssl_path(), CERTIFICATE_VALIDITY_PERIOD));
 
-       /* Dear future-carl: I suck!  I thought you wouldn't still be running these tests in 2030!  Sorry! */
        auto kdm = A->make_kdm (
                Config::instance()->decryption_chain()->leaf (),
                vector<string>(),
@@ -97,8 +97,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_test)
        JobManager::instance()->add (make_shared<ExamineContentJob>(B, d));
        BOOST_CHECK (!wait_for_jobs ());
 
-       B->make_dcp ();
-       BOOST_CHECK (!wait_for_jobs ());
+       make_and_verify_dcp (B);
 
        /* Should be 1s red, 1s green, 1s blue */
        check_dcp ("test/data/import_dcp_test2", "build/test/import_dcp_test2/" + B->dcp_name());
@@ -111,25 +110,20 @@ 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);
 
-       film->set_marker(dcp::Marker::FFOC, dcpomatic::DCPTime::from_seconds(1.91));
+       film->set_marker(dcp::Marker::FFOC, dcpomatic::DCPTime::from_frames(1, 24));
        film->set_marker(dcp::Marker::FFMC, dcpomatic::DCPTime::from_seconds(9.4));
        film->set_marker(dcp::Marker::LFMC, dcpomatic::DCPTime::from_seconds(9.99));
 
-       film->make_dcp ();
-       BOOST_REQUIRE (!wait_for_jobs());
+       make_and_verify_dcp (film);
 
        /* 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<DCPContent>(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
@@ -138,8 +132,6 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test)
        BOOST_CHECK_EQUAL (imported->markers().size(), 4U);
 
        auto markers = imported->markers();
-       BOOST_REQUIRE(markers.find(dcp::Marker::FFOC) != markers.end());
-       BOOST_CHECK(markers[dcp::Marker::FFOC] == dcpomatic::ContentTime(184000));
        BOOST_REQUIRE(markers.find(dcp::Marker::FFMC) != markers.end());
        BOOST_CHECK(markers[dcp::Marker::FFMC] == dcpomatic::ContentTime(904000));
        BOOST_REQUIRE(markers.find(dcp::Marker::LFMC) != markers.end());
@@ -149,14 +141,12 @@ BOOST_AUTO_TEST_CASE (import_dcp_markers_test)
        auto film3 = make_shared<Film>(boost::filesystem::path("build/test/import_dcp_markers_test2"));
        film3->read_metadata ();
        BOOST_REQUIRE_EQUAL (film3->content().size(), 1U);
-       shared_ptr<DCPContent> reloaded = dynamic_pointer_cast<DCPContent>(film3->content().front());
+       auto reloaded = dynamic_pointer_cast<DCPContent>(film3->content().front());
        BOOST_REQUIRE (reloaded);
 
        BOOST_CHECK_EQUAL (reloaded->markers().size(), 4U);
 
        markers = reloaded->markers();
-       BOOST_REQUIRE(markers.find(dcp::Marker::FFOC) != markers.end());
-       BOOST_CHECK(markers[dcp::Marker::FFOC] == dcpomatic::ContentTime(184000));
        BOOST_REQUIRE(markers.find(dcp::Marker::FFMC) != markers.end());
        BOOST_CHECK(markers[dcp::Marker::FFMC] == dcpomatic::ContentTime(904000));
        BOOST_REQUIRE(markers.find(dcp::Marker::LFMC) != markers.end());
@@ -183,8 +173,7 @@ BOOST_AUTO_TEST_CASE (import_dcp_metadata_test)
        vector<string> cv = { "Fred "};
        film->set_content_versions (cv);
 
-       film->make_dcp ();
-       BOOST_REQUIRE (!wait_for_jobs());
+       make_and_verify_dcp (film);
 
        /* Import the DCP to a new film and check the metadata */
        auto film2 = new_test_film2 ("import_dcp_metadata_test2");