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 "../public/fpdf_dataavail.h" | 10 #include "../public/fpdf_dataavail.h" |
11 #include "../public/fpdf_ext.h" | 11 #include "../public/fpdf_ext.h" |
12 #include "../public/fpdf_formfill.h" | 12 #include "../public/fpdf_formfill.h" |
13 #include "../public/fpdfview.h" | 13 #include "../public/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 UNSUPPORT_INFO, | 22 public UNSUPPORT_INFO, |
23 public IPDF_JSPLATFORM, | 23 public IPDF_JSPLATFORM, |
24 public FPDF_FORMFILLINFO { | 24 public FPDF_FORMFILLINFO { |
25 public: | 25 public: |
26 class Delegate { | 26 class Delegate { |
27 public: | 27 public: |
28 virtual ~Delegate() { } | 28 virtual ~Delegate() {} |
29 | 29 |
30 // Equivalent to UNSUPPORT_INFO::FSDK_UnSupport_Handler(). | 30 // Equivalent to UNSUPPORT_INFO::FSDK_UnSupport_Handler(). |
31 virtual void UnsupportedHandler(int type) { } | 31 virtual void UnsupportedHandler(int type) {} |
32 | 32 |
33 // Equivalent to IPDF_JSPLATFORM::app_alert(). | 33 // Equivalent to IPDF_JSPLATFORM::app_alert(). |
34 virtual int Alert(FPDF_WIDESTRING message, FPDF_WIDESTRING title, | 34 virtual int Alert(FPDF_WIDESTRING message, |
35 int type, int icon) { | 35 FPDF_WIDESTRING title, |
| 36 int type, |
| 37 int icon) { |
36 return 0; | 38 return 0; |
37 } | 39 } |
38 | 40 |
39 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer(). | 41 // Equivalent to FPDF_FORMFILLINFO::FFI_SetTimer(). |
40 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; } | 42 virtual int SetTimer(int msecs, TimerCallback fn) { return 0; } |
41 | 43 |
42 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer(). | 44 // Equivalent to FPDF_FORMFILLINFO::FFI_KillTimer(). |
43 virtual void KillTimer(int id) { } | 45 virtual void KillTimer(int id) {} |
44 }; | 46 }; |
45 | 47 |
46 EmbedderTest(); | 48 EmbedderTest(); |
47 virtual ~EmbedderTest(); | 49 virtual ~EmbedderTest(); |
48 | 50 |
49 void SetUp() override; | 51 void SetUp() override; |
50 void TearDown() override; | 52 void TearDown() override; |
51 | 53 |
52 void SetDelegate(Delegate* delegate) { | 54 void SetDelegate(Delegate* delegate) { |
53 delegate_ = delegate ? delegate : default_delegate_; | 55 delegate_ = delegate ? delegate : default_delegate_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 FX_FILEAVAIL file_avail_; | 90 FX_FILEAVAIL file_avail_; |
89 v8::Platform* platform_; | 91 v8::Platform* platform_; |
90 v8::StartupData natives_; | 92 v8::StartupData natives_; |
91 v8::StartupData snapshot_; | 93 v8::StartupData snapshot_; |
92 TestLoader* loader_; | 94 TestLoader* loader_; |
93 size_t file_length_; | 95 size_t file_length_; |
94 char* file_contents_; | 96 char* file_contents_; |
95 | 97 |
96 private: | 98 private: |
97 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); | 99 static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type); |
98 static int AlertTrampoline(IPDF_JSPLATFORM* plaform, FPDF_WIDESTRING message, | 100 static int AlertTrampoline(IPDF_JSPLATFORM* plaform, |
99 FPDF_WIDESTRING title, int type, int icon); | 101 FPDF_WIDESTRING message, |
100 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, int msecs, | 102 FPDF_WIDESTRING title, |
| 103 int type, |
| 104 int icon); |
| 105 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, |
| 106 int msecs, |
101 TimerCallback fn); | 107 TimerCallback fn); |
102 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); | 108 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); |
103 }; | 109 }; |
104 | 110 |
105 #endif // TESTING_EMBEDDER_TEST_H_ | 111 #endif // TESTING_EMBEDDER_TEST_H_ |
OLD | NEW |