Fill test disk partitions with random noise to expose more bugs.
[dcpomatic.git] / test / hints_test.cc
index 51374b274d74546faa5dc18e7f39f8ebda510c53..ff989647359bfe8e6aaa9357e0b6757f42d90f31 100644 (file)
@@ -63,6 +63,7 @@ get_hints (shared_ptr<Film> film)
        hints.start ();
        hints.join ();
        while (signal_manager->ui_idle()) {}
+       hints.rethrow();
        return current_hints;
 }
 
@@ -172,17 +173,20 @@ BOOST_AUTO_TEST_CASE (hint_subtitle_mxf_too_big)
 {
        string const name = "hint_subtitle_mxf_too_big";
 
+       dcp::File fake_font("build/test/hint_subtitle_mxf_too_big.ttf", "w");
+       for (int i = 0; i < 4096; ++i) {
+               std::vector<uint8_t> rubbish(65536);
+               fake_font.write(rubbish.data(), 1, rubbish.size());
+       }
+       fake_font.close();
+
        auto film = new_test_film2 (name);
        auto content = content_factory("test/data/" + name + ".srt").front();
        content->text.front()->set_type (TextType::OPEN_SUBTITLE);
        content->text.front()->set_language (dcp::LanguageTag("en-US"));
-       for (int i = 1; i < 512; ++i) {
-               auto font = make_shared<dcpomatic::Font>(String::compose("font_%1", i));
-               font->set_file ("test/data/LiberationSans-Regular.ttf");
-               content->text.front()->add_font(font);
-       }
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
+       content->text.front()->get_font("")->set_file("build/test/hint_subtitle_mxf_too_big.ttf");
        auto hints = get_hints (film);
 
        BOOST_REQUIRE_EQUAL (hints.size(), 1U);
@@ -200,16 +204,16 @@ BOOST_AUTO_TEST_CASE (hint_closed_caption_xml_too_big)
 
        auto film = new_test_film2 (name);
 
-       auto ccap = fopen_boost (String::compose("build/test/%1.srt", name), "w");
+       dcp::File ccap(String::compose("build/test/%1.srt", name), "w");
        BOOST_REQUIRE (ccap);
        for (int i = 0; i < 2048; ++i) {
-               fprintf(ccap, "%d\n", i + 1);
+               fprintf(ccap.get(), "%d\n", i + 1);
                int second = i * 2;
                int minute = second % 60;
-               fprintf(ccap, "00:%02d:%02d,000 --> 00:%02d:%02d,000\n", minute, second, minute, second + 1);
-               fprintf(ccap, "Here are some closed captions.\n\n");
+               fprintf(ccap.get(), "00:%02d:%02d,000 --> 00:%02d:%02d,000\n", minute, second, minute, second + 1);
+               fprintf(ccap.get(), "Here are some closed captions.\n\n");
        }
-       fclose (ccap);
+       ccap.close();
 
        auto content = content_factory("build/test/" + name + ".srt").front();
        content->text.front()->set_type (TextType::CLOSED_CAPTION);