X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fhints_test.cc;h=5e59ef9241a7b60763eb5760b557e096d42106fc;hb=refs%2Fheads%2Ftidy-eq-options;hp=c228cd07af4c6b38089c259dd9242a0b0785b20f;hpb=cd6c6a693f19fcaa6c75ed60f48a54a8cae51352;p=dcpomatic.git diff --git a/test/hints_test.cc b/test/hints_test.cc index c228cd07a..5e59ef924 100644 --- a/test/hints_test.cc +++ b/test/hints_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020-2021 Carl Hetherington + Copyright (C) 2020-2022 Carl Hetherington This file is part of DCP-o-matic. @@ -20,6 +20,8 @@ #include "lib/audio_content.h" +#include "lib/config.h" +#include "lib/constants.h" #include "lib/content.h" #include "lib/content_factory.h" #include "lib/cross.h" @@ -27,7 +29,6 @@ #include "lib/font.h" #include "lib/hints.h" #include "lib/text_content.h" -#include "lib/util.h" #include "test.h" #include @@ -62,6 +63,7 @@ get_hints (shared_ptr film) hints.start (); hints.join (); while (signal_manager->ui_idle()) {} + hints.rethrow(); return current_hints; } @@ -71,7 +73,7 @@ void check (TextType type, string name, optional expected_hint = optional()) { auto film = new_test_film2 (name); - auto content = content_factory("test/data/" + name + ".srt").front(); + auto content = content_factory("test/data/" + name + ".srt")[0]; content->text.front()->set_type (type); content->text.front()->set_language (dcp::LanguageTag("en-US")); film->examine_and_add_content (content); @@ -82,7 +84,11 @@ check (TextType type, string name, optional expected_hint = optional 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(); + auto content = content_factory("test/data/" + name + ".srt")[0]; 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(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); @@ -199,18 +214,18 @@ 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(); + auto content = content_factory("build/test/" + name + ".srt")[0]; content->text.front()->set_type (TextType::CLOSED_CAPTION); content->text.front()->set_language (dcp::LanguageTag("en-US")); film->examine_and_add_content (content); @@ -229,7 +244,7 @@ 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(); + auto content = content_factory(TestPaths::private_data() / "boon_telly.mkv")[0]; film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -243,7 +258,7 @@ BOOST_AUTO_TEST_CASE (hints_destroyed_while_running) BOOST_AUTO_TEST_CASE (hints_audio_with_no_language) { - auto content = content_factory("test/data/sine_440.wav").front(); + auto content = content_factory("test/data/sine_440.wav")[0]; auto film = new_test_film2 ("hints_audio_with_no_language", { content }); content->audio->set_gain (-6); @@ -254,6 +269,24 @@ BOOST_AUTO_TEST_CASE (hints_audio_with_no_language) "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." ); +} + +BOOST_AUTO_TEST_CASE (hints_certificate_validity) +{ + ConfigRestorer cr; + + Config::instance()->set_signer_chain(make_shared(openssl_path(), 40 * 365)); + + auto film = new_test_film2 ("hints_certificate_validity"); + auto hints = get_hints (film); + BOOST_REQUIRE_EQUAL (hints.size(), 1U); + BOOST_CHECK_EQUAL ( + hints[0], + "The certificate chain that DCP-o-matic uses for signing DCPs and KDMs has a validity period " + "that is too long. This will cause problems playing back DCPs on some systems. " + "You are advised to re-create the signing certificate chain by clicking the " + "\"Re-make certificates and key...\" button in the Keys page of Preferences." + ); }