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

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

Issue 2420253002: Rename shell namespace to 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"
11 #include "base/process/process.h" 11 #include "base/process/process.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "services/service_manager/public/cpp/identity.h" 13 #include "services/service_manager/public/cpp/identity.h"
14 #include "services/service_manager/public/cpp/service_test.h" 14 #include "services/service_manager/public/cpp/service_test.h"
15 #include "services/service_manager/public/interfaces/service_manager.mojom.h" 15 #include "services/service_manager/public/interfaces/service_manager.mojom.h"
16 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h" 16 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h"
17 #include "services/service_manager/tests/util.h" 17 #include "services/service_manager/tests/util.h"
18 18
19 namespace shell { 19 namespace service_manager {
20 20
21 namespace { 21 namespace {
22 22
23 const char kTestAppName[] = "service:lifecycle_unittest_app"; 23 const char kTestAppName[] = "service:lifecycle_unittest_app";
24 const char kTestParentName[] = "service:lifecycle_unittest_parent"; 24 const char kTestParentName[] = "service:lifecycle_unittest_parent";
25 const char kTestExeName[] = "exe:lifecycle_unittest_exe"; 25 const char kTestExeName[] = "exe:lifecycle_unittest_exe";
26 const char kTestPackageName[] = "service:lifecycle_unittest_package"; 26 const char kTestPackageName[] = "service:lifecycle_unittest_package";
27 const char kTestPackageAppNameA[] = "service:lifecycle_unittest_package_app_a"; 27 const char kTestPackageAppNameA[] = "service:lifecycle_unittest_package_app_a";
28 const char kTestPackageAppNameB[] = "service:lifecycle_unittest_package_app_b"; 28 const char kTestPackageAppNameB[] = "service:lifecycle_unittest_package_app_b";
29 const char kTestName[] = "service:lifecycle_unittest"; 29 const char kTestName[] = "service:lifecycle_unittest";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 Instance i(instance->identity, instance->pid); 74 Instance i(instance->identity, instance->pid);
75 initial_instances_[i.identity.name()] = i; 75 initial_instances_[i.identity.name()] = i;
76 instances_[i.identity.name()] = i; 76 instances_[i.identity.name()] = i;
77 } 77 }
78 loop_->Quit(); 78 loop_->Quit();
79 } 79 }
80 void OnServiceCreated(mojom::ServiceInfoPtr instance) override { 80 void OnServiceCreated(mojom::ServiceInfoPtr instance) override {
81 instances_[instance->identity.name()] = 81 instances_[instance->identity.name()] =
82 Instance(instance->identity, instance->pid); 82 Instance(instance->identity, instance->pid);
83 } 83 }
84 void OnServiceStarted(const shell::Identity& identity, 84 void OnServiceStarted(const service_manager::Identity& identity,
85 uint32_t pid) override { 85 uint32_t pid) override {
86 for (auto& instance : instances_) { 86 for (auto& instance : instances_) {
87 if (instance.second.identity == identity) { 87 if (instance.second.identity == identity) {
88 instance.second.pid = pid; 88 instance.second.pid = pid;
89 break; 89 break;
90 } 90 }
91 } 91 }
92 } 92 }
93 void OnServiceStopped(const shell::Identity& identity) override { 93 void OnServiceStopped(const service_manager::Identity& identity) override {
94 for (auto it = instances_.begin(); it != instances_.end(); ++it) { 94 for (auto it = instances_.begin(); it != instances_.end(); ++it) {
95 if (it->second.identity == identity) { 95 if (it->second.identity == identity) {
96 instances_.erase(it); 96 instances_.erase(it);
97 break; 97 break;
98 } 98 }
99 } 99 }
100 TryToQuitDestructionLoop(); 100 TryToQuitDestructionLoop();
101 } 101 }
102 102
103 void TryToQuitDestructionLoop() { 103 void TryToQuitDestructionLoop() {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 parent->Quit(); 443 parent->Quit();
444 444
445 // Quitting the parent should cascade-quit the child. 445 // Quitting the parent should cascade-quit the child.
446 WaitForInstanceDestruction(); 446 WaitForInstanceDestruction();
447 EXPECT_EQ(0u, instances()->GetNewInstanceCount()); 447 EXPECT_EQ(0u, instances()->GetNewInstanceCount());
448 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName)); 448 EXPECT_FALSE(instances()->HasInstanceForName(kTestParentName));
449 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName)); 449 EXPECT_FALSE(instances()->HasInstanceForName(kTestAppName));
450 } 450 }
451 451
452 } // namespace shell 452 } // namespace service_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698