/* Copyright (C) 2015-2016 Carl Hetherington This file is part of libdcp. libdcp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. libdcp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libdcp. If not, see . */ #include "interop_subtitle_asset.h" #include "smpte_subtitle_asset.h" #include "subtitle_string.h" #include "test.h" #include using std::list; using std::string; using boost::shared_ptr; /* Write some subtitle content as Interop XML and check that it is right */ BOOST_AUTO_TEST_CASE (write_interop_subtitle_test) { dcp::InteropSubtitleAsset c; c.set_reel_number ("1"); c.set_language ("EN"); c.set_movie_title ("Test"); c.add ( dcp::SubtitleString ( string ("Frutiger"), false, false, false, dcp::Colour (255, 255, 255), 48, 1.0, dcp::Time (0, 4, 9, 22, 24), dcp::Time (0, 4, 11, 22, 24), 0, dcp::HALIGN_CENTER, 0.8, dcp::VALIGN_TOP, dcp::DIRECTION_LTR, "Hello world", dcp::NONE, dcp::Colour (0, 0, 0), dcp::Time (0, 0, 0, 0, 24), dcp::Time (0, 0, 0, 0, 24) ) ); c.add ( dcp::SubtitleString ( boost::optional (), true, true, true, dcp::Colour (128, 0, 64), 91, 1.0, dcp::Time (5, 41, 0, 21, 24), dcp::Time (6, 12, 15, 21, 24), 0, dcp::HALIGN_CENTER, 0.4, dcp::VALIGN_BOTTOM, dcp::DIRECTION_LTR, "What's going on", dcp::BORDER, dcp::Colour (1, 2, 3), dcp::Time (1, 2, 3, 4, 24), dcp::Time (5, 6, 7, 8, 24) ) ); c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6"; check_xml ( c.xml_as_string (), "\n" " a6c58cff-3e1e-4b38-acec-a42224475ef6\n" " Test\n" " 1\n" " EN\n" " \n" " \n" " Hello world\n" " \n" " \n" " \n" " \n" " What's going on\n" " \n" " \n" "", list () ); } /* Write some subtitle content as SMPTE XML and check that it is right */ BOOST_AUTO_TEST_CASE (write_smpte_subtitle_test) { dcp::SMPTESubtitleAsset c; c.set_reel_number (1); c.set_language ("EN"); c.set_content_title_text ("Test"); c.set_issue_date (dcp::LocalTime ("2016-04-01T03:52:00+00:00")); c.add ( dcp::SubtitleString ( string ("Frutiger"), false, false, false, dcp::Colour (255, 255, 255), 48, 1.0, dcp::Time (0, 4, 9, 22, 24), dcp::Time (0, 4, 11, 22, 24), 0, dcp::HALIGN_CENTER, 0.8, dcp::VALIGN_TOP, dcp::DIRECTION_LTR, "Hello world", dcp::NONE, dcp::Colour (0, 0, 0), dcp::Time (0, 0, 0, 0, 24), dcp::Time (0, 0, 0, 0, 24) ) ); c.add ( dcp::SubtitleString ( boost::optional (), true, true, true, dcp::Colour (128, 0, 64), 91, 1.0, dcp::Time (5, 41, 0, 21, 24), dcp::Time (6, 12, 15, 21, 24), 0, dcp::HALIGN_CENTER, 0.4, dcp::VALIGN_BOTTOM, dcp::DIRECTION_RTL, "What's going on", dcp::BORDER, dcp::Colour (1, 2, 3), dcp::Time (1, 2, 3, 4, 24), dcp::Time (5, 6, 7, 8, 24) ) ); c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6"; check_xml ( c.xml_as_string (), "\n" "\n" " urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6\n" " Test\n" " 2016-04-01T03:52:00.000+00:00\n" " 1\n" " EN\n" " 24 1\n" " 24\n" " \n" " \n" " \n" " Hello world\n" " \n" " \n" " \n" " \n" " What's going on\n" " \n" " \n" " \n" "\n", list () ); }