From 422c8a63d2368a2e63aee4c391207e3332d1d4c7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 22 Aug 2012 18:03:18 +0100 Subject: More subs tests. --- test/data/subs1.xml | 27 +++++ test/data/subs2.xml | 82 +++++++++++++ test/ref/subs.xml | 27 ----- test/tests.cc | 329 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 426 insertions(+), 39 deletions(-) create mode 100644 test/data/subs1.xml create mode 100755 test/data/subs2.xml delete mode 100644 test/ref/subs.xml (limited to 'test') diff --git a/test/data/subs1.xml b/test/data/subs1.xml new file mode 100644 index 00000000..515dd9f7 --- /dev/null +++ b/test/data/subs1.xml @@ -0,0 +1,27 @@ + + + cab5c268-222b-41d2-88ae-6d6999441b17 + Movie Title + 1 + French + + + + My jacket was Idi Amin's + + + + My corset was H.M. The Queen's + + My large wonderbra + + + + + Once belonged to the Shah + + + And these are Roy Hattersley's jeans + + + diff --git a/test/data/subs2.xml b/test/data/subs2.xml new file mode 100755 index 00000000..c0001b06 --- /dev/null +++ b/test/data/subs2.xml @@ -0,0 +1,82 @@ + + + notusedforthstest + notusedforthistest + subs2 test + 1 + + + + + At afternoon tea with John Peel + + + I enquired if his accent was real + + + + + He said "out of the house + + + I'm incredibly scouse + + + + + At home it depends how I feel." + + + I spent a long weekend in Brighton + + + + + With the legendary Miss Enid Blyton + + + She said "you be Noddy + + + + + and I'll show you my body" + + + But Big Ears kept turning the light on. + + + + + That curious creature the Sphinx + + + Is smarter than anyone thinks + + + + It sits there and smirks + And you don't think it works + + + Then when you're not looking, it winks. + When it snows you will find Sister Sledge + + + Out mooning, at night, on the ledge + One storey down + + + Is the maestro, James Brown + Displaying his meat and two veg. + + + + HELLO + + + WORLD + + + + diff --git a/test/ref/subs.xml b/test/ref/subs.xml deleted file mode 100644 index 515dd9f7..00000000 --- a/test/ref/subs.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - cab5c268-222b-41d2-88ae-6d6999441b17 - Movie Title - 1 - French - - - - My jacket was Idi Amin's - - - - My corset was H.M. The Queen's - - My large wonderbra - - - - - Once belonged to the Shah - - - And these are Roy Hattersley's jeans - - - diff --git a/test/tests.cc b/test/tests.cc index fa6ba8e0..43c95905 100644 --- a/test/tests.cc +++ b/test/tests.cc @@ -111,9 +111,9 @@ BOOST_AUTO_TEST_CASE (read_dcp) BOOST_CHECK_EQUAL (d.length(), 24); } -BOOST_AUTO_TEST_CASE (subtitles) +BOOST_AUTO_TEST_CASE (subtitles1) { - libdcp::SubtitleAsset subs ("test/ref", "subs.xml"); + libdcp::SubtitleAsset subs ("test/data", "subs1.xml"); BOOST_CHECK_EQUAL (subs.language(), "French"); @@ -131,8 +131,8 @@ BOOST_AUTO_TEST_CASE (subtitles) "My jacket was Idi Amin's", libdcp::BORDER, libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 20), - libdcp::Time (0, 0, 0, 20) + libdcp::Time (0, 0, 0, 1), + libdcp::Time (0, 0, 0, 1) )); s = subs.subtitles_at (libdcp::Time (0, 0, 7, 190)); @@ -149,8 +149,8 @@ BOOST_AUTO_TEST_CASE (subtitles) "My corset was H.M. The Queen's", libdcp::BORDER, libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 20), - libdcp::Time (0, 0, 0, 20) + libdcp::Time (0, 0, 0, 1), + libdcp::Time (0, 0, 0, 1) )); BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( "Arial", @@ -164,8 +164,8 @@ BOOST_AUTO_TEST_CASE (subtitles) "My large wonderbra", libdcp::BORDER, libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 20), - libdcp::Time (0, 0, 0, 20) + libdcp::Time (0, 0, 0, 1), + libdcp::Time (0, 0, 0, 1) )); s = subs.subtitles_at (libdcp::Time (0, 0, 11, 95)); @@ -182,8 +182,8 @@ BOOST_AUTO_TEST_CASE (subtitles) "Once belonged to the Shah", libdcp::BORDER, libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 20), - libdcp::Time (0, 0, 0, 20) + libdcp::Time (0, 0, 0, 1), + libdcp::Time (0, 0, 0, 1) )); s = subs.subtitles_at (libdcp::Time (0, 0, 14, 42)); @@ -200,11 +200,316 @@ BOOST_AUTO_TEST_CASE (subtitles) "And these are Roy Hattersley's jeans", libdcp::BORDER, libdcp::Color (0, 0, 0), - libdcp::Time (0, 0, 0, 20), - libdcp::Time (0, 0, 0, 20) + libdcp::Time (0, 0, 0, 1), + libdcp::Time (0, 0, 0, 1) )); } +BOOST_AUTO_TEST_CASE (subtitles2) +{ + libdcp::SubtitleAsset subs ("test/data", "subs2.xml"); + + list > s = subs.subtitles_at (libdcp::Time (0, 0, 42, 100)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 0, 41, 62), + libdcp::Time (0, 0, 43, 52), + 89, + libdcp::TOP, + "At afternoon tea with John Peel", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 0, 41, 62), + libdcp::Time (0, 0, 43, 52), + 95, + libdcp::TOP, + "I enquired if his accent was real", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 0, 50, 50)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 0, 50, 42), + libdcp::Time (0, 0, 52, 21), + 89, + libdcp::TOP, + "He said \"out of the house", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 0, 50, 42), + libdcp::Time (0, 0, 52, 21), + 95, + libdcp::TOP, + "I'm incredibly scouse", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 1, 2, 300)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 2, 208), + libdcp::Time (0, 1, 4, 10), + 89, + libdcp::TOP, + "At home it depends how I feel.\"", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 2, 208), + libdcp::Time (0, 1, 4, 10), + 95, + libdcp::TOP, + "I spent a long weekend in Brighton", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 1, 15, 50)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 15, 42), + libdcp::Time (0, 1, 16, 42), + 89, + libdcp::TOP, + "With the legendary Miss Enid Blyton", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 15, 42), + libdcp::Time (0, 1, 16, 42), + 95, + libdcp::TOP, + "She said \"you be Noddy", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 1, 27, 200)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 27, 115), + libdcp::Time (0, 1, 28, 208), + 89, + libdcp::TOP, + "That curious creature the Sphinx", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 27, 115), + libdcp::Time (0, 1, 28, 208), + 95, + libdcp::TOP, + "Is smarter than anyone thinks", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 1, 42, 300)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + false, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 42, 229), + libdcp::Time (0, 1, 45, 62), + 89, + libdcp::TOP, + "It sits there and smirks", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + false, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 42, 229), + libdcp::Time (0, 1, 45, 62), + 95, + libdcp::TOP, + "And you don't think it works", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 1, 45, 200)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + false, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 45, 146), + libdcp::Time (0, 1, 47, 94), + 89, + libdcp::TOP, + "Then when you're not looking, it winks.", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + false, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 45, 146), + libdcp::Time (0, 1, 47, 94), + 95, + libdcp::TOP, + "When it snows you will find Sister Sledge", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 1, 47, 249)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + false, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 47, 146), + libdcp::Time (0, 1, 48, 167), + 89, + libdcp::TOP, + "Out mooning, at night, on the ledge", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + false, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 1, 47, 146), + libdcp::Time (0, 1, 48, 167), + 95, + libdcp::TOP, + "One storey down", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + s = subs.subtitles_at (libdcp::Time (0, 2, 6, 210)); + BOOST_CHECK_EQUAL (s.size(), 2); + BOOST_CHECK_EQUAL (*(s.front().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 2, 5, 208), + libdcp::Time (0, 2, 7, 31), + 89, + libdcp::TOP, + "HELLO", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + BOOST_CHECK_EQUAL (*(s.back().get()), libdcp::Subtitle ( + "Arial", + true, + libdcp::Color (255, 255, 255), + 42, + libdcp::Time (0, 2, 5, 208), + libdcp::Time (0, 2, 7, 31), + 95, + libdcp::TOP, + "WORLD", + libdcp::BORDER, + libdcp::Color (0, 0, 0), + libdcp::Time (0, 0, 0, 0), + libdcp::Time (0, 0, 0, 0) + )); + + + +} + BOOST_AUTO_TEST_CASE (dcp_time) { libdcp::Time t (977143, 24); -- cgit v1.2.3