Add verify test to check for erroneous <EntryPoint> and <Duration> 2215-markers v1.8.13
authorCarl Hetherington <cth@carlh.net>
Thu, 24 Mar 2022 00:28:16 +0000 (01:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 24 Mar 2022 12:27:31 +0000 (13:27 +0100)
tags inside <MainMarkers>

src/verify.cc
src/verify.h
test/verify_test.cc

index a0c329d0cdb862050a74dfe54667ce211a910be8..bef05a16fe2e494a8a4490ffd91093bf6f2301be 100644 (file)
@@ -1452,6 +1452,12 @@ dcp::verify (
                                        for (auto const& i: reel->main_markers()->get()) {
                                                markers_seen.insert (i);
                                        }
+                                       if (reel->main_markers()->entry_point()) {
+                                               notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::UNEXPECTED_ENTRY_POINT});
+                                       }
+                                       if (reel->main_markers()->duration()) {
+                                               notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::UNEXPECTED_DURATION});
+                                       }
                                }
 
                                fewest_closed_captions = std::min (fewest_closed_captions, reel->closed_captions().size());
@@ -1763,6 +1769,10 @@ dcp::note_to_string (VerificationNote note)
                return "Some closed <Text> or <Image> nodes have different vertical alignments within a <Subtitle>.";
        case VerificationNote::Code::INCORRECT_CLOSED_CAPTION_ORDERING:
                return "Some closed captions are not listed in the order of their vertical position.";
+       case VerificationNote::Code::UNEXPECTED_ENTRY_POINT:
+               return "There is an <EntryPoint> node inside a <MainMarkers>.";
+       case VerificationNote::Code::UNEXPECTED_DURATION:
+               return "There is an <Duration> node inside a <MainMarkers>.";
        }
 
        return "";
index 424b29e7ca983387800116931f391fa2b301427a..3dd7d125d369048e14716db36fcf011fb5f8d672 100644 (file)
@@ -82,6 +82,7 @@ public:
         *  - MISMATCHED: two things, which should be the same, are not.
         *  - EMPTY: something, which should have a value, has no value.
         *  - MISSING: something, which should be present, is not.
+        *  - UNEXPECTED: something, which is present, should not be.
         *  - FAILED: some part of the verification failed in some serious way.
         *
         *  Comments should clarify meaning and also say which of the optional fields (e.g. file)
@@ -392,6 +393,10 @@ public:
                MISMATCHED_CLOSED_CAPTION_VALIGN,
                /** Some closed captions are not listed in the XML in the order of their vertical position */
                INCORRECT_CLOSED_CAPTION_ORDERING,
+               /** Some <MainMarkers> asset has an <EntryPoint> that should not be there */
+               UNEXPECTED_ENTRY_POINT,
+               /** Some <MainMarkers> asset has an <Duration> that should not be there */
+               UNEXPECTED_DURATION
        };
 
        VerificationNote (Type type, Code code)
index 8126c3180e6f181a0dee22531892a724caaec48f..4b4aeea72e6b31c2fb96774487341e33411175e3 100644 (file)
@@ -219,6 +219,23 @@ public:
                BOOST_REQUIRE (_content != old_content);
        }
 
+       void insert (string after, string line)
+       {
+               vector<string> lines;
+               boost::algorithm::split (lines, _content, boost::is_any_of("\r\n"), boost::token_compress_on);
+               auto old_content = _content;
+               _content = "";
+               bool replaced = false;
+               for (auto i: lines) {
+                       _content += i;
+                       if (!replaced && i.find(after) != string::npos) {
+                               _content += line;
+                               replaced = true;
+                       }
+               }
+               BOOST_REQUIRE (_content != old_content);
+       }
+
 private:
        path _path;
        std::string _content;
@@ -3233,3 +3250,35 @@ BOOST_AUTO_TEST_CASE (verify_threed_marked_as_twod)
 
 }
 
+
+BOOST_AUTO_TEST_CASE (verify_unexpected_things_in_main_markers)
+{
+       path dir = "build/test/verify_unexpected_things_in_main_markers";
+       prepare_directory (dir);
+       auto dcp = make_simple (dir, 1, 24);
+       dcp->write_xml (
+               dcp::String::compose("libdcp %1", dcp::version),
+               dcp::String::compose("libdcp %1", dcp::version),
+               dcp::LocalTime().as_string(),
+               "A Test DCP"
+               );
+
+       {
+               Editor e (find_cpl(dir));
+               e.insert(
+                       "          <IntrinsicDuration>24</IntrinsicDuration>",
+                       "<EntryPoint>0</EntryPoint><Duration>24</Duration>"
+                       );
+       }
+
+       dcp::CPL cpl (find_cpl(dir));
+
+       check_verify_result (
+               { dir },
+               {
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, cpl.id(), canonical(find_cpl(dir)) },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::UNEXPECTED_ENTRY_POINT },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::UNEXPECTED_DURATION },
+               });
+}
+