| 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 "base/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
| 6 #include "mojo/shell/context.h" | 6 #include "mojo/shell/context.h" |
| 7 #include "mojo/shell/dynamic_application_loader.h" | 7 #include "mojo/shell/dynamic_application_loader.h" |
| 8 #include "mojo/shell/dynamic_service_runner.h" | 8 #include "mojo/shell/dynamic_service_runner.h" |
| 9 #include "mojo/shell/filename_util.h" | 9 #include "mojo/shell/filename_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 bool runner_was_created; | 23 bool runner_was_created; |
| 24 bool runner_was_started; | 24 bool runner_was_started; |
| 25 bool runner_was_destroyed; | 25 bool runner_was_destroyed; |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 class TestDynamicServiceRunner : public DynamicServiceRunner { | 28 class TestDynamicServiceRunner : public DynamicServiceRunner { |
| 29 public: | 29 public: |
| 30 explicit TestDynamicServiceRunner(TestState* state) : state_(state) { | 30 explicit TestDynamicServiceRunner(TestState* state) : state_(state) { |
| 31 state_->runner_was_created = true; | 31 state_->runner_was_created = true; |
| 32 } | 32 } |
| 33 virtual ~TestDynamicServiceRunner() { | 33 ~TestDynamicServiceRunner() override { |
| 34 state_->runner_was_destroyed = true; | 34 state_->runner_was_destroyed = true; |
| 35 base::MessageLoop::current()->Quit(); | 35 base::MessageLoop::current()->Quit(); |
| 36 } | 36 } |
| 37 virtual void Start(const base::FilePath& app_path, | 37 void Start(const base::FilePath& app_path, |
| 38 ScopedMessagePipeHandle service_handle, | 38 ScopedMessagePipeHandle service_handle, |
| 39 const base::Closure& app_completed_callback) override { | 39 const base::Closure& app_completed_callback) override { |
| 40 state_->runner_was_started = true; | 40 state_->runner_was_started = true; |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 TestState* state_; | 44 TestState* state_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class TestDynamicServiceRunnerFactory : public DynamicServiceRunnerFactory { | 47 class TestDynamicServiceRunnerFactory : public DynamicServiceRunnerFactory { |
| 48 public: | 48 public: |
| 49 explicit TestDynamicServiceRunnerFactory(TestState* state) : state_(state) {} | 49 explicit TestDynamicServiceRunnerFactory(TestState* state) : state_(state) {} |
| 50 virtual ~TestDynamicServiceRunnerFactory() {} | 50 ~TestDynamicServiceRunnerFactory() override {} |
| 51 virtual scoped_ptr<DynamicServiceRunner> Create(Context* context) override { | 51 scoped_ptr<DynamicServiceRunner> Create(Context* context) override { |
| 52 return scoped_ptr<DynamicServiceRunner>( | 52 return scoped_ptr<DynamicServiceRunner>( |
| 53 new TestDynamicServiceRunner(state_)); | 53 new TestDynamicServiceRunner(state_)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 TestState* state_; | 57 TestState* state_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 scoped_refptr<ApplicationLoader::SimpleLoadCallbacks> callbacks( | 86 scoped_refptr<ApplicationLoader::SimpleLoadCallbacks> callbacks( |
| 87 new ApplicationLoader::SimpleLoadCallbacks(pipe.handle0.Pass())); | 87 new ApplicationLoader::SimpleLoadCallbacks(pipe.handle0.Pass())); |
| 88 loader_->Load(context_.application_manager(), url, callbacks); | 88 loader_->Load(context_.application_manager(), url, callbacks); |
| 89 EXPECT_FALSE(state_.runner_was_created); | 89 EXPECT_FALSE(state_.runner_was_created); |
| 90 EXPECT_FALSE(state_.runner_was_started); | 90 EXPECT_FALSE(state_.runner_was_started); |
| 91 EXPECT_FALSE(state_.runner_was_destroyed); | 91 EXPECT_FALSE(state_.runner_was_destroyed); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace shell | 94 } // namespace shell |
| 95 } // namespace mojo | 95 } // namespace mojo |
| OLD | NEW |