diff options
Diffstat (limited to 'core/fpdfapi/edit/cpdf_creator_embeddertest.cpp')
-rw-r--r-- | core/fpdfapi/edit/cpdf_creator_embeddertest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp index 1913c4ba19..f8520c4238 100644 --- a/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp +++ b/core/fpdfapi/edit/cpdf_creator_embeddertest.cpp @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <cstring> #include <memory> #include <string> #include <vector> @@ -12,6 +13,7 @@ #include "public/fpdf_edit.h" #include "public/fpdfview.h" #include "testing/embedder_test.h" +#include "testing/gmock/include/gmock/gmock-matchers.h" #include "testing/gtest/include/gtest/gtest.h" class CPDF_CreatorEmbedderTest : public EmbedderTest {}; @@ -42,3 +44,21 @@ TEST_F(CPDF_CreatorEmbedderTest, SavedDocsAreEqualAfterParse) { // The sizes of saved docs should be equal. EXPECT_EQ(saved_doc_1.size(), saved_doc_2.size()); } + +TEST_F(CPDF_CreatorEmbedderTest, BUG_873) { + EXPECT_TRUE(OpenDocument("embedded_attachments.pdf")); + EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); + + // Cannot match second part of the ID since it is randomly generated. + std::string saved_data = GetString(); + const char kTrailerBeforeSecondID[] = + "trailer\r\n<</Info 9 0 R /Root 11 0 R /Size " + "36/ID[<D889EB6B9ADF88E5EDA7DC08FE85978B><"; + ASSERT_THAT(saved_data, testing::HasSubstr(kTrailerBeforeSecondID)); + size_t trailer_start = saved_data.find(kTrailerBeforeSecondID); + constexpr size_t kIdLen = 32; + size_t trailer_continuation = + trailer_start + strlen(kTrailerBeforeSecondID) + kIdLen; + std::string data_after_second_id = saved_data.substr(trailer_continuation); + EXPECT_THAT(data_after_second_id, testing::StartsWith(">]>>\r\n")); +} |