Merge master and multifarious hackery.
[dcpomatic.git] / test / test.cc
1 /*
2     Copyright (C) 2012 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 <fstream>
21 #include <iostream>
22 #include <boost/filesystem.hpp>
23 #include <boost/algorithm/string/predicate.hpp>
24 #include <boost/date_time.hpp>
25 #include "format.h"
26 #include "film.h"
27 #include "filter.h"
28 #include "job_manager.h"
29 #include "util.h"
30 #include "exceptions.h"
31 #include "image.h"
32 #include "log.h"
33 #include "dcp_video_frame.h"
34 #include "config.h"
35 #include "server.h"
36 #include "cross.h"
37 #include "job.h"
38 #include "subtitle.h"
39 #include "scaler.h"
40 #include "ffmpeg_decoder.h"
41 #include "sndfile_decoder.h"
42 #include "dcp_content_type.h"
43 #include "container.h"
44 #define BOOST_TEST_DYN_LINK
45 #define BOOST_TEST_MODULE dcpomatic_test
46 #include <boost/test/unit_test.hpp>
47
48 using std::string;
49 using std::list;
50 using std::stringstream;
51 using std::vector;
52 using boost::shared_ptr;
53 using boost::thread;
54 using boost::dynamic_pointer_cast;
55
56 struct TestConfig
57 {
58         TestConfig()
59         {
60                 dcpomatic_setup();
61
62                 Config::instance()->set_num_local_encoding_threads (1);
63                 Config::instance()->set_servers (vector<ServerDescription*> ());
64                 Config::instance()->set_server_port (61920);
65                 Config::instance()->set_default_dci_metadata (DCIMetadata ());
66         }
67 };
68
69 BOOST_GLOBAL_FIXTURE (TestConfig);
70
71 boost::filesystem::path
72 test_film_dir (string name)
73 {
74         boost::filesystem::path p;
75         p /= "build";
76         p /= "test";
77         p /= name;
78         return p;
79 }
80
81 shared_ptr<Film>
82 new_test_film (string name)
83 {
84         boost::filesystem::path p = test_film_dir (name);
85         if (boost::filesystem::exists (p)) {
86                 boost::filesystem::remove_all (p);
87         }
88         
89         shared_ptr<Film> f = shared_ptr<Film> (new Film (p.string()));
90         f->write_metadata ();
91         return f;
92 }
93
94 #include "pixel_formats_test.cc"
95 #include "make_black_test.cc"
96 #include "film_metadata_test.cc"
97 #include "stream_test.cc"
98 #include "format_test.cc"
99 #include "util_test.cc"
100 #include "dcp_test.cc"
101 #include "frame_rate_test.cc"
102 #include "job_test.cc"
103 #include "client_server_test.cc"
104 #include "image_test.cc"