diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/black_fill_test.cc | 68 | ||||
| -rw-r--r-- | test/client_server_test.cc | 9 | ||||
| -rw-r--r-- | test/dcp_test.cc | 33 | ||||
| -rw-r--r-- | test/film_metadata_test.cc | 41 | ||||
| -rw-r--r-- | test/film_test.cc | 30 | ||||
| -rw-r--r-- | test/format_test.cc | 61 | ||||
| -rw-r--r-- | test/frame_rate_test.cc | 2 | ||||
| -rw-r--r-- | test/job_test.cc | 4 | ||||
| -rw-r--r-- | test/make_black_test.cc | 2 | ||||
| -rw-r--r-- | test/md5.test | bin | 98304 -> 0 bytes | |||
| -rw-r--r-- | test/metadata.ref | 42 | ||||
| -rw-r--r-- | test/pixel_formats_test.cc | 4 | ||||
| -rw-r--r-- | test/ratio_test.cc | 73 | ||||
| -rw-r--r-- | test/scaling_test.cc | 72 | ||||
| -rw-r--r-- | test/stream_test.cc | 2 | ||||
| -rw-r--r-- | test/test.cc | 79 | ||||
| -rw-r--r-- | test/test.mp4 | bin | 9112 -> 0 bytes | |||
| -rw-r--r-- | test/trimmer_test.cc | 95 | ||||
| -rw-r--r-- | test/util_test.cc | 2 | ||||
| -rw-r--r-- | test/wscript | 4 |
20 files changed, 316 insertions, 307 deletions
diff --git a/test/black_fill_test.cc b/test/black_fill_test.cc new file mode 100644 index 000000000..7ea031e27 --- /dev/null +++ b/test/black_fill_test.cc @@ -0,0 +1,68 @@ +/* + Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "imagemagick_content.h" + +/** @file test/black_fill_test.cc + * @brief Test insertion of black frames between video content. + */ + +using boost::shared_ptr; + +BOOST_AUTO_TEST_CASE (black_fill_test) +{ + shared_ptr<Film> film = new_test_film ("black_fill_test"); + film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR")); + film->set_name ("black_fill_test"); + film->set_container (Ratio::from_id ("185")); + film->set_sequence_video (false); + shared_ptr<ImageMagickContent> contentA (new ImageMagickContent (film, "test/data/simple_testcard_640x480.png")); + contentA->set_ratio (Ratio::from_id ("185")); + shared_ptr<ImageMagickContent> contentB (new ImageMagickContent (film, "test/data/simple_testcard_640x480.png")); + contentB->set_ratio (Ratio::from_id ("185")); + + film->examine_and_add_content (contentA); + film->examine_and_add_content (contentB); + while (JobManager::instance()->work_to_do ()); + + contentA->set_video_length (3); + contentA->set_start (film->video_frames_to_time (2)); + contentB->set_video_length (1); + contentB->set_start (film->video_frames_to_time (7)); + + film->make_dcp (); + + while (JobManager::instance()->work_to_do ()); + + BOOST_CHECK (!JobManager::instance()->errors()); + + boost::filesystem::path ref; + ref = "test"; + ref /= "data"; + ref /= "black_fill_test"; + + boost::filesystem::path check; + check = "build"; + check /= "test"; + check /= "black_fill_test"; + check /= film->dcp_name(); + + check_dcp (ref.string(), check.string()); +} + diff --git a/test/client_server_test.cc b/test/client_server_test.cc index e5229b5ff..51b52331a 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -63,15 +63,8 @@ BOOST_AUTO_TEST_CASE (client_server_test) shared_ptr<DCPVideoFrame> frame ( new DCPVideoFrame ( image, - subtitle, - libdcp::Size (1998, 1080), - 0, - 0, - 1, - Scaler::from_id ("bicubic"), 0, 24, - "", 0, 200000000, log @@ -86,7 +79,7 @@ BOOST_AUTO_TEST_CASE (client_server_test) new thread (boost::bind (&Server::run, server, 2)); /* Let the server get itself ready */ - dvdomatic_sleep (1); + dcpomatic_sleep (1); ServerDescription description ("localhost", 2); diff --git a/test/dcp_test.cc b/test/dcp_test.cc index 9312a2067..3565c1cfd 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -21,14 +21,22 @@ BOOST_AUTO_TEST_CASE (make_dcp_test) { shared_ptr<Film> film = new_test_film ("make_dcp_test"); film->set_name ("test_film2"); - film->set_content ("../../../test/test.mp4"); - film->set_format (Format::from_nickname ("Flat")); + film->examine_and_add_content (shared_ptr<FFmpegContent> (new FFmpegContent (film, "test/data/test.mp4"))); + + /* Wait for the examine to finish */ + while (JobManager::instance()->work_to_do ()) { + dcpomatic_sleep (1); + } + + BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false); + + film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); film->make_dcp (); film->write_metadata (); while (JobManager::instance()->work_to_do ()) { - dvdomatic_sleep (1); + dcpomatic_sleep (1); } BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false); @@ -46,22 +54,3 @@ BOOST_AUTO_TEST_CASE (have_dcp_test) boost::filesystem::remove (p); BOOST_CHECK (!f.have_dcp ()); } - -BOOST_AUTO_TEST_CASE (make_dcp_with_range_test) -{ - shared_ptr<Film> film = new_test_film ("make_dcp_with_range_test"); - film->set_name ("test_film3"); - film->set_content ("../../../test/test.mp4"); - film->examine_content (); - film->set_format (Format::from_nickname ("Flat")); - film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); - film->set_trim_end (42); - film->make_dcp (); - - while (JobManager::instance()->work_to_do() && !JobManager::instance()->errors()) { - dvdomatic_sleep (1); - } - - BOOST_CHECK_EQUAL (JobManager::instance()->errors(), false); -} - diff --git a/test/film_metadata_test.cc b/test/film_metadata_test.cc index 0b4495b48..e0406db55 100644 --- a/test/film_metadata_test.cc +++ b/test/film_metadata_test.cc @@ -25,51 +25,28 @@ BOOST_AUTO_TEST_CASE (film_metadata_test) boost::filesystem::remove_all (test_film); } - BOOST_CHECK_THROW (new Film (test_film, true), OpenFileError); - - shared_ptr<Film> f (new Film (test_film, false)); + shared_ptr<Film> f (new Film (test_film)); f->_dci_date = boost::gregorian::from_undelimited_string ("20130211"); - BOOST_CHECK (f->format() == 0); + BOOST_CHECK (f->container() == 0); BOOST_CHECK (f->dcp_content_type() == 0); - BOOST_CHECK (f->filters ().empty()); f->set_name ("fred"); - BOOST_CHECK_THROW (f->set_content ("jim"), OpenFileError); f->set_dcp_content_type (DCPContentType::from_pretty_name ("Short")); - f->set_format (Format::from_nickname ("Flat")); - f->set_left_crop (1); - f->set_right_crop (2); - f->set_top_crop (3); - f->set_bottom_crop (4); - vector<Filter const *> f_filters; - f_filters.push_back (Filter::from_id ("pphb")); - f_filters.push_back (Filter::from_id ("unsharp")); - f->set_filters (f_filters); - f->set_trim_start (42); - f->set_trim_end (99); - f->set_dcp_ab (true); + f->set_container (Ratio::from_id ("185")); + f->set_ab (true); f->write_metadata (); stringstream s; - s << "diff -u test/metadata.ref " << test_film << "/metadata"; + s << "diff -u test/data/metadata.xml.ref " << test_film << "/metadata.xml"; BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0); - shared_ptr<Film> g (new Film (test_film, true)); + shared_ptr<Film> g (new Film (test_film)); + g->read_metadata (); BOOST_CHECK_EQUAL (g->name(), "fred"); BOOST_CHECK_EQUAL (g->dcp_content_type(), DCPContentType::from_pretty_name ("Short")); - BOOST_CHECK_EQUAL (g->format(), Format::from_nickname ("Flat")); - BOOST_CHECK_EQUAL (g->crop().left, 1); - BOOST_CHECK_EQUAL (g->crop().right, 2); - BOOST_CHECK_EQUAL (g->crop().top, 3); - BOOST_CHECK_EQUAL (g->crop().bottom, 4); - vector<Filter const *> g_filters = g->filters (); - BOOST_CHECK_EQUAL (g_filters.size(), 2); - BOOST_CHECK_EQUAL (g_filters.front(), Filter::from_id ("pphb")); - BOOST_CHECK_EQUAL (g_filters.back(), Filter::from_id ("unsharp")); - BOOST_CHECK_EQUAL (g->trim_start(), 42); - BOOST_CHECK_EQUAL (g->trim_end(), 99); - BOOST_CHECK_EQUAL (g->dcp_ab(), true); + BOOST_CHECK_EQUAL (g->container(), Ratio::from_id ("185")); + BOOST_CHECK_EQUAL (g->ab(), true); g->write_metadata (); BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0); diff --git a/test/film_test.cc b/test/film_test.cc deleted file mode 100644 index 02dfa0553..000000000 --- a/test/film_test.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -BOOST_AUTO_TEST_CASE (paths_test) -{ - shared_ptr<Film> f = new_test_film ("paths_test"); - f->set_directory ("build/test/a/b/c/d/e"); - - f->_content = "/foo/bar/baz"; - BOOST_CHECK_EQUAL (f->content_path(), "/foo/bar/baz"); - f->_content = "foo/bar/baz"; - BOOST_CHECK_EQUAL (f->content_path(), "build/test/a/b/c/d/e/foo/bar/baz"); -} - diff --git a/test/format_test.cc b/test/format_test.cc deleted file mode 100644 index b150738a4..000000000 --- a/test/format_test.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -BOOST_AUTO_TEST_CASE (format_test) -{ - Format::setup_formats (); - - Format const * f = Format::from_nickname ("Flat"); - BOOST_CHECK (f); - BOOST_CHECK_EQUAL (f->dcp_size().width, 1998); - BOOST_CHECK_EQUAL (f->dcp_size().height, 1080); - - f = Format::from_nickname ("Scope"); - BOOST_CHECK (f); - BOOST_CHECK_EQUAL (f->dcp_size().width, 2048); - BOOST_CHECK_EQUAL (f->dcp_size().height, 858); -} - - -/* Test VariableFormat-based scaling of content */ -BOOST_AUTO_TEST_CASE (scaling_test) -{ - shared_ptr<Film> film (new Film (test_film_dir ("scaling_test").string(), false)); - - /* 4:3 ratio */ - film->set_size (libdcp::Size (320, 240)); - - /* This format should preserve aspect ratio of the source */ - Format const * format = Format::from_id ("var-185"); - - /* We should have enough padding that the result is 4:3, - which would be 1440 pixels. - */ - BOOST_CHECK_EQUAL (format->dcp_padding (film), (1998 - 1440) / 2); - - /* This crops it to 1.291666667 */ - film->set_left_crop (5); - film->set_right_crop (5); - - /* We should now have enough padding that the result is 1.29166667, - which would be 1395 pixels. - */ - BOOST_CHECK_EQUAL (format->dcp_padding (film), rint ((1998 - 1395) / 2.0)); -} - diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc index 00700656e..8b04d3763 100644 --- a/test/frame_rate_test.cc +++ b/test/frame_rate_test.cc @@ -20,6 +20,7 @@ /* Test best_dcp_frame_rate and FrameRateConversion */ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test) { +#if 0 /* Run some tests with a limited range of allowed rates */ std::list<int> afr; @@ -207,5 +208,6 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) the 14.99 fps video to 30 and then run it slow at 25. */ BOOST_CHECK_EQUAL (f->target_audio_sample_rate(), rint (48000 * 2 * 14.99 / 25)); +#endif } diff --git a/test/job_test.cc b/test/job_test.cc index 247d4f756..86c6dc9e3 100644 --- a/test/job_test.cc +++ b/test/job_test.cc @@ -56,9 +56,9 @@ BOOST_AUTO_TEST_CASE (job_manager_test) shared_ptr<TestJob> a (new TestJob (f)); JobManager::instance()->add (a); - dvdomatic_sleep (1); + dcpomatic_sleep (1); BOOST_CHECK_EQUAL (a->running (), true); a->set_finished_ok (); - dvdomatic_sleep (2); + dcpomatic_sleep (2); BOOST_CHECK_EQUAL (a->finished_ok(), true); } diff --git a/test/make_black_test.cc b/test/make_black_test.cc index 3c0b979ff..c70870915 100644 --- a/test/make_black_test.cc +++ b/test/make_black_test.cc @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (make_black_test) for (list<AVPixelFormat>::const_iterator i = pix_fmts.begin(); i != pix_fmts.end(); ++i) { boost::shared_ptr<Image> foo (new SimpleImage (*i, in_size, true)); foo->make_black (); - boost::shared_ptr<Image> bar = foo->scale_and_convert_to_rgb (out_size, 0, Scaler::from_id ("bicubic"), true); + boost::shared_ptr<Image> bar = foo->scale_and_convert_to_rgb (out_size, Scaler::from_id ("bicubic"), true); uint8_t* p = bar->data()[0]; for (int y = 0; y < bar->size().height; ++y) { diff --git a/test/md5.test b/test/md5.test Binary files differdeleted file mode 100644 index 573ed79d9..000000000 --- a/test/md5.test +++ /dev/null diff --git a/test/metadata.ref b/test/metadata.ref deleted file mode 100644 index b7a031883..000000000 --- a/test/metadata.ref +++ /dev/null @@ -1,42 +0,0 @@ -version 4 -name fred -use_dci_name 1 -content -trust_content_header 1 -dcp_content_type SHR -format 185 -left_crop 1 -right_crop 2 -top_crop 3 -bottom_crop 4 -filter pphb -filter unsharp -scaler bicubic -trim_start 42 -trim_end 99 -trim_type cpl -dcp_ab 1 -use_content_audio 1 -audio_gain 0 -audio_delay 0 -still_duration 10 -with_subtitles 0 -subtitle_offset 0 -subtitle_scale 1 -colour_lut 0 -j2k_bandwidth 200000000 -audio_language -subtitle_language -territory -rating -studio -facility -package_type -dci_date 20130211 -dcp_frame_rate 0 -width 0 -height 0 -length 0 -content_digest -external_audio_stream external 0 0 -source_frame_rate 0 diff --git a/test/pixel_formats_test.cc b/test/pixel_formats_test.cc index 84f2a33ce..fb2278fdb 100644 --- a/test/pixel_formats_test.cc +++ b/test/pixel_formats_test.cc @@ -43,9 +43,6 @@ struct Case BOOST_AUTO_TEST_CASE (pixel_formats_test) { - /* This needs to happen in the first test */ - dvdomatic_setup (); - list<Case> cases; cases.push_back(Case(AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 )); cases.push_back(Case(AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 )); @@ -65,6 +62,7 @@ BOOST_AUTO_TEST_CASE (pixel_formats_test) f->width = 640; f->height = 480; f->format = static_cast<int> (i->format); + av_frame_get_buffer (f, true); SimpleImage t (f); BOOST_CHECK_EQUAL(t.components(), i->components); BOOST_CHECK_EQUAL(t.lines(0), i->lines[0]); diff --git a/test/ratio_test.cc b/test/ratio_test.cc new file mode 100644 index 000000000..6311976a3 --- /dev/null +++ b/test/ratio_test.cc @@ -0,0 +1,73 @@ +/* + Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +using std::ostream; + +namespace libdcp { + +ostream& +operator<< (ostream& s, libdcp::Size const & t) +{ + s << t.width << "x" << t.height; + return s; +} + +} + +BOOST_AUTO_TEST_CASE (ratio_test) +{ + Ratio::setup_ratios (); + + Ratio const * r = Ratio::from_id ("119"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1285, 1080)); + + r = Ratio::from_id ("133"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1436, 1080)); + + r = Ratio::from_id ("137"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1480, 1080)); + + r = Ratio::from_id ("138"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1485, 1080)); + + r = Ratio::from_id ("166"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1793, 1080)); + + r = Ratio::from_id ("178"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1920, 1080)); + + r = Ratio::from_id ("185"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (1998, 1080)); + + r = Ratio::from_id ("239"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 858)); + + r = Ratio::from_id ("full-frame"); + BOOST_CHECK (r); + BOOST_CHECK_EQUAL (r->size(libdcp::Size (2048, 1080)), libdcp::Size (2048, 1080)); +} + diff --git a/test/scaling_test.cc b/test/scaling_test.cc new file mode 100644 index 000000000..dba611043 --- /dev/null +++ b/test/scaling_test.cc @@ -0,0 +1,72 @@ +/* + Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "imagemagick_content.h" + +/** @file test/scaling_test.cc + * @brief Test scaling and black-padding of images from a still-image source. + */ + +using boost::shared_ptr; + +static void scaling_test_for (shared_ptr<Film> film, shared_ptr<VideoContent> content, string image, string container) +{ + content->set_ratio (Ratio::from_id (image)); + film->set_container (Ratio::from_id (container)); + film->make_dcp (); + + while (JobManager::instance()->work_to_do ()); + + BOOST_CHECK (!JobManager::instance()->errors()); + + boost::filesystem::path ref; + ref = "test"; + ref /= "data"; + ref /= "scaling_test_" + image + "_" + container; + + boost::filesystem::path check; + check = "build"; + check /= "test"; + check /= "scaling_test"; + check /= film->dcp_name(); + + check_dcp (ref.string(), check.string()); +} + +BOOST_AUTO_TEST_CASE (scaling_test) +{ + shared_ptr<Film> film = new_test_film ("scaling_test"); + film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR")); + film->set_name ("scaling_test"); + shared_ptr<ImageMagickContent> imc (new ImageMagickContent (film, "test/data/simple_testcard_640x480.png")); + + film->examine_and_add_content (imc); + while (JobManager::instance()->work_to_do ()); + + imc->set_video_length (1); + + scaling_test_for (film, imc, "133", "185"); + scaling_test_for (film, imc, "185", "185"); + scaling_test_for (film, imc, "239", "185"); + + scaling_test_for (film, imc, "133", "239"); + scaling_test_for (film, imc, "185", "239"); + scaling_test_for (film, imc, "239", "239"); +} + diff --git a/test/stream_test.cc b/test/stream_test.cc index b467dc9a2..4d97e82af 100644 --- a/test/stream_test.cc +++ b/test/stream_test.cc @@ -19,6 +19,7 @@ BOOST_AUTO_TEST_CASE (stream_test) { +#if 0 FFmpegAudioStream a ("ffmpeg 4 44100 1 hello there world", boost::optional<int> (1)); BOOST_CHECK_EQUAL (a.id(), 4); BOOST_CHECK_EQUAL (a.sample_rate(), 44100); @@ -48,5 +49,6 @@ BOOST_AUTO_TEST_CASE (stream_test) BOOST_CHECK_EQUAL (fe->sample_rate(), 44100); BOOST_CHECK_EQUAL (fe->channel_layout(), 1); BOOST_CHECK_EQUAL (fe->to_string(), "external 44100 1"); +#endif } diff --git a/test/test.cc b/test/test.cc index 91c876412..7c7efd1a0 100644 --- a/test/test.cc +++ b/test/test.cc @@ -22,7 +22,8 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string/predicate.hpp> #include <boost/date_time.hpp> -#include "format.h" +#include <libdcp/dcp.h> +#include "ratio.h" #include "film.h" #include "filter.h" #include "job_manager.h" @@ -39,15 +40,17 @@ #include "scaler.h" #include "ffmpeg_decoder.h" #include "sndfile_decoder.h" -#include "trimmer.h" +#include "dcp_content_type.h" #define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE dvdomatic_test +#define BOOST_TEST_MODULE dcpomatic_test #include <boost/test/unit_test.hpp> using std::string; using std::list; using std::stringstream; using std::vector; +using std::min; +using std::cout; using boost::shared_ptr; using boost::thread; using boost::dynamic_pointer_cast; @@ -56,12 +59,14 @@ struct TestConfig { TestConfig() { - dvdomatic_setup(); + dcpomatic_setup(); Config::instance()->set_num_local_encoding_threads (1); Config::instance()->set_servers (vector<ServerDescription*> ()); Config::instance()->set_server_port (61920); Config::instance()->set_default_dci_metadata (DCIMetadata ()); + Config::instance()->set_default_container (0); + Config::instance()->set_default_dcp_content_type (0); } }; @@ -85,17 +90,75 @@ new_test_film (string name) boost::filesystem::remove_all (p); } - return shared_ptr<Film> (new Film (p.string(), false)); + shared_ptr<Film> f = shared_ptr<Film> (new Film (p.string())); + f->write_metadata (); + return f; } +void +check_file (string ref, string check) +{ + uintmax_t N = boost::filesystem::file_size (ref); + BOOST_CHECK_EQUAL (N, boost::filesystem::file_size(check)); + FILE* ref_file = fopen (ref.c_str(), "rb"); + BOOST_CHECK (ref_file); + FILE* check_file = fopen (check.c_str(), "rb"); + BOOST_CHECK (check_file); + + int const buffer_size = 65536; + uint8_t* ref_buffer = new uint8_t[buffer_size]; + uint8_t* check_buffer = new uint8_t[buffer_size]; + + while (N) { + uintmax_t this_time = min (uintmax_t (buffer_size), N); + size_t r = fread (ref_buffer, 1, this_time, ref_file); + BOOST_CHECK_EQUAL (r, this_time); + r = fread (check_buffer, 1, this_time, check_file); + BOOST_CHECK_EQUAL (r, this_time); + + BOOST_CHECK_EQUAL (memcmp (ref_buffer, check_buffer, this_time), 0); + N -= this_time; + } + + delete[] ref_buffer; + delete[] check_buffer; + + fclose (ref_file); + fclose (check_file); +} + +static void +note (libdcp::NoteType, string n) +{ + cout << n << "\n"; +} + +void +check_dcp (string ref, string check) +{ + libdcp::DCP ref_dcp (ref); + ref_dcp.read (); + libdcp::DCP check_dcp (check); + check_dcp.read (); + + libdcp::EqualityOptions options; + options.max_mean_pixel_error = 5; + options.max_std_dev_pixel_error = 5; + options.max_audio_sample_error = 255; + options.cpl_names_can_differ = true; + options.mxf_names_can_differ = true; + + BOOST_CHECK (ref_dcp.equals (check_dcp, options, boost::bind (note, _1, _2))); +} + +#include "black_fill_test.cc" +#include "scaling_test.cc" +#include "ratio_test.cc" #include "pixel_formats_test.cc" #include "make_black_test.cc" -#include "trimmer_test.cc" #include "film_metadata_test.cc" #include "stream_test.cc" -#include "format_test.cc" #include "util_test.cc" -#include "film_test.cc" #include "dcp_test.cc" #include "frame_rate_test.cc" #include "job_test.cc" diff --git a/test/test.mp4 b/test/test.mp4 Binary files differdeleted file mode 100644 index 811e397f6..000000000 --- a/test/test.mp4 +++ /dev/null diff --git a/test/trimmer_test.cc b/test/trimmer_test.cc deleted file mode 100644 index 605f7d1b2..000000000 --- a/test/trimmer_test.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -using boost::shared_ptr; - -shared_ptr<const Image> trimmer_test_last_video; -shared_ptr<const AudioBuffers> trimmer_test_last_audio; - -void -trimmer_test_video_helper (shared_ptr<const Image> image, bool, shared_ptr<Subtitle>) -{ - trimmer_test_last_video = image; -} - -void -trimmer_test_audio_helper (shared_ptr<const AudioBuffers> audio) -{ - trimmer_test_last_audio = audio; -} - -BOOST_AUTO_TEST_CASE (trimmer_passthrough_test) -{ - Trimmer trimmer (shared_ptr<Log> (), 0, 0, 200, 48000, 25, 25); - trimmer.Video.connect (bind (&trimmer_test_video_helper, _1, _2, _3)); - trimmer.Audio.connect (bind (&trimmer_test_audio_helper, _1)); - - shared_ptr<SimpleImage> video (new SimpleImage (PIX_FMT_RGB24, libdcp::Size (1998, 1080), true)); - shared_ptr<AudioBuffers> audio (new AudioBuffers (6, 42 * 1920)); - - trimmer.process_video (video, false, shared_ptr<Subtitle> ()); - trimmer.process_audio (audio); - - BOOST_CHECK_EQUAL (video.get(), trimmer_test_last_video.get()); - BOOST_CHECK_EQUAL (audio.get(), trimmer_test_last_audio.get()); - BOOST_CHECK_EQUAL (audio->frames(), trimmer_test_last_audio->frames()); -} - - -/** Test the audio handling of the Trimmer */ -BOOST_AUTO_TEST_CASE (trimmer_audio_test) -{ - Trimmer trimmer (shared_ptr<Log> (), 25, 75, 200, 48000, 25, 25); - - trimmer.Audio.connect (bind (&trimmer_test_audio_helper, _1)); - - /* 21 video frames-worth of audio frames; should be completely stripped */ - trimmer_test_last_audio.reset (); - shared_ptr<AudioBuffers> audio (new AudioBuffers (6, 21 * 1920)); - trimmer.process_audio (audio); - BOOST_CHECK (trimmer_test_last_audio == 0); - - /* 42 more video frames-worth, 4 should be stripped from the start */ - audio.reset (new AudioBuffers (6, 42 * 1920)); - trimmer.process_audio (audio); - BOOST_CHECK (trimmer_test_last_audio); - BOOST_CHECK_EQUAL (trimmer_test_last_audio->frames(), 38 * 1920); - - /* 42 more video frames-worth, should be kept as-is */ - trimmer_test_last_audio.reset (); - audio.reset (new AudioBuffers (6, 42 * 1920)); - trimmer.process_audio (audio); - BOOST_CHECK (trimmer_test_last_audio); - BOOST_CHECK_EQUAL (trimmer_test_last_audio->frames(), 42 * 1920); - - /* 25 more video frames-worth, 5 should be trimmed from the end */ - trimmer_test_last_audio.reset (); - audio.reset (new AudioBuffers (6, 25 * 1920)); - trimmer.process_audio (audio); - BOOST_CHECK (trimmer_test_last_audio); - BOOST_CHECK_EQUAL (trimmer_test_last_audio->frames(), 20 * 1920); - - /* Now some more; all should be trimmed */ - trimmer_test_last_audio.reset (); - audio.reset (new AudioBuffers (6, 100 * 1920)); - trimmer.process_audio (audio); - BOOST_CHECK (trimmer_test_last_audio == 0); -} - - diff --git a/test/util_test.cc b/test/util_test.cc index 18c24ac3a..f75fd0e70 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE (util_test) BOOST_AUTO_TEST_CASE (md5_digest_test) { - string const t = md5_digest ("test/md5.test"); + string const t = md5_digest ("test/data/md5.test"); BOOST_CHECK_EQUAL (t, "15058685ba99decdc4398c7634796eb0"); BOOST_CHECK_THROW (md5_digest ("foobar"), OpenFileError); diff --git a/test/wscript b/test/wscript index f1a508a53..2fbbdacbf 100644 --- a/test/wscript +++ b/test/wscript @@ -12,8 +12,8 @@ def configure(conf): def build(bld): obj = bld(features = 'cxx cxxprogram') obj.name = 'unit-tests' - obj.uselib = 'BOOST_TEST DCP OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC' - obj.use = 'libdvdomatic' + obj.uselib = 'BOOST_TEST CXML DCP OPENJPEG AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC' + obj.use = 'libdcpomatic' obj.source = 'test.cc' obj.target = 'unit-tests' obj.install_path = '' |
