2 Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/content.h"
23 #include "lib/content_factory.h"
25 #include "lib/hints.h"
26 #include "lib/text_content.h"
29 #include <boost/shared_ptr.hpp>
30 #include <boost/test/unit_test.hpp>
35 using boost::shared_ptr;
38 vector<string> current_hints;
43 collect_hint (string hint)
45 current_hints.push_back (hint);
51 get_hints (shared_ptr<Film> film)
53 current_hints.clear ();
55 hints.Hint.connect (collect_hint);
58 while (signal_manager->ui_idle()) {}
65 check (TextType type, string name, string expected_hint)
67 shared_ptr<Film> film = new_test_film2 (name);
68 shared_ptr<Content> content = content_factory("test/data/" + name + ".srt").front();
69 content->text.front()->set_type (type);
70 film->examine_and_add_content (content);
71 BOOST_REQUIRE (!wait_for_jobs());
72 vector<string> hints = get_hints (film);
74 BOOST_REQUIRE_EQUAL (hints.size(), 1);
75 BOOST_CHECK_EQUAL (hints[0], expected_hint);
79 BOOST_AUTO_TEST_CASE (hint_closed_caption_too_long)
83 "hint_closed_caption_too_long",
84 String::compose("At least one of your closed caption lines has more than %1 characters. It is advisable to make each line %1 characters at most in length.", MAX_CLOSED_CAPTION_LENGTH, MAX_CLOSED_CAPTION_LENGTH)
89 BOOST_AUTO_TEST_CASE (hint_many_closed_caption_lines)
93 "hint_many_closed_caption_lines",
94 String::compose("Some of your closed captions span more than %1 lines, so they will be truncated.", MAX_CLOSED_CAPTION_LINES)
99 BOOST_AUTO_TEST_CASE (hint_subtitle_too_early)
103 "hint_subtitle_too_early",
104 "It is advisable to put your first subtitle at least 4 seconds after the start of the DCP to make sure it is seen."
109 BOOST_AUTO_TEST_CASE (hint_short_subtitles)
113 "hint_short_subtitles",
114 "At least one of your subtitles lasts less than 15 frames. It is advisable to make each subtitle at least 15 frames long."
119 BOOST_AUTO_TEST_CASE (hint_subtitles_too_close)
123 "hint_subtitles_too_close",
124 "At least one of your subtitles starts less than 2 frames after the previous one. It is advisable to make the gap between subtitles at least 2 frames."
129 BOOST_AUTO_TEST_CASE (hint_many_subtitle_lines)
133 "hint_many_subtitle_lines",
134 "At least one of your subtitles has more than 3 lines. It is advisable to use no more than 3 lines."
139 BOOST_AUTO_TEST_CASE (hint_subtitle_too_long)
143 "hint_subtitle_too_long",
144 "At least one of your subtitle lines has more than 52 characters. It is advisable to make each line 52 characters at most in length."