From d19b7cbd3d1a428697bc9b26fdc0be36fafa444a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 12 Jul 2013 13:49:57 +0100 Subject: Add silence padding test. --- test/silence_padding_test.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++ test/test.cc | 1 + 2 files changed, 61 insertions(+) create mode 100644 test/silence_padding_test.cc (limited to 'test') diff --git a/test/silence_padding_test.cc b/test/silence_padding_test.cc new file mode 100644 index 000000000..e3b0243e0 --- /dev/null +++ b/test/silence_padding_test.cc @@ -0,0 +1,60 @@ +/* + Copyright (C) 2013 Carl Hetherington + + 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 +#include +#include +#include +#include "sndfile_content.h" + +using boost::lexical_cast; + +static void test_silence_padding (int channels) +{ + string const film_name = "silence_padding_test_" + lexical_cast (channels); + shared_ptr film = new_test_film (film_name); + film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR")); + film->set_container (Ratio::from_id ("185")); + film->set_name (film_name); + + shared_ptr content (new SndfileContent (film, "test/data/staircase.wav")); + film->examine_and_add_content (content); + wait_for_jobs (); + + film->set_dcp_audio_channels (channels); + film->make_dcp (); + wait_for_jobs (); + + boost::filesystem::path path = "build/test"; + path /= film_name; + path /= film->dcp_name (); + libdcp::DCP check (path.string ()); + check.read (); + + shared_ptr sound_asset = check.cpls().front()->reels().front()->main_sound (); + BOOST_CHECK (sound_asset); + BOOST_CHECK (sound_asset->channels () == channels); +} + +BOOST_AUTO_TEST_CASE (silence_padding_test) +{ + for (int i = 1; i < MAX_AUDIO_CHANNELS; ++i) { + test_silence_padding (i); + } +} diff --git a/test/test.cc b/test/test.cc index dfa38c8f4..1f0d2db5b 100644 --- a/test/test.cc +++ b/test/test.cc @@ -160,6 +160,7 @@ wait_for_jobs () while (JobManager::instance()->work_to_do ()) {} } +#include "silence_padding_test.cc" #include "audio_delay_test.cc" #include "ffmpeg_pts_offset.cc" #include "ffmpeg_examiner_test.cc" -- cgit v1.2.3