+
+
+static void
+no_op ()
+{
+
+}
+
+static void
+dump_notes (vector<dcp::VerificationNote> const & notes)
+{
+ for (auto i: notes) {
+ std::cout << dcp::note_to_string(i) << "\n";
+ }
+}
+
+
+/** Using less than 1 second's worth of content should not result in a reel
+ * of less than 1 second's duration.
+ */
+BOOST_AUTO_TEST_CASE (reels_should_not_be_short1)
+{
+ auto A = make_shared<FFmpegContent>("test/data/flat_red.png");
+ auto B = make_shared<FFmpegContent>("test/data/flat_red.png");
+ auto film = new_test_film2 ("reels_should_not_be_short1", {A, B});
+ film->set_video_frame_rate (24);
+
+ A->video->set_length (23);
+
+ B->video->set_length (23);
+ B->set_position (film, DCPTime::from_frames(23, 24));
+
+ make_and_verify_dcp (film);
+
+ vector<boost::filesystem::path> dirs = { film->dir(film->dcp_name(false)) };
+ auto notes = dcp::verify(dirs, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd());
+ dump_notes (notes);
+ BOOST_REQUIRE (notes.empty());
+}
+
+
+/** Leaving less than 1 second's gap between two pieces of content with
+ * ReelType::BY_VIDEO_CONTENT should not make a <1s reel.
+ */
+BOOST_AUTO_TEST_CASE (reels_should_not_be_short2)
+{
+ auto A = make_shared<FFmpegContent>("test/data/flat_red.png");
+ auto B = make_shared<FFmpegContent>("test/data/flat_red.png");
+ auto film = new_test_film2 ("reels_should_not_be_short2", {A, B});
+ film->set_video_frame_rate (24);
+ film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
+
+ A->video->set_length (240);
+
+ B->video->set_length (240);
+ B->set_position (film, DCPTime::from_seconds(10.2));
+
+ make_and_verify_dcp (film);
+
+ vector<boost::filesystem::path> dirs = { film->dir(film->dcp_name(false)) };
+ auto const notes = dcp::verify(dirs, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd());
+ dump_notes (notes);
+ BOOST_REQUIRE (notes.empty());
+}
+
+
+/** Setting ReelType::BY_LENGTH and using a small length value should not make
+ * <1s reels.
+ */
+BOOST_AUTO_TEST_CASE (reels_should_not_be_short3)
+{
+ auto A = make_shared<FFmpegContent>("test/data/flat_red.png");
+ auto film = new_test_film2 ("reels_should_not_be_short3", {A});
+ film->set_video_frame_rate (24);
+ film->set_reel_type (ReelType::BY_LENGTH);
+ film->set_reel_length (1024 * 1024 * 10);
+
+ A->video->set_length (240);
+
+ make_and_verify_dcp (film);
+
+ auto const notes = dcp::verify({}, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd());
+ dump_notes (notes);
+ BOOST_REQUIRE (notes.empty());
+}
+
+
+/** Having one piece of content less than 1s long in ReelType::BY_VIDEO_CONTENT
+ * should not make a reel less than 1s long.
+ */
+BOOST_AUTO_TEST_CASE (reels_should_not_be_short4)
+{
+ auto A = make_shared<FFmpegContent>("test/data/flat_red.png");
+ auto B = make_shared<FFmpegContent>("test/data/flat_red.png");
+ auto film = new_test_film2 ("reels_should_not_be_short4", {A, B});
+ film->set_video_frame_rate (24);
+ film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
+
+ A->video->set_length (240);
+
+ B->video->set_length (23);
+ B->set_position (film, DCPTime::from_frames(240, 24));
+
+ BOOST_CHECK_EQUAL (film->reels().size(), 1U);
+ BOOST_CHECK (film->reels().front() == dcpomatic::DCPTimePeriod(dcpomatic::DCPTime(), dcpomatic::DCPTime::from_frames(263, 24)));
+
+ film->write_metadata ();
+ make_dcp (film, TranscodeJob::ChangedBehaviour::IGNORE);
+ BOOST_REQUIRE (!wait_for_jobs());
+
+ vector<boost::filesystem::path> dirs = { film->dir(film->dcp_name(false)) };
+ auto const notes = dcp::verify(dirs, boost::bind(&no_op), boost::bind(&no_op), TestPaths::xsd());
+ dump_notes (notes);
+ BOOST_REQUIRE (notes.empty());
+}
+