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