Remove unnecessary method.
[dcpomatic.git] / test / test.cc
index 4dab0cff1b5895c0e197e19c0db140092662757e..a12d79916463f7eb23589ef2e76b472d2e4a537f 100644 (file)
@@ -38,6 +38,7 @@
 #include "lib/job.h"
 #include "lib/job_manager.h"
 #include "lib/log_entry.h"
+#include "lib/make_dcp.h"
 #include "lib/ratio.h"
 #include "lib/signal_manager.h"
 #include "lib/util.h"
@@ -99,10 +100,10 @@ boost::filesystem::path TestPaths::xsd ()
 }
 
 
-void
+static void
 setup_test_config ()
 {
-       Config::instance()->set_master_encoding_threads (boost::thread::hardware_concurrency());
+       Config::instance()->set_master_encoding_threads (boost::thread::hardware_concurrency() / 2);
        Config::instance()->set_server_encoding_threads (1);
        Config::instance()->set_server_port_base (61921);
        Config::instance()->set_default_container (Ratio::from_id ("185"));
@@ -129,7 +130,7 @@ class TestSignalManager : public SignalManager
 {
 public:
        /* No wakes in tests: we call ui_idle ourselves */
-       void wake_ui ()
+       void wake_ui () override
        {
 
        }
@@ -364,12 +365,12 @@ double
 rms_error (boost::filesystem::path ref, boost::filesystem::path check)
 {
        FFmpegImageProxy ref_proxy (ref);
-       auto ref_image = ref_proxy.image().image;
+       auto ref_image = ref_proxy.image(Image::Alignment::COMPACT).image;
        FFmpegImageProxy check_proxy (check);
-       auto check_image = check_proxy.image().image;
+       auto check_image = check_proxy.image(Image::Alignment::COMPACT).image;
 
        BOOST_REQUIRE_EQUAL (ref_image->pixel_format(), check_image->pixel_format());
-       AVPixelFormat const format = ref_image->pixel_format();
+       auto const format = ref_image->pixel_format();
 
        BOOST_REQUIRE (ref_image->size() == check_image->size());
        int const width = ref_image->size().width;
@@ -700,7 +701,7 @@ png_flush (png_structp)
 static void
 png_error_fn (png_structp png_ptr, char const * message)
 {
-       reinterpret_cast<Image*>(png_get_error_ptr(png_ptr))->png_error (message);
+       throw EncodeError (String::compose("Error during PNG write: %1", message));
 }
 
 
@@ -893,7 +894,7 @@ void
 make_and_verify_dcp (shared_ptr<Film> film, vector<dcp::VerificationNote::Code> ignore)
 {
        film->write_metadata ();
-       film->make_dcp ();
+       make_dcp (film, TranscodeJob::ChangedBehaviour::IGNORE);
        BOOST_REQUIRE (!wait_for_jobs());
        auto notes = dcp::verify ({film->dir(film->dcp_name())}, &stage, &progress, TestPaths::xsd());
        bool ok = true;
@@ -920,3 +921,10 @@ check_int_close (std::pair<int, int> a, std::pair<int, int> b, int d)
        check_int_close (a.first, b.first, d);
        check_int_close (a.second, b.second, d);
 }
+
+
+ConfigRestorer::~ConfigRestorer()
+{
+       setup_test_config();
+}
+