Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: services/service_manager/tests/lifecycle/lifecycle_unittest.cc

Issue 2427443002: Replace remaining shell references with service manager (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 void WaitForInstanceDestruction() { 185 void WaitForInstanceDestruction() {
186 base::RunLoop loop; 186 base::RunLoop loop;
187 instances()->WaitForInstanceDestruction(&loop); 187 instances()->WaitForInstanceDestruction(&loop);
188 loop.Run(); 188 loop.Run();
189 } 189 }
190 190
191 private: 191 private:
192 std::unique_ptr<InstanceState> TrackInstances() { 192 std::unique_ptr<InstanceState> TrackInstances() {
193 mojom::ServiceManagerPtr service_manager; 193 mojom::ServiceManagerPtr service_manager;
194 connector()->ConnectToInterface("service:shell", &service_manager); 194 connector()->ConnectToInterface("service:service_manager",
195 &service_manager);
195 mojom::ServiceManagerListenerPtr listener; 196 mojom::ServiceManagerListenerPtr listener;
196 base::RunLoop loop; 197 base::RunLoop loop;
197 InstanceState* state = new InstanceState(GetProxy(&listener), &loop); 198 InstanceState* state = new InstanceState(GetProxy(&listener), &loop);
198 service_manager->AddListener(std::move(listener)); 199 service_manager->AddListener(std::move(listener));
199 loop.Run(); 200 loop.Run();
200 return base::WrapUnique(state); 201 return base::WrapUnique(state);
201 } 202 }
202 203
203 std::unique_ptr<InstanceState> instances_; 204 std::unique_ptr<InstanceState> instances_;
204 205
(...skipping 30 matching lines...) Expand all
235 base::RunLoop loop; 236 base::RunLoop loop;
236 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); 237 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop));
237 lifecycle->Crash(); 238 lifecycle->Crash();
238 loop.Run(); 239 loop.Run();
239 240
240 WaitForInstanceDestruction(); 241 WaitForInstanceDestruction();
241 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName)); 242 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName));
242 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); 243 EXPECT_EQ(0u, instances()->GetNewInstanceCount());
243 } 244 }
244 245
245 TEST_F(LifecycleTest, Standalone_CloseShellConnection) { 246 TEST_F(LifecycleTest, Standalone_CloseServiceManagerConnection) {
246 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestAppName); 247 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestAppName);
247 248
248 EXPECT_TRUE(instances()->HasInstanceForName(kTestAppName)); 249 EXPECT_TRUE(instances()->HasInstanceForName(kTestAppName));
249 EXPECT_EQ(1u, instances()->GetNewInstanceCount()); 250 EXPECT_EQ(1u, instances()->GetNewInstanceCount());
250 251
251 base::RunLoop loop; 252 base::RunLoop loop;
252 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop)); 253 lifecycle.set_connection_error_handler(base::Bind(&QuitLoop, &loop));
253 lifecycle->CloseShellConnection(); 254 lifecycle->CloseServiceManagerConnection();
254 255
255 WaitForInstanceDestruction(); 256 WaitForInstanceDestruction();
256 257
257 // |lifecycle| pipe should still be valid. 258 // |lifecycle| pipe should still be valid.
258 PingPong(lifecycle.get()); 259 PingPong(lifecycle.get());
259 } 260 }
260 261
261 TEST_F(LifecycleTest, PackagedApp_GracefulQuit) { 262 TEST_F(LifecycleTest, PackagedApp_GracefulQuit) {
262 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestPackageAppNameA); 263 test::mojom::LifecycleControlPtr lifecycle = ConnectTo(kTestPackageAppNameA);
263 264
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 parent->Quit(); 444 parent->Quit();
444 445
445 // Quitting the parent should cascade-quit the child. 446 // Quitting the parent should cascade-quit the child.
446 WaitForInstanceDestruction(); 447 WaitForInstanceDestruction();
447 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); 448 EXPECT_EQ(0u, instances()->GetNewInstanceCount());
448 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName)); 449 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName));
449 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName)); 450 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName));
450 } 451 }
451 452
452 } // namespace service_manager 453 } // namespace service_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698