Tidy up and add a couple more tests.
[dcpomatic.git] / test / player_test.cc
index 0ddb67afcb70b817e718803190cc1ca0aa25ff93..6a6864dbaf6e0eb77f2e7c4a8385d1b6272341d8 100644 (file)
@@ -92,6 +92,7 @@ BOOST_AUTO_TEST_CASE (player_black_fill_test)
        film->set_name ("black_fill_test");
        film->set_container (Ratio::from_id ("185"));
        film->set_sequence (false);
+       film->set_interop (false);
        shared_ptr<ImageContent> contentA (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
        shared_ptr<ImageContent> contentB (new ImageContent (film, "test/data/simple_testcard_640x480.png"));
 
@@ -226,6 +227,39 @@ BOOST_AUTO_TEST_CASE (player_seek_test)
                pair<shared_ptr<PlayerVideo>, DCPTime> video = butler->get_video();
                BOOST_CHECK_EQUAL(video.second.get(), t.get());
                write_image(video.first->image(note_handler, PlayerVideo::always_rgb, false, true), String::compose("build/test/player_seek_test_%1.png", i), "RGB");
-               check_image(String::compose("test/data/player_seek_test_%1.png", i), String::compose("build/test/player_seek_test_%1.png", i));
+               /* This 0.011 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine
+                  (17.10 and 16.04 seem to anti-alias a little differently) but to reject gross errors e.g. missing fonts or missing
+                  text altogether.
+               */
+               check_image(String::compose("test/data/player_seek_test_%1.png", i), String::compose("build/test/player_seek_test_%1.png", i), 0.011);
+       }
+}
+
+/** Test some more seeks towards the start of a DCP with awkward subtitles */
+BOOST_AUTO_TEST_CASE (player_seek_test2)
+{
+       shared_ptr<Film> film (new Film (optional<boost::filesystem::path>()));
+       shared_ptr<DCPContent> dcp (new DCPContent (film, private_data / "awkward_subs2"));
+       film->examine_and_add_content (dcp, true);
+       BOOST_REQUIRE (!wait_for_jobs ());
+       dcp->subtitle->set_use (true);
+
+       shared_ptr<Player> player (new Player (film, film->playlist()));
+       player->set_fast ();
+       player->set_always_burn_subtitles (true);
+       player->set_play_referenced ();
+
+       shared_ptr<Butler> butler (new Butler (player, film->log(), AudioMapping(), 2));
+       butler->disable_audio();
+
+       butler->seek(DCPTime::from_seconds(5), true);
+
+       for (int i = 0; i < 10; ++i) {
+               DCPTime t = DCPTime::from_seconds(5) + DCPTime::from_frames (i, 24);
+               butler->seek (t, true);
+               pair<shared_ptr<PlayerVideo>, DCPTime> video = butler->get_video();
+               BOOST_CHECK_EQUAL(video.second.get(), t.get());
+               write_image(video.first->image(note_handler, PlayerVideo::always_rgb, false, true), String::compose("build/test/player_seek_test2_%1.png", i), "RGB");
+               check_image(String::compose("test/data/player_seek_test2_%1.png", i), String::compose("build/test/player_seek_test2_%1.png", i), 0.011);
        }
 }