OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/module_system_test.h" | 5 #include "chrome/test/base/module_system_test.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "chrome/renderer/native_handler.h" | 10 #include "chrome/renderer/extensions/native_handler.h" |
11 #include "ui/base/layout.h" | 11 #include "ui/base/layout.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 | 16 |
| 17 using extensions::ModuleSystem; |
| 18 using extensions::NativeHandler; |
| 19 |
17 // Native JS functions for doing asserts. | 20 // Native JS functions for doing asserts. |
18 class AssertNatives : public NativeHandler { | 21 class AssertNatives : public NativeHandler { |
19 public: | 22 public: |
20 AssertNatives() | 23 AssertNatives() |
21 : assertion_made_(false), | 24 : assertion_made_(false), |
22 failed_(false) { | 25 failed_(false) { |
23 RouteFunction("AssertTrue", base::Bind(&AssertNatives::AssertTrue, | 26 RouteFunction("AssertTrue", base::Bind(&AssertNatives::AssertTrue, |
24 base::Unretained(this))); | 27 base::Unretained(this))); |
25 RouteFunction("AssertFalse", base::Bind(&AssertNatives::AssertFalse, | 28 RouteFunction("AssertFalse", base::Bind(&AssertNatives::AssertFalse, |
26 base::Unretained(this))); | 29 base::Unretained(this))); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 should_assertions_be_made_ = false; | 127 should_assertions_be_made_ = false; |
125 } | 128 } |
126 | 129 |
127 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { | 130 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { |
128 v8::HandleScope handle_scope; | 131 v8::HandleScope handle_scope; |
129 v8::Handle<v8::Object> object = v8::Object::New(); | 132 v8::Handle<v8::Object> object = v8::Object::New(); |
130 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), | 133 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), |
131 object); | 134 object); |
132 return handle_scope.Close(object); | 135 return handle_scope.Close(object); |
133 } | 136 } |
OLD | NEW |