Split up some files.
[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 "mono_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 ("build/test/foo", "video.mxf"));
54         mp->set_progress (&d.Progress);
55         mp->set_edit_rate (24);
56         mp->set_intrinsic_duration (24);
57         mp->set_duration (24);
58         mp->set_size (libdcp::Size (32, 32));
59         mp->set_metadata (mxf_meta);
60         mp->create (j2c);
61
62         shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ("build/test/foo", "audio.mxf"));
63         ms->set_progress (&d.Progress);
64         ms->set_edit_rate (24);
65         ms->set_intrinsic_duration (24);
66         ms->set_duration (24);
67         ms->set_channels (2);
68         ms->set_metadata (mxf_meta);
69         ms->create (wav);
70         
71         cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
72         d.add_cpl (cpl);
73
74         d.write_xml (false, xml_meta);
75
76         /* build/test/foo is checked against test/ref/DCP/foo by run-tests.sh */
77 }