| 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 "gin/modules/module_registry.h" | 5 #include "gin/modules/module_registry.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" |
| 8 #include "gin/modules/module_registry_observer.h" | 9 #include "gin/modules/module_registry_observer.h" |
| 9 #include "gin/modules/module_runner_delegate.h" | 10 #include "gin/modules/module_runner_delegate.h" |
| 10 #include "gin/public/context_holder.h" | 11 #include "gin/public/context_holder.h" |
| 11 #include "gin/public/isolate_holder.h" | 12 #include "gin/public/isolate_holder.h" |
| 12 #include "gin/shell_runner.h" | 13 #include "gin/shell_runner.h" |
| 13 #include "gin/test/v8_test.h" | 14 #include "gin/test/v8_test.h" |
| 14 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
| 15 | 16 |
| 16 namespace gin { | 17 namespace gin { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 struct TestHelper { | 21 struct TestHelper { |
| 21 TestHelper(v8::Isolate* isolate) | 22 TestHelper(v8::Isolate* isolate) |
| 22 : delegate(std::vector<base::FilePath>()), | 23 : delegate(std::vector<base::FilePath>()), |
| 23 runner(new ShellRunner(&delegate, isolate)), | 24 runner(new ShellRunner(&delegate, isolate)), |
| 24 scope(runner.get()) { | 25 scope(runner.get()) { |
| 25 } | 26 } |
| 26 | 27 |
| 28 base::MessageLoop message_loop; |
| 27 ModuleRunnerDelegate delegate; | 29 ModuleRunnerDelegate delegate; |
| 28 scoped_ptr<ShellRunner> runner; | 30 scoped_ptr<ShellRunner> runner; |
| 29 Runner::Scope scope; | 31 Runner::Scope scope; |
| 30 }; | 32 }; |
| 31 | 33 |
| 32 class ModuleRegistryObserverImpl : public ModuleRegistryObserver { | 34 class ModuleRegistryObserverImpl : public ModuleRegistryObserver { |
| 33 public: | 35 public: |
| 34 ModuleRegistryObserverImpl() : did_add_count_(0) {} | 36 ModuleRegistryObserverImpl() : did_add_count_(0) {} |
| 35 | 37 |
| 36 void OnDidAddPendingModule( | 38 void OnDidAddPendingModule( |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 helper.runner->Run(source, "script"); | 155 helper.runner->Run(source, "script"); |
| 154 EXPECT_EQ(no_such_module_set, registry->unsatisfied_dependencies()); | 156 EXPECT_EQ(no_such_module_set, registry->unsatisfied_dependencies()); |
| 155 | 157 |
| 156 // Should have no effect on the unsatisfied_dependencies set. | 158 // Should have no effect on the unsatisfied_dependencies set. |
| 157 ModuleRegistry::LoadModuleCallback callback = base::Bind(OnModuleLoadedNoOp); | 159 ModuleRegistry::LoadModuleCallback callback = base::Bind(OnModuleLoadedNoOp); |
| 158 registry->LoadModule(instance_->isolate(), "one", callback); | 160 registry->LoadModule(instance_->isolate(), "one", callback); |
| 159 EXPECT_EQ(no_such_module_set, registry->unsatisfied_dependencies()); | 161 EXPECT_EQ(no_such_module_set, registry->unsatisfied_dependencies()); |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace gin | 164 } // namespace gin |
| OLD | NEW |