Fill test disk partitions with random noise to expose more bugs.
[dcpomatic.git] / test / file_extension_test.cc
1 /*
2     Copyright (C) 2022 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/content_factory.h"
23 #include "lib/film.h"
24 #include "test.h"
25 #include <boost/test/unit_test.hpp>
26
27
28 /* Sanity check to make sure that files in a DCP have the right extensions / names.
29  * This is mostly to catch a crazy mistake where Interop subtitle files suddenly got
30  * a MXF extension but no tests caught it (#2270).
31  */
32 BOOST_AUTO_TEST_CASE (interop_file_extension_test)
33 {
34         auto video = content_factory("test/data/flat_red.png").front();
35         auto audio = content_factory("test/data/sine_440.wav").front();
36         auto sub = content_factory("test/data/15s.srt").front();
37         auto film = new_test_film2("interop_file_extension_test", { video, audio, sub });
38         film->set_interop(true);
39
40         make_and_verify_dcp(
41                 film, {
42                             dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
43                             dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
44                             dcp::VerificationNote::Code::INVALID_STANDARD
45                         });
46
47         BOOST_REQUIRE(dcp_file(film, "ASSETMAP").extension() == "");
48         BOOST_REQUIRE(dcp_file(film, "VOLINDEX").extension() == "");
49         BOOST_REQUIRE(dcp_file(film, "cpl").extension() == ".xml");
50         BOOST_REQUIRE(dcp_file(film, "pkl").extension() == ".xml");
51         BOOST_REQUIRE(dcp_file(film, "j2c").extension() == ".mxf");
52         BOOST_REQUIRE(dcp_file(film, "pcm").extension() == ".mxf");
53         BOOST_REQUIRE(dcp_file(film, "sub").extension() == ".xml");
54 }
55
56
57 BOOST_AUTO_TEST_CASE (smpte_file_extension_test)
58 {
59         auto video = content_factory("test/data/flat_red.png").front();
60         auto audio = content_factory("test/data/sine_440.wav").front();
61         auto sub = content_factory("test/data/15s.srt").front();
62         auto film = new_test_film2("smpte_file_extension_test", { video, audio, sub });
63         film->set_interop(false);
64
65         make_and_verify_dcp(
66                 film, {
67                             dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
68                             dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE
69                         });
70
71         BOOST_REQUIRE(dcp_file(film, "ASSETMAP").extension() == ".xml");
72         BOOST_REQUIRE(dcp_file(film, "VOLINDEX").extension() == ".xml");
73         BOOST_REQUIRE(dcp_file(film, "cpl").extension() == ".xml");
74         BOOST_REQUIRE(dcp_file(film, "pkl").extension() == ".xml");
75         BOOST_REQUIRE(dcp_file(film, "j2c").extension() == ".mxf");
76         BOOST_REQUIRE(dcp_file(film, "pcm").extension() == ".mxf");
77         BOOST_REQUIRE(dcp_file(film, "sub").extension() == ".mxf");
78 }