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

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: 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 #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),
129 loader_(nullptr), 130 loader_(nullptr),
130 file_length_(0), 131 file_length_(0),
131 file_contents_(nullptr) { 132 file_contents_(nullptr) {
132 memset(&hints_, 0, sizeof(hints_)); 133 memset(&hints_, 0, sizeof(hints_));
133 memset(&file_access_, 0, sizeof(file_access_)); 134 memset(&file_access_, 0, sizeof(file_access_));
134 memset(&file_avail_, 0, sizeof(file_avail_)); 135 memset(&file_avail_, 0, sizeof(file_avail_));
135 default_delegate_ = new EmbedderTest::Delegate(); 136 delegate_ = default_delegate_.get();
136 delegate_ = default_delegate_;
137 } 137 }
138 138
139 EmbedderTest::~EmbedderTest() { 139 EmbedderTest::~EmbedderTest() {
140 delete default_delegate_;
141 } 140 }
142 141
143 void EmbedderTest::SetUp() { 142 void EmbedderTest::SetUp() {
144 v8::V8::InitializeICU(); 143 v8::V8::InitializeICU();
145 144
146 platform_ = v8::platform::CreateDefaultPlatform(); 145 platform_ = v8::platform::CreateDefaultPlatform();
147 v8::V8::InitializePlatform(platform_); 146 v8::V8::InitializePlatform(platform_);
148 v8::V8::Initialize(); 147 v8::V8::Initialize();
149 148
150 // By enabling predictable mode, V8 won't post any background tasks. 149 // By enabling predictable mode, V8 won't post any background tasks.
151 const char predictable_flag[] = "--predictable"; 150 const char predictable_flag[] = "--predictable";
152 v8::V8::SetFlagsFromString(predictable_flag, 151 v8::V8::SetFlagsFromString(predictable_flag,
153 static_cast<int>(strlen(predictable_flag))); 152 static_cast<int>(strlen(predictable_flag)));
154 153
155 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 154 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
156 ASSERT_TRUE(GetExternalData(g_exe_path_, "natives_blob.bin", &natives_)); 155 ASSERT_TRUE(GetExternalData(g_exe_path_, "natives_blob.bin", &natives_));
157 ASSERT_TRUE(GetExternalData(g_exe_path_, "snapshot_blob.bin", &snapshot_)); 156 ASSERT_TRUE(GetExternalData(g_exe_path_, "snapshot_blob.bin", &snapshot_));
158 v8::V8::SetNativesDataBlob(&natives_); 157 v8::V8::SetNativesDataBlob(&natives_);
159 v8::V8::SetSnapshotDataBlob(&snapshot_); 158 v8::V8::SetSnapshotDataBlob(&snapshot_);
160 #endif // V8_USE_EXTERNAL_STARTUP_DATA 159 #endif // V8_USE_EXTERNAL_STARTUP_DATA
161 160
162 FPDF_InitLibrary(); 161 FPDF_LIBRARY_CONFIG config;
162 config.version = 2;
163 config.m_pUserFontPaths = nullptr;
164 config.m_pIsolate = delegate_->GetSharedIsolate();
165 config.m_v8EmbedderSlot = 0;
166 FPDF_InitLibraryWithConfig(&config);
163 167
164 UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(this); 168 UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(this);
165 memset(info, 0, sizeof(UNSUPPORT_INFO)); 169 memset(info, 0, sizeof(UNSUPPORT_INFO));
166 info->version = 1; 170 info->version = 1;
167 info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline; 171 info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline;
168 FSDK_SetUnSpObjProcessHandler(info); 172 FSDK_SetUnSpObjProcessHandler(info);
169 } 173 }
170 174
171 void EmbedderTest::TearDown() { 175 void EmbedderTest::TearDown() {
172 if (document_) { 176 if (document_) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 345 }
342 346
343 // Can't use gtest-provided main since we need to stash the path to the 347 // 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. 348 // executable in order to find the external V8 binary data files.
345 int main(int argc, char** argv) { 349 int main(int argc, char** argv) {
346 g_exe_path_ = argv[0]; 350 g_exe_path_ = argv[0];
347 testing::InitGoogleTest(&argc, argv); 351 testing::InitGoogleTest(&argc, argv);
348 testing::InitGoogleMock(&argc, argv); 352 testing::InitGoogleMock(&argc, argv);
349 return RUN_ALL_TESTS(); 353 return RUN_ALL_TESTS();
350 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698