Forward-port some STL fixes from libsub.
[libsub.git] / test / dcp_to_stl_binary_test.cc
1 /*
2     Copyright (C) 2014 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 "test.h"
21 #include "interop_dcp_reader.h"
22 #include "smpte_dcp_reader.h"
23 #include "stl_binary_writer.h"
24 #include "collect.h"
25 #include <boost/test/unit_test.hpp>
26 #include <fstream>
27
28 using std::ifstream;
29 using std::list;
30
31 BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test1)
32 {
33         if (private_test.empty ()) {
34                 return;
35         }
36
37         boost::filesystem::path p = private_test / "fd586c30-6d38-48f2-8241-27359acf184c_sub.xml";
38         sub::write_stl_binary (
39                 sub::collect<list<sub::Subtitle> > (sub::InteropDCPReader(p).subtitles ()),
40                 25,
41                 sub::LANGUAGE_FRENCH,
42                 "", "",
43                 "", "",
44                 "", "",
45                 "300514", "300514", 0,
46                 "GBR",
47                 "",
48                 "", "",
49                 "build/test/fd586c30-6d38-48f2-8241-27359acf184c_sub.stl"
50                 );
51
52         check_file (
53                 private_test / "fd586c30-6d38-48f2-8241-27359acf184c_sub.stl",
54                 "build/test/fd586c30-6d38-48f2-8241-27359acf184c_sub.stl"
55                 );
56 }
57
58 BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test2)
59 {
60         if (private_test.empty ()) {
61                 return;
62         }
63
64         boost::filesystem::path p = private_test / "93e8a6bf-499e-4d36-9350-a9bfa2e6758a_sub.xml";
65         sub::write_stl_binary (
66                 sub::collect<list<sub::Subtitle> > (sub::InteropDCPReader(p).subtitles ()),
67                 25,
68                 sub::LANGUAGE_FRENCH,
69                 "", "",
70                 "", "",
71                 "", "",
72                 "300514", "300514", 0,
73                 "GBR",
74                 "",
75                 "", "",
76                 "build/test/93e8a6bf-499e-4d36-9350-a9bfa2e6758a_sub.stl"
77                 );
78
79         check_file (
80                 private_test / "93e8a6bf-499e-4d36-9350-a9bfa2e6758a_sub.stl",
81                 "build/test/93e8a6bf-499e-4d36-9350-a9bfa2e6758a_sub.stl"
82                 );
83 }
84
85 BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test3)
86 {
87         if (private_test.empty ()) {
88                 return;
89         }
90
91         boost::filesystem::path p = private_test / "Paddington_FTR_Subs_DE-FR_24fps_R1.xml";
92         sub::write_stl_binary (
93                 sub::collect<list<sub::Subtitle> > (sub::InteropDCPReader(p).subtitles ()),
94                 25,
95                 sub::LANGUAGE_FRENCH,
96                 "", "",
97                 "", "",
98                 "", "",
99                 "300514", "300514", 0,
100                 "GBR",
101                 "",
102                 "", "",
103                 "build/test/Paddington_FTR_Subs_DE-FR_24fps_R1.stl"
104                 );
105
106         check_file (
107                 private_test / "Paddington_FTR_Subs_DE-FR_24fps_R1.stl",
108                 "build/test/Paddington_FTR_Subs_DE-FR_24fps_R1.stl"
109                 );
110 }
111
112 BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test4)
113 {
114         sub::write_stl_binary (
115                 sub::collect<list<sub::Subtitle> > (sub::InteropDCPReader("test/data/test1.xml").subtitles ()),
116                 25,
117                 sub::LANGUAGE_FRENCH,
118                 "", "",
119                 "", "",
120                 "", "",
121                 "300514", "300514", 0,
122                 "GBR",
123                 "",
124                 "", "",
125                 "build/test/test1.stl"
126                 );
127 }
128
129 BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test5)
130 {
131         if (private_test.empty ()) {
132                 return;
133         }
134
135         boost::filesystem::path p = private_test / "065d39ff-6723-4dbf-a94f-849cde82f5e1_sub.mxf";
136         sub::write_stl_binary (
137                 sub::collect<list<sub::Subtitle> > (sub::SMPTEDCPReader(p, true).subtitles ()),
138                 25,
139                 sub::LANGUAGE_FRENCH,
140                 "", "",
141                 "", "",
142                 "", "",
143                 "300514", "300514", 0,
144                 "GBR",
145                 "",
146                 "", "",
147                 "build/test/065d39ff-6723-4dbf-a94f-849cde82f5e1_sub.stl"
148                 );
149
150         check_file (
151                 private_test / "065d39ff-6723-4dbf-a94f-849cde82f5e1_sub.stl",
152                 "build/test/065d39ff-6723-4dbf-a94f-849cde82f5e1_sub.stl"
153                 );
154 }
155
156 BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test6)
157 {
158         if (private_test.empty ()) {
159                 return;
160         }
161
162         boost::filesystem::path p = private_test / "Paddington_FTR_FullSubs_DE_24fps.xml";
163         sub::write_stl_binary (
164                 sub::collect<list<sub::Subtitle> > (sub::InteropDCPReader(p).subtitles ()),
165                 24,
166                 sub::LANGUAGE_GERMAN,
167                 "", "",
168                 "", "",
169                 "", "",
170                 "300514", "300514", 0,
171                 "GBR",
172                 "",
173                 "", "",
174                 "build/test/Paddington_FTR_FullSubs_DE_24fps.stl"
175                 );
176
177         check_file (
178                 private_test / "Paddington_FTR_FullSubs_DE_24fps.stl",
179                 "build/test/Paddington_FTR_FullSubs_DE_24fps.stl"
180                 );
181 }
182
183 BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test7)
184 {
185         boost::filesystem::path p = "test/data/test3.xml";
186         sub::write_stl_binary (
187                 sub::collect<list<sub::Subtitle> > (sub::InteropDCPReader(p).subtitles ()),
188                 24,
189                 sub::LANGUAGE_GERMAN,
190                 "", "",
191                 "", "",
192                 "", "",
193                 "300514", "300514", 0,
194                 "GBR",
195                 "",
196                 "", "",
197                 "build/test/test3.stl"
198                 );
199
200         check_file (
201                 "test/ref/test3.stl",
202                 "build/test/test3.stl"
203                 );
204 }