summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-04-12 01:37:00 +0100
committerCarl Hetherington <cth@carlh.net>2016-04-12 01:37:00 +0100
commit4b8c626b7e66ab1d4d69606e10316542c8873842 (patch)
tree94140f93b3911196ab60866fefb5c9f807a7a2ab /test
parent4b8eee1359d817937b84df7e88126fa16040e5c9 (diff)
Add direction support for SMPTE subtitles; fix pragma warnings with non-openmp builds.
Diffstat (limited to 'test')
-rwxr-xr-xtest/data/subs2.xml6
-rw-r--r--test/make_digest_test.cc11
-rw-r--r--test/read_interop_subtitle_test.cc23
-rw-r--r--test/write_subtitle_test.cc92
4 files changed, 117 insertions, 15 deletions
diff --git a/test/data/subs2.xml b/test/data/subs2.xml
index c0001b06..a6ec2338 100755
--- a/test/data/subs2.xml
+++ b/test/data/subs2.xml
@@ -32,10 +32,10 @@
</Subtitle>
<Subtitle SpotNumber="4" TimeIn="00:01:15:042" TimeOut="00:01:16:042" FadeUpTime="0" FadeDownTime="0">
<Font Italic="yes">
- <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">With the legendary Miss Enid Blyton</Text>
+ <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5" Direction="rtl">With the legendary Miss Enid Blyton</Text>
</Font>
<Font Italic="yes">
- <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">She said "you be Noddy</Text>
+ <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5" Direction="ttb">She said "you be Noddy</Text>
</Font>
</Subtitle>
<Subtitle SpotNumber="5" TimeIn="00:01:20:219" TimeOut="00:01:22:073" FadeUpTime="0" FadeDownTime="0">
@@ -48,7 +48,7 @@
</Subtitle>
<Subtitle SpotNumber="6" TimeIn="00:01:27:115" TimeOut="00:01:28:208" FadeUpTime="0" FadeDownTime="0">
<Font Italic="yes">
- <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">That curious creature the Sphinx</Text>
+ <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5" Direction="btt">That curious creature the Sphinx</Text>
</Font>
<Font Italic="yes">
<Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">Is smarter than anyone thinks</Text>
diff --git a/test/make_digest_test.cc b/test/make_digest_test.cc
index 4614911e..b7e18a12 100644
--- a/test/make_digest_test.cc
+++ b/test/make_digest_test.cc
@@ -22,7 +22,6 @@
#include <boost/bind.hpp>
#include <boost/test/unit_test.hpp>
#include <sys/time.h>
-#include <iostream>
void progress (float)
{
@@ -43,13 +42,5 @@ BOOST_AUTO_TEST_CASE (make_digest_test)
data.write ("build/test/random");
/* Hash it */
- struct timeval A;
- gettimeofday (&A, 0);
- for (int i = 0; i < 64; ++i) {
- BOOST_CHECK_EQUAL (dcp::make_digest ("build/test/random", boost::bind (&progress, _1)), "GKbk/V3fcRtP5MaPdSmAGNbKkaU=");
- }
- struct timeval B;
- gettimeofday (&B, 0);
-
- std::cout << ((B.tv_sec + B.tv_usec / 1e6) - (A.tv_sec + A.tv_usec / 1e6)) << "\n";
+ BOOST_CHECK_EQUAL (dcp::make_digest ("build/test/random", boost::bind (&progress, _1)), "GKbk/V3fcRtP5MaPdSmAGNbKkaU=");
}
diff --git a/test/read_interop_subtitle_test.cc b/test/read_interop_subtitle_test.cc
index 7822d47e..8640b7ef 100644
--- a/test/read_interop_subtitle_test.cc
+++ b/test/read_interop_subtitle_test.cc
@@ -59,6 +59,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
dcp::HALIGN_CENTER,
0.15,
dcp::VALIGN_BOTTOM,
+ dcp::DIRECTION_LTR,
"My jacket was Idi Amin's",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -81,6 +82,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
dcp::HALIGN_CENTER,
0.21,
dcp::VALIGN_BOTTOM,
+ dcp::DIRECTION_LTR,
"My corset was H.M. The Queen's",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -100,6 +102,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
dcp::HALIGN_CENTER,
0.15,
dcp::VALIGN_BOTTOM,
+ dcp::DIRECTION_LTR,
"My large wonderbra",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -122,6 +125,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
dcp::HALIGN_CENTER,
0.15,
dcp::VALIGN_BOTTOM,
+ dcp::DIRECTION_LTR,
"Once belonged to the Shah",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -144,6 +148,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
dcp::HALIGN_CENTER,
0.15,
dcp::VALIGN_BOTTOM,
+ dcp::DIRECTION_LTR,
"And these are Roy Hattersley's jeans",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -172,6 +177,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"At afternoon tea with John Peel",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -191,6 +197,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"I enquired if his accent was real",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -213,6 +220,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"He said \"out of the house",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -232,6 +240,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"I'm incredibly scouse",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -254,6 +263,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"At home it depends how I feel.\"",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -273,6 +283,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"I spent a long weekend in Brighton",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -295,6 +306,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_RTL,
"With the legendary Miss Enid Blyton",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -314,6 +326,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_TTB,
"She said \"you be Noddy",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -336,6 +349,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_BTT,
"That curious creature the Sphinx",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -355,6 +369,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"Is smarter than anyone thinks",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -377,6 +392,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"It sits there and smirks",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -396,6 +412,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"And you don't think it works",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -418,6 +435,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"Then when you're not looking, it winks.",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -437,6 +455,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"When it snows you will find Sister Sledge",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -459,6 +478,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"Out mooning, at night, on the ledge",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -478,6 +498,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"One storey down",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -500,6 +521,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.89,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"HELLO",
dcp::BORDER,
dcp::Colour (0, 0, 0),
@@ -519,6 +541,7 @@ BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
dcp::HALIGN_CENTER,
0.95,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"WORLD",
dcp::BORDER,
dcp::Colour (0, 0, 0),
diff --git a/test/write_subtitle_test.cc b/test/write_subtitle_test.cc
index 67bfcd4e..ffd01e1f 100644
--- a/test/write_subtitle_test.cc
+++ b/test/write_subtitle_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
*/
#include "interop_subtitle_asset.h"
+#include "smpte_subtitle_asset.h"
#include "subtitle_string.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
@@ -27,7 +28,7 @@ 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_subtitle_test)
+BOOST_AUTO_TEST_CASE (write_interop_subtitle_test)
{
dcp::InteropSubtitleAsset c;
c.set_reel_number ("1");
@@ -48,6 +49,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
dcp::HALIGN_CENTER,
0.8,
dcp::VALIGN_TOP,
+ dcp::DIRECTION_LTR,
"Hello world",
dcp::NONE,
dcp::Colour (0, 0, 0),
@@ -70,6 +72,7 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
dcp::HALIGN_CENTER,
0.4,
dcp::VALIGN_BOTTOM,
+ dcp::DIRECTION_LTR,
"What's going on",
dcp::BORDER,
dcp::Colour (1, 2, 3),
@@ -101,3 +104,88 @@ BOOST_AUTO_TEST_CASE (write_subtitle_test)
list<string> ()
);
}
+
+/* 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,
+ 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<string> (),
+ 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 (),
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<dcst:SubtitleReel xmlns:dcst=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n"
+ " <dcst:Id>urn:uuid:a6c58cff-3e1e-4b38-acec-a42224475ef6</dcst:Id>\n"
+ " <dcst:ContentTitleText>Test</dcst:ContentTitleText>\n"
+ " <dcst:IssueDate>2016-04-01T03:52:00.000+00:00</dcst:IssueDate>\n"
+ " <dcst:ReelNumber>1</dcst:ReelNumber>\n"
+ " <dcst:Language>EN</dcst:Language>\n"
+ " <dcst:EditRate>24 1</dcst:EditRate>\n"
+ " <dcst:TimeCodeRate>24</dcst:TimeCodeRate>\n"
+ " <dcst:SubtitleList>\n"
+ " <dcst:Font ID=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underline=\"no\" Weight=\"normal\">\n"
+ " <dcst:Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:22\" TimeOut=\"00:04:11:22\" FadeUpTime=\"00:00:00:00\" FadeDownTime=\"00:00:00:00\">\n"
+ " <dcst:Text Valign=\"top\" Vposition=\"80\">Hello world</dcst:Text>\n"
+ " </dcst:Subtitle>\n"
+ " </dcst:Font>\n"
+ " <dcst:Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underline=\"no\" Weight=\"bold\">\n"
+ " <dcst:Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:21\" TimeOut=\"06:12:15:21\" FadeUpTime=\"01:02:03:04\" FadeDownTime=\"05:06:07:08\">\n"
+ " <dcst:Text Valign=\"bottom\" Vposition=\"40\" Direction=\"rtl\">What's going on</dcst:Text>\n"
+ " </dcst:Subtitle>\n"
+ " </dcst:Font>\n"
+ " </dcst:SubtitleList>\n"
+ "</dcst:SubtitleReel>\n",
+ list<string> ()
+ );
+}