summaryrefslogtreecommitdiff
path: root/test/write_subtitle_test.cc
blob: 3feb4b79afdfbaa2b1d970a92b0c1cff7ab7d0b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
    Copyright (C) 2015 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
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include "interop_subtitle_content.h"
#include "subtitle_string.h"
#include "test.h"
#include <boost/test/unit_test.hpp>

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_subtitle_test)
{
	dcp::SubtitleString s (
		string ("Arial"),
		false,
		dcp::Colour (255, 255, 255),
		48,
		dcp::Time (0, 4,  9, 22, 24),
		dcp::Time (0, 4, 11, 22, 24),
		0.8,
		dcp::TOP,
		"Hello world",
		dcp::NONE,
		dcp::Colour (0, 0, 0),
		dcp::Time (0, 0, 0, 0, 24),
		dcp::Time (0, 0, 0, 0, 24)
		);
		
	dcp::InteropSubtitleContent c ("Test", "EN");
	c.add (s);

	c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";

	check_xml (
		c.xml_as_string (),
		"<DCSubtitle Version=\"1.0\">\n"
		"  <SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>\n"
		"  <MovieTitle>Test</MovieTitle>\n"
		"  <ReelNumber>1</ReelNumber>\n"
		"  <Language>EN</Language>\n"
		"  <Font Id=\"Arial\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
		"    <Subtitle SpotNumber=\"1\" TimeIn=\"0:4:9:22\" TimeOut=\"0:4:11:22\" FadeUpTime=\"0\" FadeDownTime=\"0\">\n"
		"      <Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>\n"
		"    </Subtitle>\n"
		"  </Font>\n"
		"</DCSubtitle>",
		list<string> ()
		);
}