Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: testing/embedder_test.h

Issue 1377293004: Run FXJS_V8 embedder tests against a shared isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Alphabetize Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "../public/fpdf_dataavail.h" 11 #include "../public/fpdf_dataavail.h"
12 #include "../public/fpdf_ext.h" 12 #include "../public/fpdf_ext.h"
13 #include "../public/fpdf_formfill.h" 13 #include "../public/fpdf_formfill.h"
14 #include "../public/fpdfview.h" 14 #include "../public/fpdfview.h"
15 #include "../third_party/base/nonstd_unique_ptr.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "v8/include/v8.h" 17 #include "v8/include/v8.h"
17 18
18 class TestLoader; 19 class TestLoader;
19 20
20 // This class is used to load a PDF document, and then run programatic 21 // This class is used to load a PDF document, and then run programatic
21 // API tests against it. 22 // API tests against it.
22 class EmbedderTest : public ::testing::Test, 23 class EmbedderTest : public ::testing::Test,
23 public UNSUPPORT_INFO, 24 public UNSUPPORT_INFO,
24 public IPDF_JSPLATFORM, 25 public IPDF_JSPLATFORM,
25 public FPDF_FORMFILLINFO { 26 public FPDF_FORMFILLINFO {
26 public: 27 public:
27 class Delegate { 28 class Delegate {
28 public: 29 public:
29 virtual ~Delegate() {} 30 virtual ~Delegate() {}
30 31
32 // Override to return a shared isolate, otherwise PDFium creates one.
33 virtual v8::Isolate* GetSharedIsolate() const { return nullptr; }
34
31 // Equivalent to UNSUPPORT_INFO::FSDK_UnSupport_Handler(). 35 // Equivalent to UNSUPPORT_INFO::FSDK_UnSupport_Handler().
32 virtual void UnsupportedHandler(int type) {} 36 virtual void UnsupportedHandler(int type) {}
33 37
34 // Equivalent to IPDF_JSPLATFORM::app_alert(). 38 // Equivalent to IPDF_JSPLATFORM::app_alert().
35 virtual int Alert(FPDF_WIDESTRING message, 39 virtual int Alert(FPDF_WIDESTRING message,
36 FPDF_WIDESTRING title, 40 FPDF_WIDESTRING title,
37 int type, 41 int type,
38 int icon) { 42 int icon) {
39 return 0; 43 return 0;
40 } 44 }
(...skipping 13 matching lines...) Expand all
54 std::map<int, FPDF_PAGE> m_pageMap; 58 std::map<int, FPDF_PAGE> m_pageMap;
55 }; 59 };
56 60
57 EmbedderTest(); 61 EmbedderTest();
58 virtual ~EmbedderTest(); 62 virtual ~EmbedderTest();
59 63
60 void SetUp() override; 64 void SetUp() override;
61 void TearDown() override; 65 void TearDown() override;
62 66
63 void SetDelegate(Delegate* delegate) { 67 void SetDelegate(Delegate* delegate) {
64 delegate_ = delegate ? delegate : default_delegate_; 68 delegate_ = delegate ? delegate : default_delegate_.get();
65 } 69 }
66 70
67 FPDF_DOCUMENT document() { return document_; } 71 FPDF_DOCUMENT document() { return document_; }
68 FPDF_FORMHANDLE form_handle() { return form_handle_; } 72 FPDF_FORMHANDLE form_handle() { return form_handle_; }
69 73
70 // Open the document specified by |filename|, and create its form fill 74 // Open the document specified by |filename|, and create its form fill
71 // environment, or return false on failure. 75 // environment, or return false on failure.
72 virtual bool OpenDocument(const std::string& filename); 76 virtual bool OpenDocument(const std::string& filename);
73 77
74 // Perform JavaScript actions that are to run at document open time. 78 // Perform JavaScript actions that are to run at document open time.
(...skipping 12 matching lines...) Expand all
87 91
88 // Convert a loaded page into a bitmap. 92 // Convert a loaded page into a bitmap.
89 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page); 93 virtual FPDF_BITMAP RenderPage(FPDF_PAGE page);
90 94
91 // Relese the resources obtained from LoadPage(). Further use of |page| 95 // Relese the resources obtained from LoadPage(). Further use of |page|
92 // is prohibited after this call is made. 96 // is prohibited after this call is made.
93 virtual void UnloadPage(FPDF_PAGE page); 97 virtual void UnloadPage(FPDF_PAGE page);
94 98
95 protected: 99 protected:
96 Delegate* delegate_; 100 Delegate* delegate_;
97 Delegate* default_delegate_; 101 nonstd::unique_ptr<Delegate> default_delegate_;
98 FPDF_DOCUMENT document_; 102 FPDF_DOCUMENT document_;
99 FPDF_FORMHANDLE form_handle_; 103 FPDF_FORMHANDLE form_handle_;
100 FPDF_AVAIL avail_; 104 FPDF_AVAIL avail_;
101 FX_DOWNLOADHINTS hints_; 105 FX_DOWNLOADHINTS hints_;
102 FPDF_FILEACCESS file_access_; 106 FPDF_FILEACCESS file_access_;
103 FX_FILEAVAIL file_avail_; 107 FX_FILEAVAIL file_avail_;
104 v8::Platform* platform_; 108 v8::Platform* platform_;
105 v8::StartupData natives_; 109 v8::StartupData natives_;
106 v8::StartupData snapshot_; 110 v8::StartupData snapshot_;
107 TestLoader* loader_; 111 TestLoader* loader_;
(...skipping 10 matching lines...) Expand all
118 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info, 122 static int SetTimerTrampoline(FPDF_FORMFILLINFO* info,
119 int msecs, 123 int msecs,
120 TimerCallback fn); 124 TimerCallback fn);
121 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id); 125 static void KillTimerTrampoline(FPDF_FORMFILLINFO* info, int id);
122 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info, 126 static FPDF_PAGE GetPageTrampoline(FPDF_FORMFILLINFO* info,
123 FPDF_DOCUMENT document, 127 FPDF_DOCUMENT document,
124 int page_index); 128 int page_index);
125 }; 129 };
126 130
127 #endif // TESTING_EMBEDDER_TEST_H_ 131 #endif // TESTING_EMBEDDER_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698