5a2246894992da9cfa71d0f6b9e575a24f8b8969
[dcpomatic.git] / test / test.h
1 /*
2     Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "lib/warnings.h"
23 #include "lib/types.h"
24 #include <boost/filesystem.hpp>
25
26
27 class Film;
28 class Image;
29 class Log;
30
31
32 class TestPaths
33 {
34 public:
35         static boost::filesystem::path private_data();
36         static boost::filesystem::path xsd();
37 };
38
39
40 class Cleanup
41 {
42 public:
43         void add (boost::filesystem::path path);
44
45         /* Remove everything passed to add().  We don't do this
46          * in a destructor so that results of failed tests aren't
47          * deleted.
48          */
49         void run ();
50
51 private:
52         std::vector<boost::filesystem::path> _paths;
53 };
54
55
56 extern bool wait_for_jobs ();
57 extern void setup_test_config ();
58 extern std::shared_ptr<Film> new_test_film (std::string);
59 extern std::shared_ptr<Film> new_test_film2 (std::string, Cleanup* cleanup = nullptr);
60 extern void check_dcp (boost::filesystem::path, boost::filesystem::path);
61 extern void check_dcp (boost::filesystem::path, std::shared_ptr<const Film>);
62 extern void check_file (boost::filesystem::path ref, boost::filesystem::path check);
63 extern void check_wav_file (boost::filesystem::path ref, boost::filesystem::path check);
64 extern void check_mxf_audio_file (boost::filesystem::path ref, boost::filesystem::path check);
65 extern bool mxf_atmos_files_same (boost::filesystem::path ref, boost::filesystem::path check, bool verbose = false);
66 extern void check_xml (boost::filesystem::path, boost::filesystem::path, std::list<std::string>);
67 extern void check_file (boost::filesystem::path, boost::filesystem::path);
68 extern void check_ffmpeg (boost::filesystem::path, boost::filesystem::path, int audio_tolerance);
69 extern void check_image (boost::filesystem::path, boost::filesystem::path, double threshold = 4);
70 extern boost::filesystem::path test_film_dir (std::string);
71 extern void write_image (std::shared_ptr<const Image> image, boost::filesystem::path file);
72 boost::filesystem::path dcp_file (std::shared_ptr<const Film> film, std::string prefix);
73 void check_one_frame (boost::filesystem::path dcp, int64_t index, boost::filesystem::path ref);
74 extern boost::filesystem::path subtitle_file (std::shared_ptr<Film> film);
75 extern void make_random_file (boost::filesystem::path path, size_t size);
76
77
78 class LogSwitcher
79 {
80 public:
81         LogSwitcher (std::shared_ptr<Log> log);
82         ~LogSwitcher ();
83
84 private:
85         std::shared_ptr<Log> _old;
86 };
87
88
89 namespace dcp {
90
91 std::ostream& operator<< (std::ostream& s, dcp::Size i);
92 std::ostream& operator<< (std::ostream& s, dcp::Standard t);
93
94 }
95
96 std::ostream& operator<< (std::ostream& s, VideoFrameType f);