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

Side by Side Diff: extensions/renderer/api_test_base.cc

Issue 2936213002: [Extensions] Don't require() a module for calling a method (Closed)
Patch Set: lazyboy's Created 3 years, 6 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
« no previous file with comments | « no previous file | extensions/renderer/json_schema_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium 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 "extensions/renderer/api_test_base.h" 5 #include "extensions/renderer/api_test_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool did_run = false; 215 bool did_run = false;
216 auto callback = [](bool* did_run, const base::Closure& quit_closure, 216 auto callback = [](bool* did_run, const base::Closure& quit_closure,
217 const std::string& test_name, 217 const std::string& test_name,
218 const std::vector<v8::Local<v8::Value>>& result) { 218 const std::vector<v8::Local<v8::Value>>& result) {
219 *did_run = true; 219 *did_run = true;
220 if (result.empty() || result[0].IsEmpty() || !result[0]->IsTrue()) { 220 if (result.empty() || result[0].IsEmpty() || !result[0]->IsTrue()) {
221 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure); 221 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
222 FAIL() << "Failed to run test \"" << test_name << "\""; 222 FAIL() << "Failed to run test \"" << test_name << "\"";
223 } 223 }
224 }; 224 };
225
226 ASSERT_FALSE(
227 env()->module_system()->Require("testBody").ToLocalChecked().IsEmpty());
225 env()->module_system()->CallModuleMethodSafe( 228 env()->module_system()->CallModuleMethodSafe(
226 "testBody", test_name, 0, nullptr, 229 "testBody", test_name, 0, nullptr,
227 base::Bind(callback, &did_run, quit_closure, test_name)); 230 base::Bind(callback, &did_run, quit_closure, test_name));
228 ASSERT_TRUE(did_run); 231 ASSERT_TRUE(did_run);
229 } 232 }
230 233
231 void ApiTestEnvironment::RunPromisesAgain() { 234 void ApiTestEnvironment::RunPromisesAgain() {
232 v8::MicrotasksScope::PerformCheckpoint(env()->isolate()); 235 v8::MicrotasksScope::PerformCheckpoint(env()->isolate());
233 base::ThreadTaskRunnerHandle::Get()->PostTask( 236 base::ThreadTaskRunnerHandle::Get()->PostTask(
234 FROM_HERE, base::Bind(&ApiTestEnvironment::RunPromisesAgain, 237 FROM_HERE, base::Bind(&ApiTestEnvironment::RunPromisesAgain,
(...skipping 11 matching lines...) Expand all
246 test_env_.reset(new ApiTestEnvironment(env())); 249 test_env_.reset(new ApiTestEnvironment(env()));
247 } 250 }
248 251
249 void ApiTestBase::RunTest(const std::string& file_name, 252 void ApiTestBase::RunTest(const std::string& file_name,
250 const std::string& test_name) { 253 const std::string& test_name) {
251 ExpectNoAssertionsMade(); 254 ExpectNoAssertionsMade();
252 test_env_->RunTest(file_name, test_name); 255 test_env_->RunTest(file_name, test_name);
253 } 256 }
254 257
255 } // namespace extensions 258 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/json_schema_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698