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

Unified Diff: components/arc/arc_service_manager_unittest.cc

Issue 2623273003: arc: Remove ArcServiceManager::Observer (Closed)
Patch Set: Moved Get() to the manager class per (verbal) feedback from Luis Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/arc_service_manager.cc ('k') | components/arc/intent_helper/arc_intent_helper_bridge.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_service_manager_unittest.cc
diff --git a/components/arc/arc_service_manager_unittest.cc b/components/arc/arc_service_manager_unittest.cc
index 98c4db86dd22e8db77e0524985ab925e9803c741..120d5ac343c8540a93aeef602709eadeb0013599 100644
--- a/components/arc/arc_service_manager_unittest.cc
+++ b/components/arc/arc_service_manager_unittest.cc
@@ -179,4 +179,31 @@ TEST_F(ArcServiceManagerTest, EmptyNamedServices) {
EXPECT_FALSE(empty_named_service_alive);
}
+// Tests if GetGlobalService works as expected regardless of whether the
+// global pointer is null.
+TEST_F(ArcServiceManagerTest, TestGetGlobalService) {
+ // The getter should return nullptr when no global instance is available.
+ EXPECT_EQ(nullptr, ArcServiceManager::GetGlobalService<NamedService>());
+
+ // Create a manager. This will automatically be registered as a global
+ // instance.
+ auto manager = base::MakeUnique<ArcServiceManager>(nullptr);
+
+ // The getter should return nullptr when the manager doesn't know about the
+ // NamedService instance.
+ EXPECT_EQ(nullptr, ArcServiceManager::GetGlobalService<NamedService>());
+
+ // Register the instance and retry. The getter should return non-null this
+ // time.
+ bool unused;
+ EXPECT_TRUE(manager->AddService(base::MakeUnique<NamedService>(
+ arc_bridge_service(), &unused)));
+ EXPECT_NE(nullptr, ArcServiceManager::GetGlobalService<NamedService>());
+
+ // Remove the global instance. The same GetGlobalService() call should return
+ // nullptr now.
+ manager.reset();
+ EXPECT_EQ(nullptr, ArcServiceManager::GetGlobalService<NamedService>());
+}
+
} // namespace arc
« no previous file with comments | « components/arc/arc_service_manager.cc ('k') | components/arc/intent_helper/arc_intent_helper_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698