Chromium Code Reviews| 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 FS_MATRIX matrix; | |
| 348 matrix.a = 1; | |
|
dsinclair
2016/11/23 14:08:44
Can you add a comment as to what the matrix here,
Lei Zhang
2016/11/23 18:30:31
Done.
| |
| 349 matrix.b = 0; | |
| 350 matrix.c = 0; | |
| 351 matrix.d = 1; | |
| 352 matrix.e = 0; | |
| 353 matrix.f = 0; | |
| 354 | |
| 355 FS_RECTF rect; | |
| 356 rect.left = 0; | |
| 357 rect.top = 0; | |
| 358 rect.right = width; | |
| 359 rect.bottom = height; | |
| 360 | |
| 361 bitmap = FPDFBitmap_Create(width, height, 0); | |
| 362 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); | |
| 363 FPDF_RenderPageBitmapWithMatrix(bitmap, page, &matrix, &rect, 0); | |
| 364 CompareBitmap(bitmap, width, height, kAllBlackMd5sum); | |
| 365 FPDFBitmap_Destroy(bitmap); | |
| 366 | |
| 367 matrix.a = 0.5; | |
| 368 matrix.d = 0.5; | |
| 369 | |
| 370 bitmap = FPDFBitmap_Create(width, height, 0); | |
| 371 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); | |
| 372 FPDF_RenderPageBitmapWithMatrix(bitmap, page, &matrix, &rect, 0); | |
| 373 CompareBitmap(bitmap, width, height, kTopLeftQuarterBlackMd5sum); | |
| 374 FPDFBitmap_Destroy(bitmap); | |
| 375 | |
| 376 UnloadPage(page); | |
| 377 } | |
| OLD | NEW |