| 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 "testing/embedder_test.h" | 5 #include "testing/embedder_test.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "public/fpdf_dataavail.h" | 14 #include "public/fpdf_dataavail.h" |
| 15 #include "public/fpdf_edit.h" | 15 #include "public/fpdf_edit.h" |
| 16 #include "public/fpdf_text.h" | 16 #include "public/fpdf_text.h" |
| 17 #include "public/fpdfview.h" | 17 #include "public/fpdfview.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/test_support.h" | 19 #include "testing/test_support.h" |
| 20 #include "testing/utils/md5.h" |
| 20 #include "testing/utils/path_service.h" | 21 #include "testing/utils/path_service.h" |
| 21 | 22 |
| 22 #ifdef PDF_ENABLE_V8 | 23 #ifdef PDF_ENABLE_V8 |
| 23 #include "v8/include/v8-platform.h" | 24 #include "v8/include/v8-platform.h" |
| 24 #include "v8/include/v8.h" | 25 #include "v8/include/v8.h" |
| 25 #endif // PDF_ENABLE_V8 | 26 #endif // PDF_ENABLE_V8 |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 const char* g_exe_path = nullptr; | 30 const char* g_exe_path = nullptr; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 317 } |
| 317 | 318 |
| 318 // static | 319 // static |
| 319 FPDF_PAGE EmbedderTest::GetPageTrampoline(FPDF_FORMFILLINFO* info, | 320 FPDF_PAGE EmbedderTest::GetPageTrampoline(FPDF_FORMFILLINFO* info, |
| 320 FPDF_DOCUMENT document, | 321 FPDF_DOCUMENT document, |
| 321 int page_index) { | 322 int page_index) { |
| 322 return static_cast<EmbedderTest*>(info)->delegate_->GetPage(info, document, | 323 return static_cast<EmbedderTest*>(info)->delegate_->GetPage(info, document, |
| 323 page_index); | 324 page_index); |
| 324 } | 325 } |
| 325 | 326 |
| 327 // static |
| 328 void EmbedderTest::CompareBitmap(FPDF_BITMAP bitmap, |
| 329 int expected_width, |
| 330 int expected_height, |
| 331 const char* expected_md5sum) { |
| 332 ASSERT_EQ(expected_width, FPDFBitmap_GetWidth(bitmap)); |
| 333 ASSERT_EQ(expected_height, FPDFBitmap_GetHeight(bitmap)); |
| 334 const int expected_stride = expected_width * 4; |
| 335 ASSERT_EQ(expected_stride, FPDFBitmap_GetStride(bitmap)); |
| 336 EXPECT_EQ(expected_md5sum, |
| 337 pdfium::MD5String(FPDFBitmap_GetBuffer(bitmap), |
| 338 expected_stride * expected_height)); |
| 339 } |
| 340 |
| 326 // Can't use gtest-provided main since we need to stash the path to the | 341 // Can't use gtest-provided main since we need to stash the path to the |
| 327 // executable in order to find the external V8 binary data files. | 342 // executable in order to find the external V8 binary data files. |
| 328 int main(int argc, char** argv) { | 343 int main(int argc, char** argv) { |
| 329 g_exe_path = argv[0]; | 344 g_exe_path = argv[0]; |
| 330 testing::InitGoogleTest(&argc, argv); | 345 testing::InitGoogleTest(&argc, argv); |
| 331 testing::InitGoogleMock(&argc, argv); | 346 testing::InitGoogleMock(&argc, argv); |
| 332 int ret_val = RUN_ALL_TESTS(); | 347 int ret_val = RUN_ALL_TESTS(); |
| 333 | 348 |
| 334 #ifdef PDF_ENABLE_V8 | 349 #ifdef PDF_ENABLE_V8 |
| 335 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 350 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 336 if (g_v8_natives) | 351 if (g_v8_natives) |
| 337 free(const_cast<char*>(g_v8_natives->data)); | 352 free(const_cast<char*>(g_v8_natives->data)); |
| 338 if (g_v8_snapshot) | 353 if (g_v8_snapshot) |
| 339 free(const_cast<char*>(g_v8_snapshot->data)); | 354 free(const_cast<char*>(g_v8_snapshot->data)); |
| 340 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 355 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 341 #endif // PDF_ENABLE_V8 | 356 #endif // PDF_ENABLE_V8 |
| 342 | 357 |
| 343 return ret_val; | 358 return ret_val; |
| 344 } | 359 } |
| OLD | NEW |