OLD | NEW |
1 // Copyright (c) 2015 PDFium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef TESTING_EMBEDDER_TEST_H_ | 5 #ifndef TESTING_EMBEDDER_TEST_H_ |
6 #define TESTING_EMBEDDER_TEST_H_ | 6 #define TESTING_EMBEDDER_TEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "../core/include/fxcrt/fx_system.h" | 10 #include "../core/include/fxcrt/fx_system.h" |
11 #include "../fpdfsdk/include/fpdf_dataavail.h" | 11 #include "../fpdfsdk/include/fpdf_dataavail.h" |
12 #include "../fpdfsdk/include/fpdfformfill.h" | 12 #include "../fpdfsdk/include/fpdfformfill.h" |
13 #include "../fpdfsdk/include/fpdfview.h" | 13 #include "../fpdfsdk/include/fpdfview.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
16 | 16 |
17 class TestLoader; | 17 class TestLoader; |
18 | 18 |
19 // This class is used to load a PDF document, and then run programatic | 19 // This class is used to load a PDF document, and then run programatic |
20 // API tests against it. | 20 // API tests against it. |
21 class EmbedderTest : public ::testing::Test { | 21 class EmbedderTest : public ::testing::Test { |
22 public: | 22 public: |
23 EmbedderTest() : | 23 EmbedderTest() : |
24 document_(nullptr), | 24 document_(nullptr), |
| 25 form_handle_(nullptr), |
25 avail_(nullptr), | 26 avail_(nullptr), |
26 loader_(nullptr), | 27 loader_(nullptr), |
27 file_length_(0), | 28 file_length_(0), |
28 file_contents_(nullptr) { | 29 file_contents_(nullptr) { |
29 memset(&hints_, 0, sizeof(hints_)); | 30 memset(&hints_, 0, sizeof(hints_)); |
30 memset(&file_access_, 0, sizeof(file_access_)); | 31 memset(&file_access_, 0, sizeof(file_access_)); |
31 memset(&file_avail_, 0, sizeof(file_avail_)); | 32 memset(&file_avail_, 0, sizeof(file_avail_)); |
32 } | 33 } |
33 | 34 |
34 virtual ~EmbedderTest() { } | 35 virtual ~EmbedderTest() { } |
35 | 36 |
36 void SetUp() override; | 37 void SetUp() override; |
37 void TearDown() override; | 38 void TearDown() override; |
38 | 39 |
39 FPDF_DOCUMENT document() { return document_; } | 40 FPDF_DOCUMENT document() { return document_; } |
| 41 FPDF_FORMHANDLE form_handle() { return form_handle_; } |
40 | 42 |
41 // Open the document specified by |filename|, or return false on failure. | 43 // Open the document specified by |filename|, and create its form fill |
| 44 // environment, or return false on failure. |
42 virtual bool OpenDocument(const std::string& filename); | 45 virtual bool OpenDocument(const std::string& filename); |
43 | 46 |
44 // Create and return a handle to the form fill module for use with the | |
45 // FORM_ family of functions from fpdfformfill.h, or return NULL on failure. | |
46 virtual FPDF_FORMHANDLE SetFormFillEnvironment(); | |
47 | |
48 // Release the resources obtained from SetFormFillEnvironment(). | |
49 virtual void ClearFormFillEnvironment(FPDF_FORMHANDLE form); | |
50 | |
51 // Perform JavaScript actions that are to run at document open time. | 47 // Perform JavaScript actions that are to run at document open time. |
52 virtual void DoOpenActions(FPDF_FORMHANDLE form); | 48 virtual void DoOpenActions(); |
53 | 49 |
54 // Determine the page numbers present in the document. | 50 // Determine the page numbers present in the document. |
55 virtual int GetFirstPageNum(); | 51 virtual int GetFirstPageNum(); |
56 virtual int GetPageCount(); | 52 virtual int GetPageCount(); |
57 | 53 |
58 // Load a specific page of the open document. | 54 // Load a specific page of the open document. |
59 virtual FPDF_PAGE LoadPage(int page_number, FPDF_FORMHANDLE form); | 55 virtual FPDF_PAGE LoadPage(int page_number); |
60 | 56 |
61 // Convert a loaded page into a bitmap. | 57 // Convert a loaded page into a bitmap. |
62 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page, FPDF_FORMHANDLE form); | 58 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); |
63 | 59 |
64 // Relese the resources obtained from LoadPage(). Further use of |page| | 60 // Relese the resources obtained from LoadPage(). Further use of |page| |
65 // is prohibited after this call is made. | 61 // is prohibited after this call is made. |
66 virtual void UnloadPage(FPDF_PAGE page, FPDF_FORMHANDLE form); | 62 virtual void UnloadPage(FPDF_PAGE page); |
67 | 63 |
68 protected: | 64 protected: |
69 FPDF_DOCUMENT document_; | 65 FPDF_DOCUMENT document_; |
| 66 FPDF_FORMHANDLE form_handle_; |
70 FPDF_AVAIL avail_; | 67 FPDF_AVAIL avail_; |
71 FX_DOWNLOADHINTS hints_; | 68 FX_DOWNLOADHINTS hints_; |
72 FPDF_FILEACCESS file_access_; | 69 FPDF_FILEACCESS file_access_; |
73 FX_FILEAVAIL file_avail_; | 70 FX_FILEAVAIL file_avail_; |
74 v8::StartupData natives_; | 71 v8::StartupData natives_; |
75 v8::StartupData snapshot_; | 72 v8::StartupData snapshot_; |
76 TestLoader* loader_; | 73 TestLoader* loader_; |
77 size_t file_length_; | 74 size_t file_length_; |
78 char* file_contents_; | 75 char* file_contents_; |
79 }; | 76 }; |
80 | 77 |
81 #endif // TESTING_EMBEDDER_TEST_H_ | 78 #endif // TESTING_EMBEDDER_TEST_H_ |
82 | 79 |
OLD | NEW |