Clarify some documentation slightly.
[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/video_frame_type.h"
23 #include <dcp/types.h>
24 #include <dcp/verify.h>
25 #include <glibmm.h>
26 #include <boost/filesystem.hpp>
27 #include <vector>
28
29
30 class Content;
31 class Film;
32 class Image;
33 class Log;
34
35
36 class TestPaths
37 {
38 public:
39         static boost::filesystem::path private_data();
40         static boost::filesystem::path xsd();
41 };
42
43
44 class Cleanup
45 {
46 public:
47         void add (boost::filesystem::path path);
48
49         /* Remove everything passed to add().  We don't do this
50          * in a destructor so that results of failed tests aren't
51          * deleted.
52          */
53         void run ();
54
55 private:
56         std::vector<boost::filesystem::path> _paths;
57 };
58
59
60 extern bool wait_for_jobs ();
61 extern std::shared_ptr<Film> new_test_film(std::string, std::vector<std::shared_ptr<Content>> content = {}, Cleanup* cleanup = nullptr);
62 extern void check_dcp(boost::filesystem::path, boost::filesystem::path, bool sound_can_differ = false);
63 extern void check_dcp (boost::filesystem::path, std::shared_ptr<const Film>);
64 extern void check_file (boost::filesystem::path ref, boost::filesystem::path check);
65 extern void check_text_file (boost::filesystem::path ref, boost::filesystem::path check);
66 extern void check_wav_file (boost::filesystem::path ref, boost::filesystem::path check);
67 extern void check_mxf_audio_file (boost::filesystem::path ref, boost::filesystem::path check);
68 extern bool mxf_atmos_files_same (boost::filesystem::path ref, boost::filesystem::path check, bool verbose = false);
69 extern void check_xml(boost::filesystem::path, boost::filesystem::path, std::list<Glib::ustring>);
70 extern void check_ffmpeg (boost::filesystem::path, boost::filesystem::path, int audio_tolerance);
71 extern void check_image (boost::filesystem::path, boost::filesystem::path, double threshold = 4);
72 extern boost::filesystem::path test_film_dir (std::string);
73 extern void write_image (std::shared_ptr<const Image> image, boost::filesystem::path file);
74 boost::filesystem::path dcp_file (std::shared_ptr<const Film> film, std::string prefix);
75 void check_one_frame (boost::filesystem::path dcp, int64_t index, boost::filesystem::path ref);
76 extern boost::filesystem::path subtitle_file (std::shared_ptr<Film> film);
77 extern void make_random_file (boost::filesystem::path path, size_t size);
78 extern void verify_dcp(boost::filesystem::path dir, std::vector<dcp::VerificationNote::Code> ignore);
79 extern void make_and_verify_dcp(std::shared_ptr<Film> film, std::vector<dcp::VerificationNote::Code> ignore = {}, bool dcp_inspect = true, bool clairmeta = true);
80 extern void check_int_close (int a, int b, int d);
81 extern void check_int_close (std::pair<int, int>, std::pair<int, int>, int d);
82 extern boost::filesystem::path find_file (boost::filesystem::path dir, std::string filename_part);
83
84
85 class LogSwitcher
86 {
87 public:
88         LogSwitcher (std::shared_ptr<Log> log);
89         ~LogSwitcher ();
90
91 private:
92         std::shared_ptr<Log> _old;
93 };
94
95
96 class ConfigRestorer
97 {
98 public:
99         ConfigRestorer(boost::filesystem::path override_path);
100
101         ConfigRestorer() {}
102
103         ~ConfigRestorer();
104
105 private:
106         boost::optional<boost::filesystem::path> _old_path;
107 };
108
109
110 class Editor
111 {
112 public:
113         Editor(boost::filesystem::path path);
114         ~Editor();
115
116         void replace(std::string a, std::string b);
117
118 private:
119         boost::filesystem::path _path;
120         std::string _content;
121 };
122
123
124 namespace dcp {
125
126 std::ostream& operator<< (std::ostream& s, dcp::Size i);
127 std::ostream& operator<< (std::ostream& s, dcp::Standard t);
128
129 }
130
131 std::ostream& operator<< (std::ostream& s, VideoFrameType f);