Add a very simple test for writing subtitles.
[libdcp.git] / test / write_subtitle_test.cc
1 /*
2     Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "interop_subtitle_content.h"
21 #include "subtitle_string.h"
22 #include "test.h"
23 #include <boost/test/unit_test.hpp>
24
25 using std::list;
26 using std::string;
27 using boost::shared_ptr;
28
29 /* Write some subtitle content as Interop XML and check that it is right */
30 BOOST_AUTO_TEST_CASE (write_subtitle_test)
31 {
32         dcp::SubtitleString s (
33                 string ("Arial"),
34                 false,
35                 dcp::Colour (255, 255, 255),
36                 48,
37                 dcp::Time (0, 4,  9, 22, 24),
38                 dcp::Time (0, 4, 11, 22, 24),
39                 0.8,
40                 dcp::TOP,
41                 "Hello world",
42                 dcp::NONE,
43                 dcp::Colour (0, 0, 0),
44                 dcp::Time (0, 0, 0, 0, 24),
45                 dcp::Time (0, 0, 0, 0, 24)
46                 );
47                 
48         dcp::InteropSubtitleContent c ("Test", "EN");
49         c.add (s);
50
51         c._id = "a6c58cff-3e1e-4b38-acec-a42224475ef6";
52
53         check_xml (
54                 c.xml_as_string (),
55                 "<DCSubtitle Version=\"1.0\">\n"
56                 "  <SubtitleID>a6c58cff-3e1e-4b38-acec-a42224475ef6</SubtitleID>\n"
57                 "  <MovieTitle>Test</MovieTitle>\n"
58                 "  <ReelNumber>1</ReelNumber>\n"
59                 "  <Language>EN</Language>\n"
60                 "  <Font Id=\"Arial\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
61                 "    <Subtitle SpotNumber=\"1\" TimeIn=\"0:4:9:22\" TimeOut=\"0:4:11:22\" FadeUpTime=\"0\" FadeDownTime=\"0\">\n"
62                 "      <Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>\n"
63                 "    </Subtitle>\n"
64                 "  </Font>\n"
65                 "</DCSubtitle>",
66                 list<string> ()
67                 );
68 }
69