Use an enum instead of a bool in PictureAsset::start_write().
[libdcp.git] / test / verify_test.cc
index 76c20ffc2addf3f6acbbfe7e5eb976d861a262cd..5b51db4344bd0c319759997267e247d5a5c4df2e 100644 (file)
@@ -88,7 +88,7 @@ static string const dcp_test1_pkl_id = filename_to_id(dcp_test1_pkl);
 static boost::filesystem::path const dcp_test1_cpl = find_file("test/ref/DCP/dcp_test1", "cpl_").filename();
 static string const dcp_test1_cpl_id = filename_to_id(dcp_test1_cpl);
 
-static string const dcp_test1_asset_map_id = "5d51e8a1-b2a5-4da6-9b66-4615c3609440";
+static string const dcp_test1_asset_map_id = "017b3de4-6dda-408d-b19b-6711354b0bc3";
 
 static boost::filesystem::path const encryption_test_cpl = find_file("test/ref/DCP/encryption_test", "cpl_").filename();
 static string const encryption_test_cpl_id = filename_to_id(encryption_test_cpl);
@@ -172,18 +172,34 @@ public:
                fclose (f);
        }
 
+       class ChangeChecker
+       {
+       public:
+               ChangeChecker(Editor* editor)
+                       : _editor(editor)
+               {
+                       _old_content = _editor->_content;
+               }
+
+               ~ChangeChecker()
+               {
+                       BOOST_REQUIRE(_old_content != _editor->_content);
+               }
+       private:
+               Editor* _editor;
+               std::string _old_content;
+       };
+
        void replace (string a, string b)
        {
-               auto old_content = _content;
+               ChangeChecker cc(this);
                boost::algorithm::replace_all (_content, a, b);
-               BOOST_REQUIRE (_content != old_content);
        }
 
        void delete_first_line_containing (string s)
        {
-               vector<string> lines;
-               boost::algorithm::split (lines, _content, boost::is_any_of("\r\n"), boost::token_compress_on);
-               auto old_content = _content;
+               ChangeChecker cc(this);
+               auto lines = as_lines();
                _content = "";
                bool done = false;
                for (auto i: lines) {
@@ -193,15 +209,13 @@ public:
                                done = true;
                        }
                }
-               BOOST_REQUIRE (_content != old_content);
        }
 
        void delete_lines (string from, string to)
        {
-               vector<string> lines;
-               boost::algorithm::split (lines, _content, boost::is_any_of("\r\n"), boost::token_compress_on);
+               ChangeChecker cc(this);
+               auto lines = as_lines();
                bool deleting = false;
-               auto old_content = _content;
                _content = "";
                for (auto i: lines) {
                        if (i.find(from) != string::npos) {
@@ -214,27 +228,54 @@ public:
                                deleting = false;
                        }
                }
-               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;
+               ChangeChecker cc(this);
+               auto lines = as_lines();
                _content = "";
                bool replaced = false;
                for (auto i: lines) {
-                       _content += i;
+                       _content += i + "\n";
                        if (!replaced && i.find(after) != string::npos) {
-                               _content += line;
+                               _content += line + "\n";
                                replaced = true;
                        }
                }
-               BOOST_REQUIRE (_content != old_content);
+       }
+
+       void delete_lines_after(string after, int lines_to_delete)
+       {
+               ChangeChecker cc(this);
+               auto lines = as_lines();
+               _content = "";
+               auto iter = std::find_if(lines.begin(), lines.end(), [after](string const& line) {
+                       return line.find(after) != string::npos;
+               });
+               int to_delete = 0;
+               for (auto i = lines.begin(); i != lines.end(); ++i) {
+                       if (i == iter) {
+                               to_delete = lines_to_delete;
+                               _content += *i + "\n";
+                       } else if (to_delete == 0) {
+                               _content += *i + "\n";
+                       } else {
+                               --to_delete;
+                       }
+               }
        }
 
 private:
+       friend class ChangeChecker;
+
+       vector<string> as_lines() const
+       {
+               vector<string> lines;
+               boost::algorithm::split(lines, _content, boost::is_any_of("\r\n"), boost::token_compress_on);
+               return lines;
+       }
+
        path _path;
        std::string _content;
 };
@@ -256,17 +297,33 @@ 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());
 
        string message = "\nVerification notes from test:\n";
        for (auto i: notes) {
                message += "  " + note_to_string(i) + "\n";
+               message += dcp::String::compose(
+                       "  [%1 %2 %3 %4 %5]\n",
+                       static_cast<int>(i.type()),
+                       static_cast<int>(i.code()),
+                       i.note().get_value_or("<none>"),
+                       i.file().get_value_or("<none>"),
+                       i.line().get_value_or(0)
+                       );
        }
        message += "Expected:\n";
        for (auto i: test_notes) {
                message += "  " + note_to_string(i) + "\n";
+               message += dcp::String::compose(
+                       "  [%1 %2 %3 %4 %5]\n",
+                       static_cast<int>(i.type()),
+                       static_cast<int>(i.code()),
+                       i.note().get_value_or("<none>"),
+                       i.file().get_value_or("<none>"),
+                       i.line().get_value_or(0)
+                       );
        }
 
        BOOST_REQUIRE_MESSAGE (notes == test_notes, message);
