std::shared_ptr
[dcpomatic.git] / test / test.cc
index 5aee442309de2dc07a507f9cc4247a97204958e5..19e8f978a481977ee51bb59c84252fe3c8bc9679 100644 (file)
@@ -68,12 +68,31 @@ using std::cout;
 using std::cerr;
 using std::list;
 using std::abs;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::scoped_array;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+
+
+boost::filesystem::path
+TestPaths::TestPaths::private_data ()
+{
+       char* env = getenv("DCPOMATIC_TEST_PRIVATE");
+       if (env) {
+               return boost::filesystem::path(env);
+       }
+
+       return boost::filesystem::canonical(boost::filesystem::path ("..") / boost::filesystem::path ("dcpomatic-test-private"));
+}
+
+
+boost::filesystem::path TestPaths::xsd ()
+{
+       return boost::filesystem::canonical(boost::filesystem::path("..") / boost::filesystem::path("libdcp") / boost::filesystem::path("xsd"));
+}
 
-boost::filesystem::path TestPaths::TestPaths::private_data = boost::filesystem::canonical(boost::filesystem::path ("..") / boost::filesystem::path ("dcpomatic-test-private"));
-boost::filesystem::path TestPaths::xsd = boost::filesystem::canonical(boost::filesystem::path("..") / boost::filesystem::path("libdcp") / boost::filesystem::path("xsd"));
 
 void
 setup_test_config ()
@@ -89,7 +108,10 @@ setup_test_config ()
        Config::instance()->set_default_interop (false);
        Config::instance()->set_default_still_length (10);
        Config::instance()->set_log_types (
-               LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR | LogEntry::TYPE_DEBUG_THREED | LogEntry::TYPE_DEBUG_ENCODE | LogEntry::TYPE_DEBUG_PLAYER
+               LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING |
+               LogEntry::TYPE_ERROR | LogEntry::TYPE_DEBUG_THREED |
+               LogEntry::TYPE_DEBUG_ENCODE | LogEntry::TYPE_DEBUG_PLAYER |
+               LogEntry::TYPE_DISK
                );
        Config::instance()->set_automatic_audio_analysis (false);
 }
@@ -118,11 +140,6 @@ struct TestConfig
 
                signal_manager = new TestSignalManager ();
 
-               char* env_private = getenv("DCPOMATIC_TEST_PRIVATE");
-               if (env_private) {
-                       TestPaths::TestPaths::private_data = env_private;
-               }
-
                dcpomatic_log.reset (new FileLog("build/test/log"));
        }
 
@@ -322,9 +339,9 @@ static
 double
 rms_error (boost::filesystem::path ref, boost::filesystem::path check)
 {
-       FFmpegImageProxy ref_proxy (ref);
+       FFmpegImageProxy ref_proxy (ref, VIDEO_RANGE_FULL);
        shared_ptr<Image> ref_image = ref_proxy.image().image;
-       FFmpegImageProxy check_proxy (check);
+       FFmpegImageProxy check_proxy (check, VIDEO_RANGE_FULL);
        shared_ptr<Image> check_image = check_proxy.image().image;
 
        BOOST_REQUIRE_EQUAL (ref_image->pixel_format(), check_image->pixel_format());
@@ -673,7 +690,7 @@ write_image (shared_ptr<const Image> image, boost::filesystem::path file)
        png_destroy_write_struct (&png_ptr, &info_ptr);
        png_free (png_ptr, row_pointers);
 
-       dcp::Data(state.data, state.size).write(file);
+       dcp::ArrayData(state.data, state.size).write(file);
 }
 
 
@@ -751,24 +768,13 @@ subtitle_file (shared_ptr<Film> film)
 void
 make_random_file (boost::filesystem::path path, size_t size)
 {
-       size_t const chunk = 128 * 1024;
-       uint8_t* buffer = static_cast<uint8_t*> (malloc(chunk));
-       BOOST_REQUIRE (buffer);
-       FILE* r = fopen("/dev/urandom", "rb");
-       BOOST_REQUIRE (r);
        FILE* t = fopen_boost(path, "wb");
        BOOST_REQUIRE (t);
-       while (size) {
-               size_t this_time = min (size, chunk);
-               size_t N = fread (buffer, 1, this_time, r);
-               BOOST_REQUIRE (N == this_time);
-               N = fwrite (buffer, 1, this_time, t);
-               BOOST_REQUIRE (N == this_time);
-               size -= this_time;
+       for (size_t i = 0; i < size; ++i) {
+               uint8_t r = rand() & 0xff;
+               fwrite (&r, 1, 1, t);
        }
        fclose (t);
-       fclose (r);
-       free (buffer);
 }