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/native_handler.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 | 106 |
107 void ModuleSystemTest::OverrideNativeHandler(const std::string& name, | 107 void ModuleSystemTest::OverrideNativeHandler(const std::string& name, |
108 const std::string& code) { | 108 const std::string& code) { |
109 RegisterModule(name, code); | 109 RegisterModule(name, code); |
110 module_system_->OverrideNativeHandler(name); | 110 module_system_->OverrideNativeHandler(name); |
111 } | 111 } |
112 | 112 |
113 void ModuleSystemTest::TearDown() { | 113 void ModuleSystemTest::TearDown() { |
114 if (try_catch_.HasCaught()) | 114 if (try_catch_.HasCaught()) |
115 ModuleSystem::DumpException(try_catch_.Message()); | 115 ModuleSystem::DumpException(try_catch_); |
116 EXPECT_FALSE(try_catch_.HasCaught()); | 116 EXPECT_FALSE(try_catch_.HasCaught()); |
117 // All tests must assert at least once unless otherwise specified. | 117 // All tests must assert at least once unless otherwise specified. |
118 EXPECT_EQ(should_assertions_be_made_, | 118 EXPECT_EQ(should_assertions_be_made_, |
119 assert_natives_->assertion_made()); | 119 assert_natives_->assertion_made()); |
120 EXPECT_FALSE(assert_natives_->failed()); | 120 EXPECT_FALSE(assert_natives_->failed()); |
121 } | 121 } |
122 | 122 |
123 void ModuleSystemTest::ExpectNoAssertionsMade() { | 123 void ModuleSystemTest::ExpectNoAssertionsMade() { |
124 should_assertions_be_made_ = false; | 124 should_assertions_be_made_ = false; |
125 } | 125 } |
126 | 126 |
127 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { | 127 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { |
128 v8::HandleScope handle_scope; | 128 v8::HandleScope handle_scope; |
129 v8::Handle<v8::Object> object = v8::Object::New(); | 129 v8::Handle<v8::Object> object = v8::Object::New(); |
130 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), | 130 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), |
131 object); | 131 object); |
132 return handle_scope.Close(object); | 132 return handle_scope.Close(object); |
133 } | 133 } |
OLD | NEW |