@@ -288,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();
@@ -305,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;
@@ -401,9 +458,9 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_picture_sound_hashes)
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, dcp_test1_cpl_id, canonical(dir / dcp_test1_cpl) },
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_PICTURE_HASHES, canonical(dir / "video.mxf") },
                        { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_SOUND_HASHES, canonical(dir / "audio.mxf") },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xLq7ot/GobgrqUYdlbR8FCD5APqs=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 26 },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xgVKhC9IkWyzQbgzpFcJ1bpqbtwk=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 19 },
-                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xznqYbl53W9ZQtrU2E1FQ6dwdM2M=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 12 },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xKcJb7S2K5cNm8RG4kfQD5FTeS0A=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 28 },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xtfX1mVIKJCVr1m7Y32Nzxf0+Rpw=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 12 },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, "value 'xwUmt8G+cFFKMGt0ueS9+F1S4uhc=' is invalid Base64-encoded binary", canonical(dir / dcp_test1_pkl), 20 },
                });
 }
 
@@ -419,8 +476,10 @@ BOOST_AUTO_TEST_CASE (verify_failed_read_content_kind)
 
        check_verify_result (
                { dir },
-               {{ dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::FAILED_READ, string("Bad content kind 'xtrailer'")}}
-               );
+               {
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, dcp_test1_cpl_id, canonical(dir / dcp_test1_cpl) },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_CONTENT_KIND, string("xtrailer") }
+               });
 }
 
 
@@ -501,7 +560,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_cpl_id)
        /* There's no MISMATCHED_CPL_HASHES error here because it can't find the correct hash by ID (since the ID is wrong) */
        check_verify_result_after_replace (
                        "invalid_xml_cpl_id", &cpl,
-                       "<Id>urn:uuid:81fb54df-e1bf-4647-8788-ea7ba154375b", "<Id>urn:uuid:81fb54df-e1bf-4647-8788-ea7ba154375",
+                       "<Id>urn:uuid:6affb8ee-0020-4dff-a53c-17652f6358ab", "<Id>urn:uuid:6affb8ee-0020-4dff-a53c-17652f6358a",
                        { dcp::VerificationNote::Code::INVALID_XML }
                        );
 }
@@ -544,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";
@@ -620,7 +679,7 @@ dcp_from_frame (dcp::ArrayData const& frame, path dir)
 {
        auto asset = make_shared<dcp::MonoPictureAsset>(dcp::Fraction(24, 1), dcp::Standard::SMPTE);
        create_directories (dir);
-       auto writer = asset->start_write (dir / "pic.mxf", true);
+       auto writer = asset->start_write(dir / "pic.mxf", dcp::PictureAsset::Behaviour::MAKE_NEW);
        for (int i = 0; i < 24; ++i) {
                writer->write (frame.data(), frame.size());
        }
@@ -747,6 +806,43 @@ 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_interop_subtitle_asset_with_single_space_subtitle)
+{
+       path const dir("build/test/verify_interop_subtitle_asset_with_single_space_subtitle");
+       prepare_directory(dir);
+       copy_file("test/data/subs5.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 },
+               });
+
+}
+
+
 BOOST_AUTO_TEST_CASE (verify_valid_smpte_subtitles)
 {
        path const dir("build/test/verify_valid_smpte_subtitles");
@@ -756,7 +852,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"} }
+               });
 }
 
 
@@ -785,6 +886,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"} }
                });
 }
 
@@ -805,6 +907,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"} }
                });
 }
 
@@ -840,6 +943,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 },
                });
@@ -904,16 +1008,35 @@ BOOST_AUTO_TEST_CASE (verify_valid_cpl_metadata)
 }
 
 
+path
+find_prefix(path dir, string prefix)
+{
+       auto iter = std::find_if(directory_iterator(dir), directory_iterator(), [prefix](path const& p) {
+               return boost::starts_with(p.filename().string(), prefix);
+       });
+
+       BOOST_REQUIRE(iter != directory_iterator());
+       return iter->path();
+}
+
+
 path find_cpl (path dir)
 {
-       for (auto i: directory_iterator(dir)) {
-               if (boost::starts_with(i.path().filename().string(), "cpl_")) {
-                       return i.path();
-               }
-       }
+       return find_prefix(dir, "cpl_");
+}
+
 
