Bump version
[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 "trimmer.h"
43 #include "ui_signaller.h"
44 #define BOOST_TEST_DYN_LINK
45 #define BOOST_TEST_MODULE dvdomatic_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                 dvdomatic_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                 Config::instance()->set_default_format (static_cast<Format*> (0));
67                 Config::instance()->set_default_dcp_content_type (static_cast<DCPContentType*> (0));
68
69                 ui_signaller = new UISignaller ();
70         }
71 };
72
73 BOOST_GLOBAL_FIXTURE (TestConfig);
74
75 boost::filesystem::path
76 test_film_dir (string name)
77 {
78         boost::filesystem::path p;
79         p /= "build";
80         p /= "test";
81         p /= name;
82         return p;
83 }
84
85 shared_ptr<Film>
86 new_test_film (string name)
87 {
88         boost::filesystem::path p = test_film_dir (name);
89         if (boost::filesystem::exists (p)) {
90                 boost::filesystem::remove_all (p);
91         }
92         
93         return shared_ptr<Film> (new Film (p.string(), false));
94 }
95
96 #include "pixel_formats_test.cc"
97 #include "make_black_test.cc"
98 #include "trimmer_test.cc"
99 #include "film_metadata_test.cc"
100 #include "stream_test.cc"
101 #include "format_test.cc"
102 #include "util_test.cc"
103 #include "film_test.cc"
104 #include "dcp_test.cc"
105 #include "frame_rate_test.cc"
106 #include "job_test.cc"
107 #include "client_server_test.cc"
108 #include "image_test.cc"