Add --no-asset-hash-check and --asset-hash-check-maximum-size (DoM #2444).
[libdcp.git] / test / verify_test.cc
index 652bf12da894220e1337b8182e2ab6a5fad8729b..cde498309fe7f52776611dd67f1cf9ea905ffb22 100644 (file)
@@ -297,7 +297,7 @@ static
 void
 check_verify_result (vector<path> dir, vector<dcp::VerificationNote> test_notes)
 {
-       auto notes = dcp::verify ({dir}, &stage, &progress, xsd_test);
+       auto notes = dcp::verify({dir}, &stage, &progress, {}, xsd_test);
        std::sort (notes.begin(), notes.end());
        std::sort (test_notes.begin(), test_notes.end());
 
@@ -345,7 +345,7 @@ check_verify_result_after_replace (string suffix, boost::function<path (string)>
                e.replace (from, to);
        }
 
-       auto notes = dcp::verify ({dir}, &stage, &progress, xsd_test);
+       auto notes = dcp::verify({dir}, &stage, &progress, {}, xsd_test);
 
        BOOST_REQUIRE_EQUAL (notes.size(), codes.size());
        auto i = notes.begin();
@@ -362,7 +362,7 @@ BOOST_AUTO_TEST_CASE (verify_no_error)
 {
        stages.clear ();
        auto dir = setup (1, "no_error");
-       auto notes = dcp::verify ({dir}, &stage, &progress, xsd_test);
+       auto notes = dcp::verify({dir}, &stage, &progress, {}, xsd_test);
 
        path const cpl_file = dir / dcp_test1_cpl;
        path const pkl_file = dir / dcp_test1_pkl;
@@ -603,7 +603,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_standard)
 {
        stages.clear ();
        auto dir = setup (3, "verify_invalid_standard");
-       auto notes = dcp::verify ({dir}, &stage, &progress, xsd_test);
+       auto notes = dcp::verify({dir}, &stage, &progress, {}, xsd_test);
 
        path const cpl_file = dir / "cpl_cbfd2bc0-21cf-4a8f-95d8-9cddcbe51296.xml";
        path const pkl_file = dir / "pkl_d87a950c-bd6f-41f6-90cc-56ccd673e131.xml";
@@ -806,6 +806,25 @@ BOOST_AUTO_TEST_CASE (verify_invalid_interop_subtitles)
 }
 
 
+BOOST_AUTO_TEST_CASE(verify_interop_subtitle_asset_with_no_subtitles)
+{
+       path const dir("build/test/verify_interop_subtitle_asset_with_no_subtitles");
+       prepare_directory(dir);
+       copy_file("test/data/subs4.xml", dir / "subs.xml");
+       auto asset = make_shared<dcp::InteropSubtitleAsset>(dir / "subs.xml");
+       auto reel_asset = make_shared<dcp::ReelInteropSubtitleAsset>(asset, dcp::Fraction(24, 1), 16 * 24, 0);
+       write_dcp_with_single_asset(dir, reel_asset, dcp::Standard::INTEROP);
+
+       check_verify_result (
+               { dir },
+               {
+                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_STANDARD },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISSING_SUBTITLE, asset->id(), boost::filesystem::canonical(asset->file().get()) },
+               });
+
+}
+
+
 BOOST_AUTO_TEST_CASE (verify_valid_smpte_subtitles)
 {
        path const dir("build/test/verify_valid_smpte_subtitles");
@@ -815,7 +834,12 @@ BOOST_AUTO_TEST_CASE (verify_valid_smpte_subtitles)
        auto reel_asset = make_shared<dcp::ReelSMPTESubtitleAsset>(asset, dcp::Fraction(24, 1), 6046, 0);
        auto cpl = write_dcp_with_single_asset (dir, reel_asset);
 
-       check_verify_result ({dir}, {{ dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() }});
+       check_verify_result(
+               {dir},
+               {
+                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() },
+                       { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_ISSUE_DATE, string{"2021-04-14T13:19:14.000+02:00"} }
+               });
 }
 
 
