Merge branch 'master' of ssh://houllier/home/carl/git/dvdomatic
[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 #define BOOST_TEST_DYN_LINK
44 #define BOOST_TEST_MODULE dvdomatic_test
45 #include <boost/test/unit_test.hpp>
46
47 using std::string;
48 using std::list;
49 using std::stringstream;
50 using std::vector;
51 using boost::shared_ptr;
52 using boost::thread;
53 using boost::dynamic_pointer_cast;
54
55 struct TestConfig
56 {
57         TestConfig()
58         {
59                 dvdomatic_setup();
60
61                 Config::instance()->set_num_local_encoding_threads (1);
62                 Config::instance()->set_servers (vector<ServerDescription*> ());
63                 Config::instance()->set_server_port (61920);
64                 Config::instance()->set_default_dci_metadata (DCIMetadata ());
65         }
66 };
67
68 BOOST_GLOBAL_FIXTURE (TestConfig);
69
70 boost::filesystem::path
71 test_film_dir (string name)
72 {
73         boost::filesystem::path p;
74         p /= "build";
75         p /= "test";
76         p /= name;
77         return p;
78 }
79
80 shared_ptr<Film>
81 new_test_film (string name)
82 {
83         boost::filesystem::path p = test_film_dir (name);
84         if (boost::filesystem::exists (p)) {
85                 boost::filesystem::remove_all (p);
86         }
87         
88         return shared_ptr<Film> (new Film (p.string(), false));
89 }
90
91 #include "pixel_formats_test.cc"
92 #include "make_black_test.cc"
93 #include "trimmer_test.cc"
94 #include "film_metadata_test.cc"
95 #include "stream_test.cc"
96 #include "format_test.cc"
97 #include "util_test.cc"
98 #include "film_test.cc"
99 #include "dcp_test.cc"
100 #include "frame_rate_test.cc"
101 #include "job_test.cc"
102 #include "client_server_test.cc"
103 #include "image_test.cc"