Supporters update.
[dcpomatic.git] / test / job_manager_test.cc
index cdd1e2a29871069b7367328c048febfd8580f146..4a2f8bde5f97e8849dfb0347d273c6a0edba63c8 100644 (file)
@@ -59,20 +59,21 @@ public:
                set_state (FINISHED_ERROR);
        }
 
-       void run ()
+       void run () override
        {
                while (true) {
                        if (finished ()) {
                                return;
                        }
+                       boost::this_thread::interruption_point();
                }
        }
 
-       string name () const {
+       string name () const override {
                return "";
        }
 
-       string json_name () const {
+       string json_name () const override {
                return "";
        }
 };
@@ -139,3 +140,24 @@ BOOST_AUTO_TEST_CASE (job_manager_test2)
        BOOST_REQUIRE (!wait_for_jobs());
 }
 
+
+BOOST_AUTO_TEST_CASE(cancel_job_test)
+{
+       shared_ptr<Film> film;
+
+       vector<shared_ptr<TestJob>> jobs;
+       for (int i = 0; i < 2; ++i) {
+               auto job = make_shared<TestJob>(film);
+               jobs.push_back(job);
+               JobManager::instance()->add(job);
+       }
+
+       jobs[1]->cancel();
+       jobs[0]->cancel();
+
+       dcpomatic_sleep_seconds(1);
+
+       BOOST_CHECK(jobs[0]->finished_cancelled());
+       BOOST_CHECK(jobs[1]->finished_cancelled());
+}
+