@@ -844,6 +868,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_smpte_subtitles)
                        },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_SUBTITLE_START_TIME, canonical(dir / "subs.mxf") },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() },
+                       { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_ISSUE_DATE, string{"2020-05-09T00:29:21.000+02:00"} }
                });
 }
 
@@ -864,6 +889,7 @@ BOOST_AUTO_TEST_CASE (verify_empty_text_node_in_subtitles)
                        { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, canonical(dir / "subs.mxf") },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() },
+                       { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_ISSUE_DATE, string{"2021-08-09T18:34:46.000+02:00"} }
                });
 }
 
@@ -899,6 +925,7 @@ BOOST_AUTO_TEST_CASE (verify_empty_text_node_in_subtitles_with_empty_child_nodes
        check_verify_result (
                { dir },
                {
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISSING_SUBTITLE, asset->id(), boost::filesystem::canonical(asset->file().get()) },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_STANDARD },
                        { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::EMPTY_TEXT },
                });
@@ -1218,7 +1245,7 @@ check_picture_size (int width, int height, int frame_rate, bool three_d)
        d->set_annotation_text("A Test DCP");
        d->write_xml();
 
-       return dcp::verify ({dcp_path}, &stage, &progress, xsd_test);
+       return dcp::verify({dcp_path}, &stage, &progress, {}, xsd_test);
 }
 
 
@@ -1366,7 +1393,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_xml_size_in_bytes)
                        {
                                dcp::VerificationNote::Type::BV21_ERROR,
                                dcp::VerificationNote::Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES,
-                               string("419346"),
+                               string("419336"),
                                canonical(dir / "subs.mxf")
                        },
                        { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME },
@@ -1406,7 +1433,7 @@ verify_timed_text_asset_too_large (string name)
        check_verify_result (
                { dir },
                {
-                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_TIMED_TEXT_SIZE_IN_BYTES, string("121695542"), canonical(dir / "subs.mxf") },
+                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_TIMED_TEXT_SIZE_IN_BYTES, string("121695532"), canonical(dir / "subs.mxf") },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_TIMED_TEXT_FONT_SIZE_IN_BYTES, string("121634816"), canonical(dir / "subs.mxf") },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_SUBTITLE_START_TIME, canonical(dir / "subs.mxf") },
                        { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME },
@@ -2339,7 +2366,7 @@ BOOST_AUTO_TEST_CASE (verify_missing_main_subtitle_from_some_reels)
                        { dir },
                        {
                                { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_MAIN_SUBTITLE_FROM_SOME_REELS },
-                               { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() }
+                               { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() },
                        });
 
        }
@@ -2476,7 +2503,7 @@ verify_text_entry_point_check (path dir, dcp::VerificationNote::Code code, boost
                {dir},
                {
                        { dcp::VerificationNote::Type::BV21_ERROR, code, subs->id() },
-                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() }
+                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() },
                });
 }
 
@@ -3094,7 +3121,7 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_subtitle_resource_id)
                "<Id>urn:uuid:%1</Id>"
                "<ContentTitleText>Content</ContentTitleText>"
                "<AnnotationText>Annotation</AnnotationText>"
-               "<IssueDate>2018-10-02T12:25:14+02:00</IssueDate>"
+               "<IssueDate>2018-10-02T12:25:14</IssueDate>"
                "<ReelNumber>1</ReelNumber>"
                "<Language>en-US</Language>"
                "<EditRate>25 1</EditRate>"
@@ -3187,7 +3214,8 @@ BOOST_AUTO_TEST_CASE (verify_incorrect_timed_text_id)
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_TIMED_TEXT_DURATION , "240 0", boost::filesystem::canonical(subs_mxf) },
                        { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INCORRECT_TIMED_TEXT_ASSET_ID },
                        { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME },
-                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() }
+                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() },
+                       { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_ISSUE_DATE, string{"2018-10-02T12:25:14+02:00"} }
                });
 }