X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fhints_test.cc;h=c228cd07af4c6b38089c259dd9242a0b0785b20f;hb=46b0a3c2c8fa25b9881c4ae64a42682959464217;hp=5222f904634274d97a730db32bbdda56f8af67ec;hpb=d5c44003e016ea4d7ef0d59f3fffac1cb84f4839;p=dcpomatic.git diff --git a/test/hints_test.cc b/test/hints_test.cc index 5222f9046..c228cd07a 100644 --- a/test/hints_test.cc +++ b/test/hints_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -19,6 +19,7 @@ */ +#include "lib/audio_content.h" #include "lib/content.h" #include "lib/content_factory.h" #include "lib/cross.h" @@ -28,14 +29,14 @@ #include "lib/text_content.h" #include "lib/util.h" #include "test.h" -#include #include +using std::make_shared; +using std::shared_ptr; using std::string; using std::vector; using boost::optional; -using boost::shared_ptr; vector current_hints; @@ -55,6 +56,8 @@ get_hints (shared_ptr film) { current_hints.clear (); Hints hints (film); + /* None of our tests need the audio analysis, and it is quite time-consuming */ + hints.disable_audio_analysis (); hints.Hint.connect (collect_hint); hints.start (); hints.join (); @@ -67,12 +70,13 @@ static void check (TextType type, string name, optional expected_hint = optional()) { - shared_ptr film = new_test_film2 (name); - shared_ptr content = content_factory("test/data/" + name + ".srt").front(); + auto film = new_test_film2 (name); + auto content = content_factory("test/data/" + name + ".srt").front(); content->text.front()->set_type (type); + content->text.front()->set_language (dcp::LanguageTag("en-US")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - vector hints = get_hints (film); + auto hints = get_hints (film); if (expected_hint) { BOOST_REQUIRE_EQUAL (hints.size(), 1U); @@ -86,7 +90,7 @@ check (TextType type, string name, optional expected_hint = optional film = new_test_film2 (name); - shared_ptr content = content_factory("test/data/" + name + ".srt").front(); - content->text.front()->set_type (TEXT_OPEN_SUBTITLE); + 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) { - shared_ptr font(new dcpomatic::Font(String::compose("font_%1", i))); + auto font = make_shared(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()); - vector hints = get_hints (film); + auto hints = get_hints (film); BOOST_REQUIRE_EQUAL (hints.size(), 1U); BOOST_CHECK_EQUAL ( @@ -182,9 +197,9 @@ BOOST_AUTO_TEST_CASE (hint_closed_caption_xml_too_big) { string const name = "hint_closed_caption_xml_too_big"; - shared_ptr film = new_test_film2 (name); + auto film = new_test_film2 (name); - FILE* ccap = fopen_boost (String::compose("build/test/%1.srt", name), "w"); + auto ccap = fopen_boost (String::compose("build/test/%1.srt", name), "w"); BOOST_REQUIRE (ccap); for (int i = 0; i < 2048; ++i) { fprintf(ccap, "%d\n", i + 1); @@ -195,11 +210,12 @@ BOOST_AUTO_TEST_CASE (hint_closed_caption_xml_too_big) } fclose (ccap); - shared_ptr content = content_factory("build/test/" + name + ".srt").front(); - content->text.front()->set_type (TEXT_CLOSED_CAPTION); + auto content = content_factory("build/test/" + name + ".srt").front(); + content->text.front()->set_type (TextType::CLOSED_CAPTION); + content->text.front()->set_language (dcp::LanguageTag("en-US")); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - vector hints = get_hints (film); + auto hints = get_hints (film); BOOST_REQUIRE_EQUAL (hints.size(), 1U); BOOST_CHECK_EQUAL ( @@ -209,3 +225,35 @@ BOOST_AUTO_TEST_CASE (hint_closed_caption_xml_too_big) ); } + +BOOST_AUTO_TEST_CASE (hints_destroyed_while_running) +{ + auto film = new_test_film2 ("hints_destroyed_while_running"); + auto content = content_factory(TestPaths::private_data() / "boon_telly.mkv").front(); + film->examine_and_add_content (content); + BOOST_REQUIRE (!wait_for_jobs()); + + auto hints = make_shared(film); + hints->start (); + dcpomatic_sleep_seconds (1); + hints.reset (); + dcpomatic_sleep_seconds (1); +} + + +BOOST_AUTO_TEST_CASE (hints_audio_with_no_language) +{ + auto content = content_factory("test/data/sine_440.wav").front(); + auto film = new_test_film2 ("hints_audio_with_no_language", { content }); + content->audio->set_gain (-6); + + auto hints = get_hints (film); + BOOST_REQUIRE_EQUAL (hints.size(), 1U); + BOOST_CHECK_EQUAL ( + hints[0], + "Some of your content has audio but you have not set the audio language. It is advisable to set the audio language " + "in the \"DCP\" tab unless your audio has no spoken parts." + ); + +} +