2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 BOOST_AUTO_TEST_CASE (film_metadata_test)
22 string const test_film = "build/test/film_metadata_test";
24 if (boost::filesystem::exists (test_film)) {
25 boost::filesystem::remove_all (test_film);
28 BOOST_CHECK_THROW (new Film (test_film, true), OpenFileError);
30 shared_ptr<Film> f (new Film (test_film, false));
31 f->_dci_date = boost::gregorian::from_undelimited_string ("20130211");
32 BOOST_CHECK (f->format() == 0);
33 BOOST_CHECK (f->dcp_content_type() == 0);
34 BOOST_CHECK (f->filters ().empty());
37 BOOST_CHECK_THROW (f->set_content ("jim"), OpenFileError);
38 f->set_dcp_content_type (DCPContentType::from_pretty_name ("Short"));
39 f->set_format (Format::from_nickname ("Flat"));
41 f->set_right_crop (2);
43 f->set_bottom_crop (4);
44 vector<Filter const *> f_filters;
45 f_filters.push_back (Filter::from_id ("pphb"));
46 f_filters.push_back (Filter::from_id ("unsharp"));
47 f->set_filters (f_filters);
48 f->set_trim_start (42);
54 s << "diff -u test/metadata.ref " << test_film << "/metadata";
55 BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0);
57 shared_ptr<Film> g (new Film (test_film, true));
59 BOOST_CHECK_EQUAL (g->name(), "fred");
60 BOOST_CHECK_EQUAL (g->dcp_content_type(), DCPContentType::from_pretty_name ("Short"));
61 BOOST_CHECK_EQUAL (g->format(), Format::from_nickname ("Flat"));
62 BOOST_CHECK_EQUAL (g->crop().left, 1);
63 BOOST_CHECK_EQUAL (g->crop().right, 2);
64 BOOST_CHECK_EQUAL (g->crop().top, 3);
65 BOOST_CHECK_EQUAL (g->crop().bottom, 4);
66 vector<Filter const *> g_filters = g->filters ();
67 BOOST_CHECK_EQUAL (g_filters.size(), 2);
68 BOOST_CHECK_EQUAL (g_filters.front(), Filter::from_id ("pphb"));
69 BOOST_CHECK_EQUAL (g_filters.back(), Filter::from_id ("unsharp"));
70 BOOST_CHECK_EQUAL (g->trim_start(), 42);
71 BOOST_CHECK_EQUAL (g->trim_end(), 99);
72 BOOST_CHECK_EQUAL (g->dcp_ab(), true);
75 BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0);