Verify a whole bunch of DCPs made by unit tests.
[dcpomatic.git] / test / test.cc
index 6c811221d9a3de55d7ef03017cf602f9d0e7739c..eba0fc49055cb8747edc5de568a1b46f9dd0fe6d 100644 (file)
@@ -176,17 +176,26 @@ new_test_film (string name)
 }
 
 shared_ptr<Film>
-new_test_film2 (string name)
+new_test_film2 (string name, vector<shared_ptr<Content>> content, Cleanup* cleanup)
 {
        auto p = test_film_dir (name);
        if (boost::filesystem::exists (p)) {
                boost::filesystem::remove_all (p);
        }
+       if (cleanup) {
+               cleanup->add (p);
+       }
 
        auto film = make_shared<Film>(p);
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
        film->set_container (Ratio::from_id ("185"));
        film->write_metadata ();
+
+       for (auto i: content) {
+               film->examine_and_add_content (i);
+               BOOST_REQUIRE (!wait_for_jobs());
+       }
+
        return film;
 }
 
@@ -811,3 +820,42 @@ operator<< (std::ostream&s, VideoFrameType f)
        return s;
 }
 
+
+void
+Cleanup::add (boost::filesystem::path path)
+{
+       _paths.push_back (path);
+}
+
+
+void
+Cleanup::run ()
+{
+       boost::system::error_code ec;
+       for (auto i: _paths) {
+               boost::filesystem::remove_all (i, ec);
+       }
+}
+
+
+void stage (string, boost::optional<boost::filesystem::path>) {}
+void progress (float) {}
+
+
+void
+make_and_verify_dcp (shared_ptr<Film> film, vector<dcp::VerificationNote::Code> ignore)
+{
+       film->write_metadata ();
+       film->make_dcp ();
+       BOOST_REQUIRE (!wait_for_jobs());
+       auto notes = dcp::verify ({film->dir(film->dcp_name())}, &stage, &progress, TestPaths::xsd());
+       bool ok = true;
+       for (auto i: notes) {
+               if (find(ignore.begin(), ignore.end(), i.code()) == ignore.end()) {
+                       std::cout << "\t" << dcp::note_to_string(i) << "\n";
+                       ok = false;
+               }
+       }
+       BOOST_CHECK(ok);
+}
+