2 Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 /** @file test/film_metadata_test.cc
23 * @brief Test some basic reading/writing of film metadata.
28 #include "lib/content.h"
29 #include "lib/content_factory.h"
30 #include "lib/dcp_content.h"
31 #include "lib/dcp_content_type.h"
33 #include "lib/ratio.h"
34 #include "lib/text_content.h"
36 #include <boost/date_time.hpp>
37 #include <boost/filesystem.hpp>
38 #include <boost/test/unit_test.hpp>
43 using std::make_shared;
44 using std::shared_ptr;
47 BOOST_AUTO_TEST_CASE (film_metadata_test)
49 auto film = new_test_film ("film_metadata_test");
50 auto dir = test_film_dir ("film_metadata_test");
52 film->_isdcf_date = boost::gregorian::from_undelimited_string ("20130211");
53 BOOST_CHECK (film->container() == Ratio::from_id ("185"));
54 BOOST_CHECK (film->dcp_content_type() == 0);
56 film->set_name ("fred");
57 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("SHR"));
58 film->set_container (Ratio::from_id ("185"));
59 film->set_j2k_bandwidth (200000000);
60 film->set_interop (false);
61 film->set_chain (string(""));
62 film->set_distributor (string(""));
63 film->set_facility (string(""));
64 film->set_release_territory (dcp::LanguageTag::RegionSubtag("US"));
65 film->write_metadata ();
67 list<string> ignore = { "Key", "ContextID" };
68 check_xml ("test/data/metadata.xml.ref", dir.string() + "/metadata.xml", ignore);
70 auto g = make_shared<Film>(dir);
73 BOOST_CHECK_EQUAL (g->name(), "fred");
74 BOOST_CHECK_EQUAL (g->dcp_content_type(), DCPContentType::from_isdcf_name ("SHR"));
75 BOOST_CHECK_EQUAL (g->container(), Ratio::from_id ("185"));
78 check_xml ("test/data/metadata.xml.ref", dir.string() + "/metadata.xml", ignore);
82 /** Check a bug where <Content> tags with multiple <Text>s would fail to load */
83 BOOST_AUTO_TEST_CASE (multiple_text_nodes_are_allowed)
85 auto subs = content_factory("test/data/15s.srt").front();
86 auto caps = content_factory("test/data/15s.srt").front();
87 auto film = new_test_film2("multiple_text_nodes_are_allowed1", { subs, caps });
88 caps->only_text()->set_type(TextType::CLOSED_CAPTION);
92 dcp::VerificationNote::Code::MISSING_CPL_METADATA,
93 dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
94 dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME
97 auto reload = make_shared<DCPContent>(film->dir(film->dcp_name()));
98 auto film2 = new_test_film2("multiple_text_nodes_are_allowed2", { reload });
99 film2->write_metadata ();
101 auto test = make_shared<Film>(boost::filesystem::path("build/test/multiple_text_nodes_are_allowed2"));
102 test->read_metadata();