2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "smpte_subtitle_asset.h"
22 #include "local_time.h"
23 #include "smpte_load_font_node.h"
24 #include <boost/test/unit_test.hpp>
27 using boost::shared_ptr;
28 using boost::dynamic_pointer_cast;
30 /** Check reading of a SMPTE subtitle file */
31 BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test)
33 dcp::SMPTESubtitleAsset sc (private_test / "8dfafe11-2bd1-4206-818b-afc109cfe7f6_reel1.xml", false);
35 BOOST_CHECK_EQUAL (sc.id(), "8dfafe11-2bd1-4206-818b-afc109cfe7f6");
36 BOOST_CHECK_EQUAL (sc.content_title_text(), "Violet");
37 BOOST_REQUIRE (sc.annotation_text());
38 BOOST_CHECK_EQUAL (sc.annotation_text().get(), "Violet");
39 BOOST_CHECK_EQUAL (sc.issue_date(), dcp::LocalTime ("2014-12-23T22:30:07.000-00:00"));
40 BOOST_REQUIRE (sc.reel_number());
41 BOOST_CHECK_EQUAL (sc.reel_number().get(), 1);
42 BOOST_REQUIRE (sc.language ());
43 BOOST_CHECK_EQUAL (sc.language().get (), "Dutch");
44 BOOST_CHECK_EQUAL (sc.edit_rate(), dcp::Fraction (24, 1));
45 BOOST_CHECK_EQUAL (sc.time_code_rate(), 24);
46 BOOST_CHECK_EQUAL (sc.start_time(), dcp::Time (0, 0, 0, 23, 24));
47 list<shared_ptr<dcp::LoadFontNode> > lfn = sc.load_font_nodes ();
48 BOOST_REQUIRE_EQUAL (lfn.size(), 1);
49 shared_ptr<dcp::SMPTELoadFontNode> smpte_lfn = dynamic_pointer_cast<dcp::SMPTELoadFontNode> (lfn.front ());
50 BOOST_REQUIRE (smpte_lfn);
51 BOOST_CHECK_EQUAL (smpte_lfn->id, "theFontId");
52 BOOST_CHECK_EQUAL (smpte_lfn->urn, "3dec6dc0-39d0-498d-97d0-928d2eb78391");
53 BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 159);
54 BOOST_CHECK_EQUAL (sc.subtitles().front().text(), "Jonas ?");
55 BOOST_CHECK_EQUAL (sc.subtitles().front().in(), dcp::Time (0, 7, 6, 20, 24));
56 BOOST_CHECK_EQUAL (sc.subtitles().front().out(), dcp::Time (0, 7, 7, 20, 24));
57 BOOST_CHECK_EQUAL (sc.subtitles().back().text(), "Come on.");
58 BOOST_CHECK_EQUAL (sc.subtitles().back().in(), dcp::Time (1, 13, 37, 11, 24));
59 BOOST_CHECK_EQUAL (sc.subtitles().back().out(), dcp::Time (1, 13, 38, 11, 24));