X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fread_smpte_subtitle_test.cc;h=49fd1f6271c25f3f6b28d593a930efb77f13992f;hb=b0b3c6f0cdc034ef515f72d72fd72fbb71d1ca63;hp=2aadc2dcc8fd1906a102fd1a7917192d9f38dd9f;hpb=3e24098b32d6160759378e671bfca241dd9025d9;p=libdcp.git diff --git a/test/read_smpte_subtitle_test.cc b/test/read_smpte_subtitle_test.cc index 2aadc2dc..49fd1f62 100644 --- a/test/read_smpte_subtitle_test.cc +++ b/test/read_smpte_subtitle_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of libdcp. @@ -15,19 +15,35 @@ You should have received a copy of the GNU General Public License along with libdcp. If not, see . + + In addition, as a special exception, the copyright holders give + permission to link the code of portions of this program with the + OpenSSL library under certain conditions as described in each + individual source file, and distribute linked combinations + including the two. + + You must obey the GNU General Public License in all respects + for all of the code used other than OpenSSL. If you modify + file(s) with this exception, you may extend this exception to your + version of the file(s), but you are not obligated to do so. If you + do not wish to do so, delete this exception statement from your + version. If you delete this exception statement from all source + files in the program, then also delete it here. */ #include "smpte_subtitle_asset.h" #include "test.h" #include "local_time.h" #include "smpte_load_font_node.h" +#include "subtitle_image.h" +#include "stream_operators.h" #include #include #include using std::list; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; +using std::shared_ptr; +using std::dynamic_pointer_cast; /** Check reading of a SMPTE subtitle file */ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test) @@ -51,19 +67,21 @@ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test) BOOST_CHECK_EQUAL (sc.edit_rate(), dcp::Fraction (25, 1)); BOOST_CHECK_EQUAL (sc.time_code_rate(), 25); BOOST_CHECK_EQUAL (sc.start_time(), dcp::Time (0, 0, 0, 0, 25)); - list > lfn = sc.load_font_nodes (); + auto lfn = sc.load_font_nodes (); BOOST_REQUIRE_EQUAL (lfn.size(), 1); shared_ptr smpte_lfn = dynamic_pointer_cast (lfn.front ()); BOOST_REQUIRE (smpte_lfn); BOOST_CHECK_EQUAL (smpte_lfn->id, "theFontId"); BOOST_CHECK_EQUAL (smpte_lfn->urn, "9118bbce-4105-4a05-b37c-a5a6f75e1fea"); BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 63); - BOOST_CHECK_EQUAL (sc.subtitles().front().text(), "Noch mal."); - BOOST_CHECK_EQUAL (sc.subtitles().front().in(), dcp::Time (0, 0, 25, 12, 25)); - BOOST_CHECK_EQUAL (sc.subtitles().front().out(), dcp::Time (0, 0, 26, 4, 25)); - BOOST_CHECK_EQUAL (sc.subtitles().back().text(), "Prochainement"); - BOOST_CHECK_EQUAL (sc.subtitles().back().in(), dcp::Time (0, 1, 57, 17, 25)); - BOOST_CHECK_EQUAL (sc.subtitles().back().out(), dcp::Time (0, 1, 58, 12, 25)); + BOOST_REQUIRE (dynamic_pointer_cast(sc.subtitles().front())); + BOOST_CHECK_EQUAL (dynamic_pointer_cast(sc.subtitles().front())->text(), "Noch mal."); + BOOST_CHECK_EQUAL (sc.subtitles().front()->in(), dcp::Time (0, 0, 25, 12, 25)); + BOOST_CHECK_EQUAL (sc.subtitles().front()->out(), dcp::Time (0, 0, 26, 4, 25)); + BOOST_REQUIRE (dynamic_pointer_cast(sc.subtitles().back())); + BOOST_CHECK_EQUAL (dynamic_pointer_cast(sc.subtitles().back())->text(), "Prochainement"); + BOOST_CHECK_EQUAL (sc.subtitles().back()->in(), dcp::Time (0, 1, 57, 17, 25)); + BOOST_CHECK_EQUAL (sc.subtitles().back()->out(), dcp::Time (0, 1, 58, 12, 25)); } /** And another one featuring within */ @@ -71,23 +89,47 @@ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test2) { dcp::SMPTESubtitleAsset sc (private_test / "olsson.xml"); - BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 6); - list::const_iterator i = sc.subtitles().begin(); - BOOST_CHECK_EQUAL (i->text(), "Testing is "); - BOOST_CHECK (!i->italic()); + auto subs = sc.subtitles(); + BOOST_REQUIRE_EQUAL (subs.size(), 6); + auto i = 0; + auto is = dynamic_pointer_cast(subs[i]); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "Testing is "); + BOOST_CHECK (!is->italic()); ++i; - BOOST_CHECK_EQUAL (i->text(), "really"); - BOOST_CHECK (i->italic()); + is = dynamic_pointer_cast(subs[i]); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "really"); + BOOST_CHECK (is->italic()); ++i; - BOOST_CHECK_EQUAL (i->text(), " fun!"); - BOOST_CHECK (!i->italic()); + is = dynamic_pointer_cast(subs[i]); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), " fun!"); + BOOST_CHECK (!is->italic()); ++i; - BOOST_CHECK_EQUAL (i->text(), "This is the "); - BOOST_CHECK (!i->italic()); + is = dynamic_pointer_cast(subs[i]); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "This is the "); + BOOST_CHECK (!is->italic()); ++i; - BOOST_CHECK_EQUAL (i->text(), "second"); - BOOST_CHECK (i->italic()); + is = dynamic_pointer_cast(subs[i]); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), "second"); + BOOST_CHECK (is->italic()); ++i; - BOOST_CHECK_EQUAL (i->text(), " line!"); - BOOST_CHECK (!i->italic()); + is = dynamic_pointer_cast(subs[i]); + BOOST_REQUIRE (is); + BOOST_CHECK_EQUAL (is->text(), " line!"); + BOOST_CHECK (!is->italic()); +} + +/** And another one featuring image subtitles */ +BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test3) +{ + dcp::SMPTESubtitleAsset subs ("test/data/subs.mxf"); + + BOOST_REQUIRE_EQUAL (subs.subtitles().size(), 1); + auto si = dynamic_pointer_cast(subs.subtitles()[0]); + BOOST_REQUIRE (si); + BOOST_CHECK (si->png_image() == dcp::ArrayData("test/data/sub.png")); }