From e0a70cd5cfb11fc2de167f3146acdd437a6faa82 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 23 Mar 2021 00:50:11 +0100 Subject: Put subtitle language back into content from the film (#1930). This also adds the main/additional language flag. Of all the considerations about how to specify subtitle language, the most important seems to be that the language specification happens for the content where the language is; i.e. in the content text tab. --- test/isdcf_name_test.cc | 2 +- test/subtitle_language_test.cc | 19 +++++++++---------- test/subtitle_metadata_test.cc | 33 +++++++-------------------------- 3 files changed, 17 insertions(+), 37 deletions(-) (limited to 'test') diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc index dad2ba7d9..59d8ec1b0 100644 --- a/test/isdcf_name_test.cc +++ b/test/isdcf_name_test.cc @@ -74,10 +74,10 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) film->_isdcf_date = boost::gregorian::date (2014, boost::gregorian::Jul, 4); film->set_audio_channels (1); film->set_resolution (Resolution::FOUR_K); - film->set_subtitle_language (dcp::LanguageTag("fr-FR")); shared_ptr text = content_factory("test/data/subrip.srt").front(); BOOST_REQUIRE_EQUAL (text->text.size(), 1U); text->text.front()->set_burn (true); + text->text.front()->set_language (dcp::LanguageTag("fr-FR")); film->examine_and_add_content (text); BOOST_REQUIRE (!wait_for_jobs()); m.content_version = 2; diff --git a/test/subtitle_language_test.cc b/test/subtitle_language_test.cc index f0f2ad162..af5dee001 100644 --- a/test/subtitle_language_test.cc +++ b/test/subtitle_language_test.cc @@ -18,13 +18,16 @@ */ + /** @file test/subtitle_language_test.cc * @brief Test that subtitle language information is correctly written to DCPs. */ +#include "lib/content.h" #include "lib/content_factory.h" #include "lib/film.h" +#include "lib/text_content.h" #include "test.h" #include #include @@ -39,12 +42,10 @@ using std::shared_ptr; BOOST_AUTO_TEST_CASE (subtitle_language_interop_test) { string const name = "subtitle_language_interop_test"; - auto film = new_test_film2 (name, { content_factory("test/data/frames.srt").front() }); + auto fr = content_factory("test/data/frames.srt").front(); + auto film = new_test_film2 (name, { fr }); - vector langs = { - dcp::LanguageTag("fr-FR"), dcp::LanguageTag("de-DE") - }; - film->set_subtitle_languages(langs); + fr->only_text()->set_language (dcp::LanguageTag("fr-FR")); film->set_interop (true); make_and_verify_dcp ( @@ -62,12 +63,10 @@ BOOST_AUTO_TEST_CASE (subtitle_language_interop_test) BOOST_AUTO_TEST_CASE (subtitle_language_smpte_test) { string const name = "subtitle_language_smpte_test"; - auto film = new_test_film2 (name, { content_factory("test/data/frames.srt").front() }); + auto fr = content_factory("test/data/frames.srt").front(); + auto film = new_test_film2 (name, { fr }); - vector langs = { - dcp::LanguageTag("fr-FR"), dcp::LanguageTag("de-DE") - }; - film->set_subtitle_languages (langs); + fr->only_text()->set_language (dcp::LanguageTag("fr-FR")); film->set_interop (false); make_and_verify_dcp ( diff --git a/test/subtitle_metadata_test.cc b/test/subtitle_metadata_test.cc index 6eaa77100..91372d2a5 100644 --- a/test/subtitle_metadata_test.cc +++ b/test/subtitle_metadata_test.cc @@ -30,46 +30,27 @@ #include -using std::vector; +using std::make_shared; using std::shared_ptr; +using std::vector; BOOST_AUTO_TEST_CASE (subtitle_metadata_test1) { using namespace boost::filesystem; - path p = test_film_dir ("subtitle_metadata_test1"); + auto p = test_film_dir ("subtitle_metadata_test1"); if (exists (p)) { remove_all (p); } create_directory (p); copy_file ("test/data/subtitle_metadata1.xml", p / "metadata.xml"); - shared_ptr film(new Film(p)); - film->read_metadata(); - - vector langs = film->subtitle_languages (); - BOOST_REQUIRE (!langs.empty()); - BOOST_CHECK_EQUAL (langs.front().to_string(), "de-DE"); -} - - -BOOST_AUTO_TEST_CASE (subtitle_metadata_test2) -{ - using namespace boost::filesystem; - - path p = test_film_dir ("subtitle_metadata_test2"); - if (exists (p)) { - remove_all (p); - } - create_directory (p); - - copy_file ("test/data/subtitle_metadata2.xml", p / "metadata.xml"); - shared_ptr film(new Film(p)); + auto film = make_shared(p); film->read_metadata(); - vector langs = film->subtitle_languages (); - BOOST_REQUIRE (!langs.empty()); - BOOST_CHECK_EQUAL (langs.front().to_string(), "FR"); + auto langs = film->subtitle_languages (); + BOOST_REQUIRE (langs.first); + BOOST_CHECK_EQUAL (langs.first->to_string(), "de-DE"); } -- cgit v1.2.3