| OLD | NEW | 
|---|
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
|  | 5 #include "public/fpdf_save.h" | 
|  | 6 | 
| 5 #include <string.h> | 7 #include <string.h> | 
| 6 | 8 | 
| 7 #include "core/fxcrt/fx_string.h" | 9 #include "core/fxcrt/fx_string.h" | 
| 8 #include "public/fpdf_save.h" | 10 #include "public/fpdf_edit.h" | 
|  | 11 #include "public/fpdf_ppo.h" | 
| 9 #include "public/fpdfview.h" | 12 #include "public/fpdfview.h" | 
| 10 #include "testing/embedder_test.h" | 13 #include "testing/embedder_test.h" | 
| 11 #include "testing/fx_string_testhelpers.h" | 14 #include "testing/fx_string_testhelpers.h" | 
| 12 #include "testing/gmock/include/gmock/gmock-matchers.h" | 15 #include "testing/gmock/include/gmock/gmock-matchers.h" | 
| 13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" | 
| 14 #include "testing/test_support.h" | 17 #include "testing/test_support.h" | 
| 15 | 18 | 
| 16 class FPDFSaveEmbedderTest : public EmbedderTest, public TestSaver {}; | 19 class FPDFSaveEmbedderTest : public EmbedderTest, public TestSaver {}; | 
| 17 | 20 | 
| 18 TEST_F(FPDFSaveEmbedderTest, SaveSimpleDoc) { | 21 TEST_F(FPDFSaveEmbedderTest, SaveSimpleDoc) { | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 36 | 39 | 
| 37   ClearString(); | 40   ClearString(); | 
| 38   EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 0)); | 41   EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 0)); | 
| 39   EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n")); | 42   EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n")); | 
| 40 | 43 | 
| 41   ClearString(); | 44   ClearString(); | 
| 42   EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 18)); | 45   EXPECT_TRUE(FPDF_SaveWithVersion(document(), this, 0, 18)); | 
| 43   EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n")); | 46   EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.7\r\n")); | 
| 44 } | 47 } | 
| 45 | 48 | 
|  | 49 TEST_F(FPDFSaveEmbedderTest, SaveCopiedDoc) { | 
|  | 50   EXPECT_TRUE(OpenDocument("hello_world.pdf")); | 
|  | 51 | 
|  | 52   FPDF_PAGE page = LoadPage(0); | 
|  | 53   EXPECT_TRUE(page); | 
|  | 54 | 
|  | 55   FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument(); | 
|  | 56   EXPECT_TRUE(output_doc); | 
|  | 57   EXPECT_TRUE(FPDF_ImportPages(output_doc, document(), "1", 0)); | 
|  | 58   EXPECT_TRUE(FPDF_SaveAsCopy(output_doc, this, 0)); | 
|  | 59   FPDF_CloseDocument(output_doc); | 
|  | 60 | 
|  | 61   UnloadPage(page); | 
|  | 62 } | 
|  | 63 | 
| 46 TEST_F(FPDFSaveEmbedderTest, BUG_342) { | 64 TEST_F(FPDFSaveEmbedderTest, BUG_342) { | 
| 47   EXPECT_TRUE(OpenDocument("hello_world.pdf")); | 65   EXPECT_TRUE(OpenDocument("hello_world.pdf")); | 
| 48   EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); | 66   EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); | 
| 49   EXPECT_THAT(GetString(), testing::HasSubstr("0000000000 65535 f\r\n")); | 67   EXPECT_THAT(GetString(), testing::HasSubstr("0000000000 65535 f\r\n")); | 
| 50   EXPECT_THAT(GetString(), | 68   EXPECT_THAT(GetString(), | 
| 51               testing::Not(testing::HasSubstr("0000000000 65536 f\r\n"))); | 69               testing::Not(testing::HasSubstr("0000000000 65536 f\r\n"))); | 
| 52 } | 70 } | 
| OLD | NEW | 
|---|