OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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 <limits> | 5 #include <limits> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "fpdfsdk/fpdfview_c_api_test.h" | 8 #include "fpdfsdk/fpdfview_c_api_test.h" |
9 #include "public/fpdfview.h" | 9 #include "public/fpdfview.h" |
10 #include "testing/embedder_test.h" | 10 #include "testing/embedder_test.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 320 |
321 // The test should pass when there is no infinite recursion in | 321 // The test should pass when there is no infinite recursion in |
322 // CPDF_SyntaxParser::GetString(). | 322 // CPDF_SyntaxParser::GetString(). |
323 TEST_F(FPDFViewEmbeddertest, Hang_355) { | 323 TEST_F(FPDFViewEmbeddertest, Hang_355) { |
324 EXPECT_FALSE(OpenDocument("bug_355.pdf")); | 324 EXPECT_FALSE(OpenDocument("bug_355.pdf")); |
325 } | 325 } |
326 // The test should pass even when the file has circular references to pages. | 326 // The test should pass even when the file has circular references to pages. |
327 TEST_F(FPDFViewEmbeddertest, Hang_360) { | 327 TEST_F(FPDFViewEmbeddertest, Hang_360) { |
328 EXPECT_FALSE(OpenDocument("bug_360.pdf")); | 328 EXPECT_FALSE(OpenDocument("bug_360.pdf")); |
329 } | 329 } |
| 330 |
| 331 TEST_F(FPDFViewEmbeddertest, FPDF_RenderPageBitmapWithMatrix) { |
| 332 const char kAllBlackMd5sum[] = "5708fc5c4a8bd0abde99c8e8f0390615"; |
| 333 const char kTopLeftQuarterBlackMd5sum[] = "24e4d1ec06fa0258af758cfc8b2ad50a"; |
| 334 |
| 335 EXPECT_TRUE(OpenDocument("black.pdf")); |
| 336 FPDF_PAGE page = LoadPage(0); |
| 337 EXPECT_NE(nullptr, page); |
| 338 const int width = static_cast<int>(FPDF_GetPageWidth(page)); |
| 339 const int height = static_cast<int>(FPDF_GetPageHeight(page)); |
| 340 EXPECT_EQ(612, width); |
| 341 EXPECT_EQ(792, height); |
| 342 |
| 343 FPDF_BITMAP bitmap = RenderPage(page); |
| 344 CompareBitmap(bitmap, width, height, kAllBlackMd5sum); |
| 345 FPDFBitmap_Destroy(bitmap); |
| 346 |
| 347 // Try rendering with an identity matrix. The output should be the same as |
| 348 // the RenderPage() output. |
| 349 FS_MATRIX matrix; |
| 350 matrix.a = 1; |
| 351 matrix.b = 0; |
| 352 matrix.c = 0; |
| 353 matrix.d = 1; |
| 354 matrix.e = 0; |
| 355 matrix.f = 0; |
| 356 |
| 357 FS_RECTF rect; |
| 358 rect.left = 0; |
| 359 rect.top = 0; |
| 360 rect.right = width; |
| 361 rect.bottom = height; |
| 362 |
| 363 bitmap = FPDFBitmap_Create(width, height, 0); |
| 364 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); |
| 365 FPDF_RenderPageBitmapWithMatrix(bitmap, page, &matrix, &rect, 0); |
| 366 CompareBitmap(bitmap, width, height, kAllBlackMd5sum); |
| 367 FPDFBitmap_Destroy(bitmap); |
| 368 |
| 369 // Now render again with the image scaled. |
| 370 matrix.a = 0.5; |
| 371 matrix.d = 0.5; |
| 372 |
| 373 bitmap = FPDFBitmap_Create(width, height, 0); |
| 374 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); |
| 375 FPDF_RenderPageBitmapWithMatrix(bitmap, page, &matrix, &rect, 0); |
| 376 CompareBitmap(bitmap, width, height, kTopLeftQuarterBlackMd5sum); |
| 377 FPDFBitmap_Destroy(bitmap); |
| 378 |
| 379 UnloadPage(page); |
| 380 } |
OLD | NEW |