summaryrefslogtreecommitdiff
path: root/test/writer_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-11-12 22:09:48 +0100
committerCarl Hetherington <cth@carlh.net>2023-11-20 07:29:15 +0100
commitdb4fde2e8983eaa0b76c49a189e059d6c9f5720d (patch)
treed19f2cbd88fa4bb23a3a18213f24cf06964e1b75 /test/writer_test.cc
parent796ac1e76ff47b2e4dad2b3ef10458d8befac5d8 (diff)
Improve progress reporting of digest calculations (might help with #2643).
Diffstat (limited to 'test/writer_test.cc')
-rw-r--r--test/writer_test.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/writer_test.cc b/test/writer_test.cc
index 76e9ddb28..86b60818f 100644
--- a/test/writer_test.cc
+++ b/test/writer_test.cc
@@ -23,6 +23,7 @@
#include "lib/content.h"
#include "lib/content_factory.h"
#include "lib/cross.h"
+#include "lib/dcp_encoder.h"
#include "lib/film.h"
#include "lib/job.h"
#include "lib/video_content.h"
@@ -36,6 +37,7 @@
using std::make_shared;
using std::shared_ptr;
+using std::string;
using std::vector;
@@ -101,3 +103,53 @@ BOOST_AUTO_TEST_CASE (interrupt_writer)
dcpomatic_sleep_seconds (1);
cl.run ();
}
+
+
+BOOST_AUTO_TEST_CASE(writer_progress_test)
+{
+ class TestJob : public Job
+ {
+ public:
+ explicit TestJob(shared_ptr<const Film> film)
+ : Job(film)
+ {}
+
+ ~TestJob()
+ {
+ stop_thread();
+ }
+
+ std::string name() const override {
+ return "test";
+ }
+ std::string json_name() const override {
+ return "test";
+ }
+ void run() override {};
+ };
+
+ auto picture1 = content_factory("test/data/flat_red.png")[0];
+ auto picture2 = content_factory("test/data/flat_red.png")[0];
+
+ auto film = new_test_film2("writer_progress_test", { picture1, picture2 });
+ film->set_reel_type(ReelType::BY_VIDEO_CONTENT);
+ picture1->video->set_length(240);
+ picture2->video->set_length(240);
+ picture2->set_position(film, dcpomatic::DCPTime::from_seconds(10));
+
+ auto job = std::make_shared<TestJob>(film);
+ job->set_rate_limit_progress(false);
+
+ float last_progress = 0;
+ string last_sub_name;
+ boost::signals2::scoped_connection connection = job->Progress.connect([job, &last_progress, &last_sub_name]() {
+ auto const progress = job->progress().get_value_or(0);
+ BOOST_REQUIRE(job->sub_name() != last_sub_name || progress >= last_progress);
+ last_progress = progress;
+ last_sub_name = job->sub_name();
+ });
+
+ DCPEncoder encoder(film, job);
+ encoder.go();
+}
+