From af85c3bb844599895eda780083fb9466cdfc8e76 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 26 Dec 2021 00:16:45 +0100 Subject: Add guess_crop(). --- test/guess_crop_test.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ test/wscript | 1 + 2 files changed, 70 insertions(+) create mode 100644 test/guess_crop_test.cc (limited to 'test') diff --git a/test/guess_crop_test.cc b/test/guess_crop_test.cc new file mode 100644 index 000000000..c26fc5ee4 --- /dev/null +++ b/test/guess_crop_test.cc @@ -0,0 +1,69 @@ +/* + Copyright (C) 2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see . + +*/ + + +#include "lib/content.h" +#include "lib/content_factory.h" +#include "lib/guess_crop.h" +#include "lib/types.h" +#include "lib/video_content.h" +#include "test.h" +#include +#include +#include + + +using namespace dcpomatic; + + +BOOST_AUTO_TEST_CASE (guess_crop_image_test1) +{ + auto content = content_factory(TestPaths::private_data() / "arrietty_724.tiff").front(); + auto film = new_test_film2 ("guess_crop_image_test1", { content }); + + BOOST_CHECK ( + guess_crop(film, content, 0.1, ContentTime::from_frames(content->video->length(), content->video_frame_rate().get())) + == Crop(0, 0, 11, 11) + ); +} + + +BOOST_AUTO_TEST_CASE (guess_crop_image_test2) +{ + auto content = content_factory(TestPaths::private_data() / "prophet_frame.tiff").front(); + auto film = new_test_film2 ("guess_crop_image_test2", { content }); + + BOOST_CHECK ( + guess_crop(film, content, 0.1, ContentTime::from_frames(content->video->length(), content->video_frame_rate().get())) + == Crop(0, 0, 22, 22) + ); +} + + +BOOST_AUTO_TEST_CASE (guess_crop_image_test3) +{ + auto content = content_factory(TestPaths::private_data() / "pillarbox.png").front(); + auto film = new_test_film2 ("guess_crop_image_test3", { content }); + + BOOST_CHECK ( + guess_crop(film, content, 0.1, ContentTime::from_frames(content->video->length(), content->video_frame_rate().get())) + == Crop(113, 262, 0, 0) + ); +} diff --git a/test/wscript b/test/wscript index 1178264f0..4e28f1740 100644 --- a/test/wscript +++ b/test/wscript @@ -91,6 +91,7 @@ def build(bld): film_metadata_test.cc frame_interval_checker_test.cc frame_rate_test.cc + guess_crop_test.cc hints_test.cc image_content_fade_test.cc image_filename_sorter_test.cc -- cgit v1.2.3