2 Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 /** @file test/file_naming_test.cc
22 * @brief Test how files in DCPs are named.
27 #include "lib/config.h"
29 #include "lib/ffmpeg_content.h"
30 #include "lib/dcp_content_type.h"
31 #include <boost/test/unit_test.hpp>
32 #include <boost/regex.hpp>
35 using boost::shared_ptr;
37 BOOST_AUTO_TEST_CASE (file_naming_test)
39 Config::instance()->set_dcp_asset_filename_format (dcp::NameFormat ("%c"));
41 shared_ptr<Film> film = new_test_film ("file_naming_test");
42 film->set_name ("file_naming_test");
43 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
44 shared_ptr<FFmpegContent> r (new FFmpegContent (film, "test/data/flat_red.png"));
45 film->examine_and_add_content (r);
46 shared_ptr<FFmpegContent> g (new FFmpegContent (film, "test/data/flat_green.png"));
47 film->examine_and_add_content (g);
48 shared_ptr<FFmpegContent> b (new FFmpegContent (film, "test/data/flat_blue.png"));
49 film->examine_and_add_content (b);
52 film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
56 int got[3] = { 0, 0, 0 };
58 boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (film->file(film->dcp_name()));
59 i != boost::filesystem::directory_iterator();
61 if (boost::regex_match(i->path().string(), boost::regex(".*flat_red\\.png_.*\\.mxf"))) {
63 } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_green\\.png_.*\\.mxf"))) {
65 } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_blue\\.png_.*\\.mxf"))) {
70 for (int i = 0; i < 3; ++i) {
71 BOOST_CHECK (got[i] == 2);
75 BOOST_AUTO_TEST_CASE (file_naming_test2)
77 Config::instance()->set_dcp_asset_filename_format (dcp::NameFormat ("%c"));
79 shared_ptr<Film> film = new_test_film ("file_naming_test2");
80 film->set_name ("file_naming_test2");
81 film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
82 shared_ptr<FFmpegContent> r (new FFmpegContent (film, "test/data/flät_red.png"));
83 film->examine_and_add_content (r);
84 shared_ptr<FFmpegContent> g (new FFmpegContent (film, "test/data/flat_green.png"));
85 film->examine_and_add_content (g);
86 shared_ptr<FFmpegContent> b (new FFmpegContent (film, "test/data/flat_blue.png"));
87 film->examine_and_add_content (b);
90 film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
94 int got[3] = { 0, 0, 0 };
96 boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (film->file(film->dcp_name()));
97 i != boost::filesystem::directory_iterator();
99 if (boost::regex_match(i->path().string(), boost::regex(".*flt_red\\.png_.*\\.mxf"))) {
101 } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_green\\.png_.*\\.mxf"))) {
103 } else if (boost::regex_match(i->path().string(), boost::regex(".*flat_blue\\.png_.*\\.mxf"))) {
108 for (int i = 0; i < 3; ++i) {
109 BOOST_CHECK (got[i] == 2);