OLD | NEW |
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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "extensions/common/extension_urls.h" | 10 #include "extensions/common/extension_urls.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Natives for the implementation of the unit test version of chrome.test. Calls | 24 // Natives for the implementation of the unit test version of chrome.test. Calls |
25 // the provided |quit_closure| when either notifyPass or notifyFail is called. | 25 // the provided |quit_closure| when either notifyPass or notifyFail is called. |
26 class TestNatives : public gin::Wrappable<TestNatives> { | 26 class TestNatives : public gin::Wrappable<TestNatives> { |
27 public: | 27 public: |
28 static gin::Handle<TestNatives> Create(v8::Isolate* isolate, | 28 static gin::Handle<TestNatives> Create(v8::Isolate* isolate, |
29 const base::Closure& quit_closure) { | 29 const base::Closure& quit_closure) { |
30 return gin::CreateHandle(isolate, new TestNatives(quit_closure)); | 30 return gin::CreateHandle(isolate, new TestNatives(quit_closure)); |
31 } | 31 } |
32 | 32 |
33 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | 33 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
34 v8::Isolate* isolate) OVERRIDE { | 34 v8::Isolate* isolate) override { |
35 return Wrappable<TestNatives>::GetObjectTemplateBuilder(isolate) | 35 return Wrappable<TestNatives>::GetObjectTemplateBuilder(isolate) |
36 .SetMethod("Log", &TestNatives::Log) | 36 .SetMethod("Log", &TestNatives::Log) |
37 .SetMethod("NotifyPass", &TestNatives::NotifyPass) | 37 .SetMethod("NotifyPass", &TestNatives::NotifyPass) |
38 .SetMethod("NotifyFail", &TestNatives::NotifyFail); | 38 .SetMethod("NotifyFail", &TestNatives::NotifyFail); |
39 } | 39 } |
40 | 40 |
41 void Log(const std::string& value) { logs_ += value + "\n"; } | 41 void Log(const std::string& value) { logs_ += value + "\n"; } |
42 void NotifyPass() { FinishTesting(); } | 42 void NotifyPass() { FinishTesting(); } |
43 | 43 |
44 void NotifyFail(const std::string& message) { | 44 void NotifyFail(const std::string& message) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 void ApiTestBase::RunPromisesAgain() { | 214 void ApiTestBase::RunPromisesAgain() { |
215 RunResolvedPromises(); | 215 RunResolvedPromises(); |
216 base::MessageLoop::current()->PostTask( | 216 base::MessageLoop::current()->PostTask( |
217 FROM_HERE, | 217 FROM_HERE, |
218 base::Bind(&ApiTestBase::RunPromisesAgain, base::Unretained(this))); | 218 base::Bind(&ApiTestBase::RunPromisesAgain, base::Unretained(this))); |
219 } | 219 } |
220 | 220 |
221 } // namespace extensions | 221 } // namespace extensions |
OLD | NEW |