Make sure 2-channel MXFs don't get extra channel descriptors (#2631).
[dcpomatic.git] / test / writer_test.cc
index cb97cf78afb2209b4cccbf1dc342249e44bb5636..76e9ddb28799aa46575e78d93bb4388ed50217f5 100644 (file)
 
 using std::make_shared;
 using std::shared_ptr;
+using std::vector;
 
 
 BOOST_AUTO_TEST_CASE (test_write_odd_amount_of_silence)
 {
-       auto content = content_factory("test/data/flat_red.png").front();
-       auto film = new_test_film2 ("test_write_odd_amount_of_silence", {content});
-       content->video->set_length(24);
+       auto content = content_factory("test/data/flat_red.png");
+       auto film = new_test_film2 ("test_write_odd_amount_of_silence", content);
+       content[0]->video->set_length(24);
        auto writer = make_shared<Writer>(film, shared_ptr<Job>());
 
        auto audio = make_shared<AudioBuffers>(6, 48000);
@@ -53,14 +54,16 @@ BOOST_AUTO_TEST_CASE (test_write_odd_amount_of_silence)
 
 BOOST_AUTO_TEST_CASE (interrupt_writer)
 {
-       auto film = new_test_film2 ("test_interrupt_writer");
+       Cleanup cl;
 
-       auto content = content_factory("test/data/check_image0.png").front();
+       auto film = new_test_film2 ("test_interrupt_writer", {}, &cl);
+
+       auto content = content_factory("test/data/check_image0.png")[0];
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
 
        /* Add some dummy content to the film so that it has a reel of the right length */
-       auto constexpr frames = 24 * 60 * 60;
+       auto constexpr frames = 24 * 60;
        content->video->set_length (frames);
 
        /* Make a random J2K image */
@@ -68,7 +71,7 @@ BOOST_AUTO_TEST_CASE (interrupt_writer)
        auto image = make_shared<dcp::OpenJPEGImage>(size);
        for (int i = 0; i < 3; ++i) {
                for (int j = 0; j < (size.width * size.height); ++j) {
-                       image->data(i)[j] = rand();
+                       image->data(i)[j] = rand() % 4095;
                }
        }
 
@@ -93,7 +96,8 @@ BOOST_AUTO_TEST_CASE (interrupt_writer)
        dcpomatic_sleep_seconds (1);
 
        thread.interrupt ();
+       thread.join ();
 
        dcpomatic_sleep_seconds (1);
+       cl.run ();
 }
-