OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 void InitPackage() { | 152 void InitPackage() { |
153 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestPackageName); | 153 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestPackageName); |
154 base::RunLoop loop; | 154 base::RunLoop loop; |
155 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); | 155 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); |
156 lifecycle->GracefulQuit(); | 156 lifecycle->GracefulQuit(); |
157 loop.Run(); | 157 loop.Run(); |
158 } | 158 } |
159 | 159 |
160 test::mojom::LifecycleControlPtr ConnectTo(const std::string& name) { | 160 test::mojom::LifecycleControlPtr ConnectTo(const std::string& name) { |
161 test::mojom::LifecycleControlPtr lifecycle; | 161 test::mojom::LifecycleControlPtr lifecycle; |
162 connector()->ConnectToInterface(name, &lifecycle); | 162 connector()->BindInterface(name, &lifecycle); |
163 PingPong(lifecycle.get()); | 163 PingPong(lifecycle.get()); |
164 return lifecycle; | 164 return lifecycle; |
165 } | 165 } |
166 | 166 |
167 base::Process LaunchProcess() { | 167 base::Process LaunchProcess() { |
168 base::Process process; | 168 base::Process process; |
169 test::LaunchAndConnectToProcess( | 169 test::LaunchAndConnectToProcess( |
170 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
171 "lifecycle_unittest_exe.exe", | 171 "lifecycle_unittest_exe.exe", |
172 #else | 172 #else |
(...skipping 15 matching lines...) Expand all Loading... |
188 | 188 |
189 void WaitForInstanceDestruction() { | 189 void WaitForInstanceDestruction() { |
190 base::RunLoop loop; | 190 base::RunLoop loop; |
191 instances()->WaitForInstanceDestruction(&loop); | 191 instances()->WaitForInstanceDestruction(&loop); |
192 loop.Run(); | 192 loop.Run(); |
193 } | 193 } |
194 | 194 |
195 private: | 195 private: |
196 std::unique_ptr<InstanceState> TrackInstances() { | 196 std::unique_ptr<InstanceState> TrackInstances() { |
197 mojom::ServiceManagerPtr service_manager; | 197 mojom::ServiceManagerPtr service_manager; |
198 connector()->ConnectToInterface(service_manager::mojom::kServiceName, | 198 connector()->BindInterface(service_manager::mojom::kServiceName, |
199 &service_manager); | 199 &service_manager); |
200 mojom::ServiceManagerListenerPtr listener; | 200 mojom::ServiceManagerListenerPtr listener; |
201 base::RunLoop loop; | 201 base::RunLoop loop; |
202 InstanceState* state = new InstanceState(MakeRequest(&listener), &loop); | 202 InstanceState* state = new InstanceState(MakeRequest(&listener), &loop); |
203 service_manager->AddListener(std::move(listener)); | 203 service_manager->AddListener(std::move(listener)); |
204 loop.Run(); | 204 loop.Run(); |
205 return base::WrapUnique(state); | 205 return base::WrapUnique(state); |
206 } | 206 } |
207 | 207 |
208 std::unique_ptr<InstanceState> instances_; | 208 std::unique_ptr<InstanceState> instances_; |
209 | 209 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); | 419 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); |
420 process.Terminate(9, true); | 420 process.Terminate(9, true); |
421 loop.Run(); | 421 loop.Run(); |
422 | 422 |
423 WaitForInstanceDestruction(); | 423 WaitForInstanceDestruction(); |
424 EXPECT_FALSE(instances()->HasInstanceForName(kTestExeName)); | 424 EXPECT_FALSE(instances()->HasInstanceForName(kTestExeName)); |
425 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); | 425 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); |
426 } | 426 } |
427 | 427 |
428 } // namespace service_manager | 428 } // namespace service_manager |
OLD | NEW |