Chromium Code Reviews| 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_edit.h" | 5 #include "public/fpdf_edit.h" |
| 6 #include "public/fpdfview.h" | 6 #include "public/fpdfview.h" |
| 7 #include "testing/embedder_test.h" | 7 #include "testing/embedder_test.h" |
| 8 #include "testing/gmock/include/gmock/gmock-matchers.h" | 8 #include "testing/gmock/include/gmock/gmock-matchers.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/test_support.h" | 10 #include "testing/test_support.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 "/Root 1 0 R\r\n" | 48 "/Root 1 0 R\r\n" |
| 49 "/Info 3 0 R\r\n" | 49 "/Info 3 0 R\r\n" |
| 50 "/Size 6/ID\\[<.*><.*>\\]>>\r\n" | 50 "/Size 6/ID\\[<.*><.*>\\]>>\r\n" |
| 51 "startxref\r\n" | 51 "startxref\r\n" |
| 52 "379\r\n" | 52 "379\r\n" |
| 53 "%%EOF\r\n"; | 53 "%%EOF\r\n"; |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 TEST_F(FPDFEditEmbeddertest, EmptyCreation) { | 56 TEST_F(FPDFEditEmbeddertest, EmptyCreation) { |
| 57 EXPECT_TRUE(CreateEmptyDocument()); | 57 EXPECT_TRUE(CreateEmptyDocument()); |
| 58 FPDF_PAGE page = FPDFPage_New(document(), 1, 640.0, 480.0); | 58 FPDF_PAGE page = FPDFPage_New(document(), 0, 640.0, 480.0); |
| 59 EXPECT_NE(nullptr, page); | 59 EXPECT_NE(nullptr, page); |
| 60 EXPECT_TRUE(FPDFPage_GenerateContent(page)); | 60 EXPECT_TRUE(FPDFPage_GenerateContent(page)); |
| 61 EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); | 61 EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); |
| 62 | 62 |
| 63 // The MatchesRegexp doesn't support embedded NUL ('\0') characters. They are | 63 // The MatchesRegexp doesn't support embedded NUL ('\0') characters. They are |
| 64 // replaced by '_' for the purpose of the test. | 64 // replaced by '_' for the purpose of the test. |
| 65 std::string result = GetString(); | 65 std::string result = GetString(); |
| 66 std::replace(result.begin(), result.end(), '\0', '_'); | 66 std::replace(result.begin(), result.end(), '\0', '_'); |
| 67 EXPECT_THAT(result, testing::MatchesRegex( | 67 EXPECT_THAT(result, testing::MatchesRegex( |
| 68 std::string(kExpectedPDF, sizeof(kExpectedPDF)))); | 68 std::string(kExpectedPDF, sizeof(kExpectedPDF)))); |
| 69 FPDFPage_Delete(document(), 1); | 69 // FPDFPage_New() doesn't add any new page into document if the page index is |
|
Tom Sepez
2016/08/19 20:24:48
This comment should be in a public/ header file.
Wei Li
2016/08/19 22:25:27
Done.
| |
| 70 // not within document's existing page range. Use FPDF_ClosePage() instead of | |
| 71 // FPDFPage_Delete() to free the page. | |
| 72 FPDF_ClosePage(page); | |
| 70 } | 73 } |
| OLD | NEW |