-       BOOST_REQUIRE (false);
-       return {};
+path
+find_pkl(path dir)
+{
+       return find_prefix(dir, "pkl_");
+}
+
+
+path
+find_asset_map(path dir)
+{
+       return find_prefix(dir, "ASSETMAP");
 }
 
 
@@ -1104,7 +1227,7 @@ check_picture_size (int width, int height, int frame_rate, bool three_d)
        } else {
                mp = make_shared<dcp::MonoPictureAsset>(dcp::Fraction(frame_rate, 1), dcp::Standard::SMPTE);
        }
-       auto picture_writer = mp->start_write (dcp_path / "video.mxf", false);
+       auto picture_writer = mp->start_write(dcp_path / "video.mxf", dcp::PictureAsset::Behaviour::MAKE_NEW);
 
        auto image = black_image (dcp::Size(width, height));
        auto j2c = dcp::compress_j2k (image, 100000000, frame_rate, three_d, width > 2048);
@@ -1120,8 +1243,8 @@ check_picture_size (int width, int height, int frame_rate, bool three_d)
        cpl->set_issue_date ("2012-07-17T04:45:18+00:00");
        cpl->set_main_sound_configuration ("L,C,R,Lfe,-,-");
        cpl->set_main_sound_sample_rate (48000);
-       cpl->set_main_picture_stored_area (dcp::Size(1998, 1080));
-       cpl->set_main_picture_active_area (dcp::Size(1998, 1080));
+       cpl->set_main_picture_stored_area(dcp::Size(width, height));
+       cpl->set_main_picture_active_area(dcp::Size(width, height));
        cpl->set_version_number (1);
 
        auto reel = make_shared<dcp::Reel>();
@@ -1140,7 +1263,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);
 }
 
 
@@ -1240,7 +1363,7 @@ void
 add_test_subtitle (shared_ptr<dcp::SubtitleAsset> asset, int start_frame, int end_frame, float v_position = 0, dcp::VAlign v_align = dcp::VAlign::CENTER, string text = "Hello")
 {
        asset->add (
-               make_shared<dcp::SubtitleString>(
+               std::make_shared<dcp::SubtitleString>(
                        optional<string>(),
                        false,
                        false,
@@ -1254,6 +1377,7 @@ add_test_subtitle (shared_ptr<dcp::SubtitleAsset> asset, int start_frame, int en
                        dcp::HAlign::CENTER,
                        v_position,
                        v_align,
+                       0,
                        dcp::Direction::LTR,
                        text,
                        dcp::Effect::NONE,
@@ -1287,7 +1411,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 },
@@ -1327,7 +1451,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 },
@@ -2260,7 +2384,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() },
                        });
 
        }
@@ -2397,7 +2521,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() },
                });
 }
 
@@ -2901,7 +3025,7 @@ BOOST_AUTO_TEST_CASE (verify_partially_encrypted)
        auto mp = make_shared<dcp::MonoPictureAsset>(dcp::Fraction (24, 1), dcp::Standard::SMPTE);
        mp->set_key (key);
 
-       auto writer = mp->start_write (dir / "video.mxf", false);
+       auto writer = mp->start_write(dir / "video.mxf", dcp::PictureAsset::Behaviour::MAKE_NEW);
        dcp::ArrayData j2c ("test/data/flat_red.j2c");
        for (int i = 0; i < 24; ++i) {
                writer->write (j2c.data(), j2c.size());
@@ -3007,7 +3131,7 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_subtitle_resource_id)
        auto xml_id = dcp::make_uuid ();
        ASDCP::TimedText::MXFWriter writer;
        auto subs_mxf = dir / "subs.mxf";
-       auto r = writer.OpenWrite(subs_mxf.c_str(), writer_info, descriptor, 4096);
+       auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096);
        BOOST_REQUIRE (ASDCP_SUCCESS(r));
        writer.WriteTimedTextResource (dcp::String::compose(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -3015,7 +3139,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>"
@@ -3071,7 +3195,7 @@ BOOST_AUTO_TEST_CASE (verify_incorrect_timed_text_id)
        auto xml_id = resource_id;
        ASDCP::TimedText::MXFWriter writer;
        auto subs_mxf = dir / "subs.mxf";
-       auto r = writer.OpenWrite(subs_mxf.c_str(), writer_info, descriptor, 4096);
+       auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096);
        BOOST_REQUIRE (ASDCP_SUCCESS(r));
        writer.WriteTimedTextResource (dcp::String::compose(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -3108,7 +3232,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"} }
                });
 }
 
@@ -3159,3 +3284,164 @@ BOOST_AUTO_TEST_CASE (verify_unexpected_things_in_main_markers)
                });
 }
 
