summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-09 15:32:34 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-09 15:32:34 +0100
commitca9dfb8c67721ad667e204e22908f4e5c723c2ce (patch)
tree512b6f335a077d26a9c5b8cd2054cc89a1be9834 /test
parentdca56d88f34daa66d0df30e966030f84e99b4bea (diff)
Various work on improving vertical position handling.
Diffstat (limited to 'test')
-rw-r--r--test/data/test.ssa2
-rw-r--r--test/ssa_reader_test.cc26
2 files changed, 27 insertions, 1 deletions
diff --git a/test/data/test.ssa b/test/data/test.ssa
index 578c3d4..8ff209d 100644
--- a/test/data/test.ssa
+++ b/test/data/test.ssa
@@ -17,4 +17,4 @@ Style: Default,Arial,20,16777215,255,0,0,0,0,1,2,2,2,10,10,10,0,1
[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: Marked=0,0:00:01.23,0:00:04.55,Default,,0,0,0,,Hello world
-Dialogue: Marked=0,0:00:05.74,0:00:11.00,Default,,0,0,900,,This is vertically moved
+Dialogue: Marked=0,0:00:05.74,0:00:11.00,Default,,0,0,900,,This is vertically moved\nand has two lines.
diff --git a/test/ssa_reader_test.cc b/test/ssa_reader_test.cc
index 7689f4f..c62505a 100644
--- a/test/ssa_reader_test.cc
+++ b/test/ssa_reader_test.cc
@@ -140,6 +140,10 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test3)
BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 0, 4, 550));
list<sub::Line>::iterator j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
+ BOOST_CHECK (j->vertical_position.proportional);
+ BOOST_CHECK_EQUAL (j->vertical_position.proportional.get(), 0);
+ BOOST_CHECK (j->vertical_position.reference);
+ BOOST_CHECK_EQUAL (j->vertical_position.reference.get(), sub::BOTTOM_OF_SCREEN);
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
sub::Block b = j->blocks.front ();
BOOST_CHECK_EQUAL (b.text, "Hello world");
@@ -155,6 +159,14 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test3)
BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 0, 11, 0));
j = i->lines.begin();
BOOST_REQUIRE (j != i->lines.end ());
+ BOOST_CHECK (j->vertical_position.proportional);
+ /* The first line should be 900 pixels and one line (20
+ points, 1.2 times spaced, as a proportion of the total
+ screen height 729 points) up.
+ */
+ BOOST_CHECK (fabs (j->vertical_position.proportional.get() - (900.0 / 1080) - (20.0 * 1.2 / 792)) < 1e-5);
+ BOOST_CHECK (j->vertical_position.reference);
+ BOOST_CHECK_EQUAL (j->vertical_position.reference.get(), sub::BOTTOM_OF_SCREEN);
BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
b = j->blocks.front ();
BOOST_CHECK_EQUAL (b.text, "This is vertically moved");
@@ -163,6 +175,20 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test3)
BOOST_CHECK_EQUAL (b.bold, false);
BOOST_CHECK_EQUAL (b.italic, false);
BOOST_CHECK_EQUAL (b.underline, false);
+ ++j;
+ BOOST_CHECK (fabs (j->vertical_position.proportional.get() - (900.0 / 1080)) < 1e-5);
+ BOOST_CHECK (j->vertical_position.reference);
+ BOOST_CHECK_EQUAL (j->vertical_position.reference.get(), sub::BOTTOM_OF_SCREEN);
+ BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
+ b = j->blocks.front ();
+ BOOST_CHECK_EQUAL (b.text, "and has two lines.");
+ BOOST_CHECK_EQUAL (b.font.get(), "Arial");
+ BOOST_CHECK_EQUAL (b.font_size.points().get(), 20);
+ BOOST_CHECK_EQUAL (b.bold, false);
+ BOOST_CHECK_EQUAL (b.italic, false);
+ BOOST_CHECK_EQUAL (b.underline, false);
+ ++j;
+ BOOST_REQUIRE (j == i->lines.end());
++i;
BOOST_REQUIRE (i == subs.end ());