| 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 "mojo/shell/shell_test_helper.h" | 5 #include "mojo/shell/shell_test_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/shell/context.h" | 10 #include "mojo/shell/context.h" |
| 11 #include "mojo/shell/init.h" | 11 #include "mojo/shell/init.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 namespace shell { | 14 namespace shell { |
| 15 | 15 |
| 16 // State used on the background thread. Be careful, this is created on the main | 16 // State used on the background thread. Be careful, this is created on the main |
| 17 // thread than passed to the shell thread. Destruction happens on the shell | 17 // thread than passed to the shell thread. Destruction happens on the shell |
| 18 // thread. | 18 // thread. |
| 19 struct ShellTestHelper::State { | 19 struct ShellTestHelper::State { |
| 20 scoped_ptr<Context> context; | 20 scoped_ptr<Context> context; |
| 21 scoped_ptr<ServiceManager::TestAPI> test_api; | 21 scoped_ptr<ServiceManager::TestAPI> test_api; |
| 22 ScopedShellHandle shell_handle; | 22 ScopedMessagePipeHandle shell_handle; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 void StartShellOnShellThread(ShellTestHelper::State* state) { | 27 void StartShellOnShellThread(ShellTestHelper::State* state) { |
| 28 state->context.reset(new Context); | 28 state->context.reset(new Context); |
| 29 state->test_api.reset( | 29 state->test_api.reset( |
| 30 new ServiceManager::TestAPI(state->context->service_manager())); | 30 new ServiceManager::TestAPI(state->context->service_manager())); |
| 31 state->shell_handle = state->test_api->GetShellHandle(); | 31 state->shell_handle = state->test_api->GetShellHandle(); |
| 32 } | 32 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 FROM_HERE, | 72 FROM_HERE, |
| 73 base::Bind(&StartShellOnShellThread, state_), | 73 base::Bind(&StartShellOnShellThread, state_), |
| 74 base::Bind(&ShellTestHelper::OnShellStarted, base::Unretained(this))); | 74 base::Bind(&ShellTestHelper::OnShellStarted, base::Unretained(this))); |
| 75 run_loop_.reset(new base::RunLoop); | 75 run_loop_.reset(new base::RunLoop); |
| 76 run_loop_->Run(); | 76 run_loop_->Run(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void ShellTestHelper::OnShellStarted() { | 79 void ShellTestHelper::OnShellStarted() { |
| 80 DCHECK(state_); | 80 DCHECK(state_); |
| 81 shell_client_.reset(new TestShellClient); | 81 shell_client_.reset(new TestShellClient); |
| 82 shell_.reset(state_->shell_handle.Pass(), shell_client_.get()); | 82 shell_.Bind(state_->shell_handle.Pass()); |
| 83 shell_->SetClient(shell_client_.get()); |
| 83 run_loop_->Quit(); | 84 run_loop_->Quit(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 } // namespace shell | 87 } // namespace shell |
| 87 } // namespace mojo | 88 } // namespace mojo |
| OLD | NEW |