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