| 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" | |
| 16 #include "public/fpdf_text.h" | 15 #include "public/fpdf_text.h" |
| 17 #include "public/fpdfview.h" | 16 #include "public/fpdfview.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/test_support.h" | 18 #include "testing/test_support.h" |
| 20 #include "testing/utils/path_service.h" | 19 #include "testing/utils/path_service.h" |
| 21 | 20 |
| 22 #ifdef PDF_ENABLE_V8 | 21 #ifdef PDF_ENABLE_V8 |
| 23 #include "v8/include/v8.h" | 22 #include "v8/include/v8.h" |
| 24 #include "v8/include/v8-platform.h" | 23 #include "v8/include/v8-platform.h" |
| 25 #endif // PDF_ENABLE_V8 | 24 #endif // PDF_ENABLE_V8 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (!page) { | 206 if (!page) { |
| 208 return nullptr; | 207 return nullptr; |
| 209 } | 208 } |
| 210 FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_OPEN); | 209 FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_OPEN); |
| 211 return page; | 210 return page; |
| 212 } | 211 } |
| 213 | 212 |
| 214 FPDF_BITMAP EmbedderTest::RenderPage(FPDF_PAGE page) { | 213 FPDF_BITMAP EmbedderTest::RenderPage(FPDF_PAGE page) { |
| 215 int width = static_cast<int>(FPDF_GetPageWidth(page)); | 214 int width = static_cast<int>(FPDF_GetPageWidth(page)); |
| 216 int height = static_cast<int>(FPDF_GetPageHeight(page)); | 215 int height = static_cast<int>(FPDF_GetPageHeight(page)); |
| 217 int alpha = FPDFPage_HasTransparency(page) ? 1 : 0; | 216 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, 0); |
| 218 FPDF_BITMAP bitmap = FPDFBitmap_Create(width, height, alpha); | 217 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, 0xFFFFFFFF); |
| 219 FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF; | |
| 220 FPDFBitmap_FillRect(bitmap, 0, 0, width, height, fill_color); | |
| 221 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); | 218 FPDF_RenderPageBitmap(bitmap, page, 0, 0, width, height, 0, 0); |
| 222 FPDF_FFLDraw(form_handle_, bitmap, page, 0, 0, width, height, 0, 0); | 219 FPDF_FFLDraw(form_handle_, bitmap, page, 0, 0, width, height, 0, 0); |
| 223 return bitmap; | 220 return bitmap; |
| 224 } | 221 } |
| 225 | 222 |
| 226 void EmbedderTest::UnloadPage(FPDF_PAGE page) { | 223 void EmbedderTest::UnloadPage(FPDF_PAGE page) { |
| 227 FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_CLOSE); | 224 FORM_DoPageAAction(page, form_handle_, FPDFPAGE_AACTION_CLOSE); |
| 228 FORM_OnBeforeClosePage(page, form_handle_); | 225 FORM_OnBeforeClosePage(page, form_handle_); |
| 229 FPDF_ClosePage(page); | 226 FPDF_ClosePage(page); |
| 230 } | 227 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 282 } |
| 286 | 283 |
| 287 // Can't use gtest-provided main since we need to stash the path to the | 284 // Can't use gtest-provided main since we need to stash the path to the |
| 288 // executable in order to find the external V8 binary data files. | 285 // executable in order to find the external V8 binary data files. |
| 289 int main(int argc, char** argv) { | 286 int main(int argc, char** argv) { |
| 290 g_exe_path_ = argv[0]; | 287 g_exe_path_ = argv[0]; |
| 291 testing::InitGoogleTest(&argc, argv); | 288 testing::InitGoogleTest(&argc, argv); |
| 292 testing::InitGoogleMock(&argc, argv); | 289 testing::InitGoogleMock(&argc, argv); |
| 293 return RUN_ALL_TESTS(); | 290 return RUN_ALL_TESTS(); |
| 294 } | 291 } |
| OLD | NEW |