X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fsubtitle_font_id_change_test.cc;h=37880382833e8cffbb7aeb6bfdc2cb0ea260b910;hb=7c6e1bcdaf52d6167631dbf9b1612e80356391c4;hp=32cf57400c0a33475418ab8e521379b05979840e;hpb=14e02ad2f79bdc6fbc320ec7b9282b5faabdb825;p=dcpomatic.git diff --git a/test/subtitle_font_id_change_test.cc b/test/subtitle_font_id_change_test.cc index 32cf57400..378803828 100644 --- a/test/subtitle_font_id_change_test.cc +++ b/test/subtitle_font_id_change_test.cc @@ -38,37 +38,6 @@ using std::string; -class Editor -{ -public: - Editor (boost::filesystem::path path) - : _path(path) - , _content(dcp::file_to_string(path)) - { - - } - - ~Editor () - { - auto f = fopen(_path.string().c_str(), "w"); - BOOST_REQUIRE(f); - fwrite(_content.c_str(), _content.length(), 1, f); - fclose(f); - } - - void replace (string a, string b) - { - auto old_content = _content; - boost::algorithm::replace_all (_content, a, b); - BOOST_REQUIRE (_content != old_content); - } - -private: - boost::filesystem::path _path; - std::string _content; -}; - - BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test1) { auto film = new_test_film2("subtitle_font_id_change_test1"); @@ -84,6 +53,7 @@ BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test1) CheckContentJob check(film); check.run(); + BOOST_REQUIRE (!wait_for_jobs()); make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_STANDARD }); } @@ -105,9 +75,14 @@ BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test2) BOOST_REQUIRE_EQUAL(content[0]->text.size(), 1U); content[0]->set_paths({"test/data/short.srt"}); + /* Make sure the content doesn't look like it's changed, otherwise it will be re-examined + * which obscures the point of this test. + */ + content[0]->_last_write_times[0] = boost::filesystem::last_write_time("test/data/short.srt"); CheckContentJob check(film); check.run(); + BOOST_REQUIRE (!wait_for_jobs()); auto font = content[0]->text.front()->get_font(""); BOOST_REQUIRE(font->file()); @@ -136,14 +111,47 @@ BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test3) CheckContentJob check(film); check.run(); + BOOST_REQUIRE (!wait_for_jobs()); auto font = content[0]->text.front()->get_font("Arial Black"); + BOOST_REQUIRE(font); BOOST_REQUIRE(font->file()); BOOST_CHECK_EQUAL(*font->file(), "test/data/Inconsolata-VF.ttf"); font = content[0]->text.front()->get_font("Helvetica Neue"); + BOOST_REQUIRE(font); BOOST_REQUIRE(font->file()); BOOST_CHECK_EQUAL(*font->file(), "test/data/Inconsolata-VF.ttf"); make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_STANDARD }); } + + +BOOST_AUTO_TEST_CASE(subtitle_font_id_change_test4) +{ + Cleanup cl; + + auto film = new_test_film2("subtitle_font_id_change_test4", {}, &cl); + boost::filesystem::remove(film->file("metadata.xml")); + boost::filesystem::copy_file("test/data/subtitle_font_id_change_test4.xml", film->file("metadata.xml")); + + { + Editor editor(film->file("metadata.xml")); + editor.replace("dcpomatic-test-private", TestPaths::private_data().string()); + } + + film->read_metadata(); + + auto content = film->content(); + BOOST_REQUIRE_EQUAL(content.size(), 1U); + BOOST_REQUIRE_EQUAL(content[0]->text.size(), 1U); + + CheckContentJob check(film); + check.run(); + BOOST_REQUIRE(!wait_for_jobs()); + + make_and_verify_dcp(film, { dcp::VerificationNote::Code::INVALID_STANDARD }); + + cl.run(); +} +