C++11 tidying.
[dcpomatic.git] / test / markers_test.cc
1 /*
2     Copyright (C) 2020-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 /** @file  test/markers_test
23  *  @brief Test SMPTE markers.
24  *  @ingroup feature
25  */
26
27
28 #include "lib/content_factory.h"
29 #include "lib/film.h"
30 #include "test.h"
31 #include <dcp/cpl.h>
32 #include <dcp/dcp.h>
33 #include <dcp/reel_markers_asset.h>
34 #include <dcp/reel.h>
35 #include <boost/test/unit_test.hpp>
36
37
38 using std::string;
39 using boost::optional;
40 using std::shared_ptr;
41
42
43 /** Check that FFOC and LFOC are automatically added if not specified */
44 BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test1)
45 {
46         string const name = "automatic_ffoc_lfoc_markers_test1";
47         auto film = new_test_film2 (name);
48         film->examine_and_add_content (content_factory("test/data/flat_red.png").front());
49         BOOST_REQUIRE (!wait_for_jobs());
50
51         film->set_interop (false);
52         make_and_verify_dcp (film);
53
54         dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name()));
55         dcp.read ();
56         BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
57         auto cpl = dcp.cpls().front();
58         BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1U);
59         auto reel = cpl->reels()[0];
60         auto markers = reel->main_markers();
61         BOOST_REQUIRE (markers);
62
63         auto ffoc = markers->get (dcp::Marker::FFOC);
64         BOOST_REQUIRE (ffoc);
65         BOOST_CHECK (*ffoc == dcp::Time(0, 0, 0, 1, 24));
66         auto lfoc = markers->get (dcp::Marker::LFOC);
67         BOOST_REQUIRE (lfoc);
68         BOOST_CHECK (*lfoc == dcp::Time(0, 0, 9, 23, 24));
69 }
70
71
72 /** Check that FFOC and LFOC are not overridden if they are specified */
73 BOOST_AUTO_TEST_CASE (automatic_ffoc_lfoc_markers_test2)
74 {
75         string const name = "automatic_ffoc_lfoc_markers_test2";
76         auto film = new_test_film2 (name);
77         film->examine_and_add_content (content_factory("test/data/flat_red.png").front());
78         BOOST_REQUIRE (!wait_for_jobs());
79
80         film->set_interop (false);
81         film->set_marker (dcp::Marker::FFOC, dcpomatic::DCPTime::from_seconds(1));
82         film->set_marker (dcp::Marker::LFOC, dcpomatic::DCPTime::from_seconds(9));
83         make_and_verify_dcp (
84                 film,
85                 {
86                         dcp::VerificationNote::Code::INCORRECT_FFOC,
87                         dcp::VerificationNote::Code::INCORRECT_LFOC
88                 });
89
90         dcp::DCP dcp (String::compose("build/test/%1/%2", name, film->dcp_name()));
91         dcp.read ();
92         BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
93         auto cpl = dcp.cpls().front();
94         BOOST_REQUIRE_EQUAL (cpl->reels().size(), 1U);
95         auto reel = cpl->reels()[0];
96         auto markers = reel->main_markers();
97         BOOST_REQUIRE (markers);
98
99         auto ffoc = markers->get (dcp::Marker::FFOC);
100         BOOST_REQUIRE (ffoc);
101         BOOST_CHECK (*ffoc == dcp::Time (0, 0, 1, 0, 24));
102         auto lfoc = markers->get (dcp::Marker::LFOC);
103         BOOST_REQUIRE (lfoc);
104         BOOST_CHECK (*lfoc == dcp::Time(0, 0, 9, 0, 24));
105 }
106