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

Side by Side Diff: testing/embedder_test.cpp

Issue 1377293004: Run FXJS_V8 embedder tests against a shared isolate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase past massive rename 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 #include "embedder_test.h" 5 #include "embedder_test.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return 1; 116 return 1;
117 } 117 }
118 118
119 FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) { 119 FPDF_BOOL Is_Data_Avail(FX_FILEAVAIL* pThis, size_t offset, size_t size) {
120 return true; 120 return true;
121 } 121 }
122 122
123 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {} 123 void Add_Segment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {}
124 124
125 EmbedderTest::EmbedderTest() 125 EmbedderTest::EmbedderTest()
126 : document_(nullptr), 126 : default_delegate_(new EmbedderTest::Delegate()),
127 document_(nullptr),
127 form_handle_(nullptr), 128 form_handle_(nullptr),
128 avail_(nullptr), 129 avail_(nullptr),
130 external_isolate_(nullptr),
129 loader_(nullptr), 131 loader_(nullptr),
130 file_length_(0), 132 file_length_(0),
131 file_contents_(nullptr) { 133 file_contents_(nullptr) {
132 memset(&hints_, 0, sizeof(hints_)); 134 memset(&hints_, 0, sizeof(hints_));
133 memset(&file_access_, 0, sizeof(file_access_)); 135 memset(&file_access_, 0, sizeof(file_access_));
134 memset(&file_avail_, 0, sizeof(file_avail_)); 136 memset(&file_avail_, 0, sizeof(file_avail_));
135 default_delegate_ = new EmbedderTest::Delegate(); 137 delegate_ = default_delegate_.get();
136 delegate_ = default_delegate_;
137 } 138 }
138 139
139 EmbedderTest::~EmbedderTest() { 140 EmbedderTest::~EmbedderTest() {
140 delete default_delegate_;
141 } 141 }
142 142
143 void EmbedderTest::SetUp() { 143 void EmbedderTest::SetUp() {
144 v8::V8::InitializeICU(); 144 v8::V8::InitializeICU();
145 145
146 platform_ = v8::platform::CreateDefaultPlatform(); 146 platform_ = v8::platform::CreateDefaultPlatform();
147 v8::V8::InitializePlatform(platform_); 147 v8::V8::InitializePlatform(platform_);
148 v8::V8::Initialize(); 148 v8::V8::Initialize();
149 149
150 // By enabling predictable mode, V8 won't post any background tasks. 150 // By enabling predictable mode, V8 won't post any background tasks.
151 const char predictable_flag[] = "--predictable"; 151 const char predictable_flag[] = "--predictable";
152 v8::V8::SetFlagsFromString(predictable_flag, 152 v8::V8::SetFlagsFromString(predictable_flag,
153 static_cast<int>(strlen(predictable_flag))); 153 static_cast<int>(strlen(predictable_flag)));
154 154
155 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 155 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
156 ASSERT_TRUE(GetExternalData(g_exe_path_, "natives_blob.bin", &natives_)); 156 ASSERT_TRUE(GetExternalData(g_exe_path_, "natives_blob.bin", &natives_));
157 ASSERT_TRUE(GetExternalData(g_exe_path_, "snapshot_blob.bin", &snapshot_)); 157 ASSERT_TRUE(GetExternalData(g_exe_path_, "snapshot_blob.bin", &snapshot_));
158 v8::V8::SetNativesDataBlob(&natives_); 158 v8::V8::SetNativesDataBlob(&natives_);
159 v8::V8::SetSnapshotDataBlob(&snapshot_); 159 v8::V8::SetSnapshotDataBlob(&snapshot_);
160 #endif // V8_USE_EXTERNAL_STARTUP_DATA 160 #endif // V8_USE_EXTERNAL_STARTUP_DATA
161 161
162 FPDF_InitLibrary(); 162 FPDF_LIBRARY_CONFIG config;
163 config.version = 2;
164 config.m_pUserFontPaths = nullptr;
165 config.m_pIsolate = external_isolate_;
166 config.m_v8EmbedderSlot = 0;
167 FPDF_InitLibraryWithConfig(&config);
163 168
164 UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(this); 169 UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(this);
165 memset(info, 0, sizeof(UNSUPPORT_INFO)); 170 memset(info, 0, sizeof(UNSUPPORT_INFO));
166 info->version = 1; 171 info->version = 1;
167 info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline; 172 info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline;
168 FSDK_SetUnSpObjProcessHandler(info); 173 FSDK_SetUnSpObjProcessHandler(info);
169 } 174 }
170 175
171 void EmbedderTest::TearDown() { 176 void EmbedderTest::TearDown() {
172 if (document_) { 177 if (document_) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 346 }
342 347
343 // Can't use gtest-provided main since we need to stash the path to the 348 // Can't use gtest-provided main since we need to stash the path to the
344 // executable in order to find the external V8 binary data files. 349 // executable in order to find the external V8 binary data files.
345 int main(int argc, char** argv) { 350 int main(int argc, char** argv) {
346 g_exe_path_ = argv[0]; 351 g_exe_path_ = argv[0];
347 testing::InitGoogleTest(&argc, argv); 352 testing::InitGoogleTest(&argc, argv);
348 testing::InitGoogleMock(&argc, argv); 353 testing::InitGoogleMock(&argc, argv);
349 return RUN_ALL_TESTS(); 354 return RUN_ALL_TESTS();
350 } 355 }
OLDNEW
« fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp ('K') | « testing/embedder_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698