+
+BOOST_AUTO_TEST_CASE(verify_invalid_content_kind)
+{
+       path dir = "build/test/verify_invalid_content_kind";
+       prepare_directory (dir);
+       auto dcp = make_simple (dir, 1, 24);
+       dcp->set_annotation_text("A Test DCP");
+       dcp->write_xml();
+
+       {
+               Editor e(find_cpl(dir));
+               e.replace("trailer", "trip");
+       }
+
+       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::INVALID_CONTENT_KIND, string("trip") }
+               });
+
+}
+
+
+BOOST_AUTO_TEST_CASE(verify_valid_content_kind)
+{
+       path dir = "build/test/verify_valid_content_kind";
+       prepare_directory (dir);
+       auto dcp = make_simple (dir, 1, 24);
+       dcp->set_annotation_text("A Test DCP");
+       dcp->write_xml();
+
+       {
+               Editor e(find_cpl(dir));
+               e.replace("<ContentKind>trailer</ContentKind>", "<ContentKind scope=\"http://bobs.contents/\">trip</ContentKind>");
+       }
+
+       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)) },
+               });
+
+}
+
+
+BOOST_AUTO_TEST_CASE(verify_invalid_main_picture_active_area_1)
+{
+       path dir = "build/test/verify_invalid_main_picture_active_area_1";
+       prepare_directory(dir);
+       auto dcp = make_simple(dir, 1, 24);
+       dcp->write_xml();
+
+       auto constexpr area = "<meta:MainPictureActiveArea>";
+
+       {
+               Editor e(find_cpl(dir));
+               e.delete_lines_after(area, 2);
+               e.insert(area, "<meta:Height>4080</meta:Height>");
+               e.insert(area, "<meta:Width>1997</meta:Width>");
+       }
+
+       dcp::PKL pkl(find_pkl(dir));
+       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::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL, pkl.id(), canonical(find_pkl(dir)), },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA, "width 1997 is not a multiple of 2", canonical(find_cpl(dir)) },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA, "height 4080 is bigger than the asset height 1080", canonical(find_cpl(dir)) },
+               });
+}
+
+
+BOOST_AUTO_TEST_CASE(verify_invalid_main_picture_active_area_2)
+{
+       path dir = "build/test/verify_invalid_main_picture_active_area_2";
+       prepare_directory(dir);
+       auto dcp = make_simple(dir, 1, 24);
+       dcp->write_xml();
+
+       auto constexpr area = "<meta:MainPictureActiveArea>";
+
+       {
+               Editor e(find_cpl(dir));
+               e.delete_lines_after(area, 2);
+               e.insert(area, "<meta:Height>5125</meta:Height>");
+               e.insert(area, "<meta:Width>9900</meta:Width>");
+       }
+
+       dcp::PKL pkl(find_pkl(dir));
+       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::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL, pkl.id(), canonical(find_pkl(dir)), },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA, "height 5125 is not a multiple of 2", canonical(find_cpl(dir)) },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA, "width 9900 is bigger than the asset width 1998", canonical(find_cpl(dir)) },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_MAIN_PICTURE_ACTIVE_AREA, "height 5125 is bigger than the asset height 1080", canonical(find_cpl(dir)) },
+               });
+}
+
+
+BOOST_AUTO_TEST_CASE(verify_duplicate_pkl_asset_ids)
+{
+       RNGFixer rg;
+
+       path dir = "build/test/verify_duplicate_pkl_asset_ids";
+       prepare_directory(dir);
+       auto dcp = make_simple(dir, 1, 24);
+       dcp->write_xml();
+
+       {
+               Editor e(find_pkl(dir));
+               e.replace("urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54", "urn:uuid:6affb8ee-0020-4dff-a53c-17652f6358ab");
+       }
+
+       dcp::PKL pkl(find_pkl(dir));
+
+       check_verify_result(
+               { dir },
+               {
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::DUPLICATE_ASSET_ID_IN_PKL, pkl.id(), canonical(find_pkl(dir)) },
+               });
+}
+
+
+BOOST_AUTO_TEST_CASE(verify_duplicate_assetmap_asset_ids)
+{
+       RNGFixer rg;
+
+       path dir = "build/test/verify_duplicate_assetmap_asset_ids";
+       prepare_directory(dir);
+       auto dcp = make_simple(dir, 1, 24);
+       dcp->write_xml();
+
+       {
+               Editor e(find_asset_map(dir));
+               e.replace("urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54", "urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa");
+       }
+
+       dcp::PKL pkl(find_pkl(dir));
+       dcp::AssetMap asset_map(find_asset_map(dir));
+
+       check_verify_result(
+               { dir },
+               {
+                       { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL, pkl.id(), canonical(find_pkl(dir)), },
+                       { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::DUPLICATE_ASSET_ID_IN_ASSETMAP, asset_map.id(), canonical(find_asset_map(dir)) },
+                       { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::EXTERNAL_ASSET, string("5407b210-4441-4e97-8b16-8bdc7c12da54") },
+               });
+}
+