summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-12-26 00:16:45 +0100
committerCarl Hetherington <cth@carlh.net>2022-04-29 01:10:35 +0200
commitaf85c3bb844599895eda780083fb9466cdfc8e76 (patch)
treee63e6bf28d23077fb5bf3df9324239e31a0389af /test
parentd394f2a171235fcbd5bdaf07c3b9b91529368538 (diff)
Add guess_crop().
Diffstat (limited to 'test')
-rw-r--r--test/guess_crop_test.cc69
-rw-r--r--test/wscript1
2 files changed, 70 insertions, 0 deletions
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 <cth@carlh.net>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#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 <boost/test/unit_test.hpp>
+#include <iostream>
+#include <vector>
+
+
+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