Some work on tests.
[libdcp.git] / test / dcp_test.cc
1 /*
2     Copyright (C) 2013 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 /* Test creation of a DCP from very simple inputs */
21 BOOST_AUTO_TEST_CASE (dcp_test)
22 {
23         Kumu::libdcp_test = true;
24
25         /* Some known metadata */
26         libdcp::XMLMetadata xml_meta;
27         xml_meta.issuer = "OpenDCP 0.0.25";
28         xml_meta.creator = "OpenDCP 0.0.25";
29         xml_meta.issue_date = "2012-07-17T04:45:18+00:00";
30         libdcp::MXFMetadata mxf_meta;
31         mxf_meta.company_name = "OpenDCP";
32         mxf_meta.product_name = "OpenDCP";
33         mxf_meta.product_version = "0.0.25";
34
35         /* We're making build/test/foo */
36         boost::filesystem::remove_all ("build/test/foo");
37         boost::filesystem::create_directories ("build/test/foo");
38         libdcp::DCP d ("build/test/foo");
39         shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/foo", "A Test DCP", libdcp::FEATURE, 24, 24));
40
41         shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset (
42                                                          j2c,
43                                                          "build/test/foo",
44                                                          "video.mxf",
45                                                          &d.Progress,
46                                                          24,
47                                                          24,
48                                                          false,
49                                                          libdcp::Size (32, 32),
50                                                          mxf_meta
51                                                          ));
52
53         shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset (
54                                                    wav,
55                                                    "build/test/foo",
56                                                    "audio.mxf",
57                                                    &(d.Progress),
58                                                    24,
59                                                    24,
60                                                    2,
61                                                    false,
62                                                    mxf_meta
63                                                    ));
64         
65         cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
66         d.add_cpl (cpl);
67
68         d.write_xml (xml_meta);
69
70         /* build/test/foo is checked against test/ref/DCP/foo by run-tests.sh */
71 }