| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 module_system_->OverrideNativeHandlerForTest(name); | 165 module_system_->OverrideNativeHandlerForTest(name); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ModuleSystemTest::RegisterTestFile(const std::string& module_name, | 168 void ModuleSystemTest::RegisterTestFile(const std::string& module_name, |
| 169 const std::string& file_name) { | 169 const std::string& file_name) { |
| 170 base::FilePath test_js_file_path; | 170 base::FilePath test_js_file_path; |
| 171 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_js_file_path)); | 171 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_js_file_path)); |
| 172 test_js_file_path = test_js_file_path.AppendASCII("extensions") | 172 test_js_file_path = test_js_file_path.AppendASCII("extensions") |
| 173 .AppendASCII(file_name); | 173 .AppendASCII(file_name); |
| 174 std::string test_js; | 174 std::string test_js; |
| 175 ASSERT_TRUE(file_util::ReadFileToString(test_js_file_path, &test_js)); | 175 ASSERT_TRUE(base::ReadFileToString(test_js_file_path, &test_js)); |
| 176 source_map_->RegisterModule(module_name, test_js); | 176 source_map_->RegisterModule(module_name, test_js); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ModuleSystemTest::TearDown() { | 179 void ModuleSystemTest::TearDown() { |
| 180 // All tests must assert at least once unless otherwise specified. | 180 // All tests must assert at least once unless otherwise specified. |
| 181 EXPECT_EQ(should_assertions_be_made_, | 181 EXPECT_EQ(should_assertions_be_made_, |
| 182 assert_natives_->assertion_made()); | 182 assert_natives_->assertion_made()); |
| 183 EXPECT_FALSE(assert_natives_->failed()); | 183 EXPECT_FALSE(assert_natives_->failed()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void ModuleSystemTest::ExpectNoAssertionsMade() { | 186 void ModuleSystemTest::ExpectNoAssertionsMade() { |
| 187 should_assertions_be_made_ = false; | 187 should_assertions_be_made_ = false; |
| 188 } | 188 } |
| 189 | 189 |
| 190 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { | 190 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { |
| 191 v8::HandleScope handle_scope; | 191 v8::HandleScope handle_scope; |
| 192 v8::Handle<v8::Object> object = v8::Object::New(); | 192 v8::Handle<v8::Object> object = v8::Object::New(); |
| 193 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), | 193 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), |
| 194 object); | 194 object); |
| 195 return handle_scope.Close(object); | 195 return handle_scope.Close(object); |
| 196 } | 196 } |
| OLD | NEW |