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

Unified Diff: components/policy/core/common/schema_registry_unittest.cc

Issue 349643002: Decoupled the SchemaRegistryService from SchemaRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
Index: components/policy/core/common/schema_registry_unittest.cc
diff --git a/components/policy/core/common/schema_registry_unittest.cc b/components/policy/core/common/schema_registry_unittest.cc
index 36749ea4bcd95ae36aa4442ed7ce5724f0330a16..0ae29fc6397debf6a65309733d193dc16a495035 100644
--- a/components/policy/core/common/schema_registry_unittest.cc
+++ b/components/policy/core/common/schema_registry_unittest.cc
@@ -57,9 +57,7 @@ TEST(SchemaRegistryTest, Notifications) {
MockSchemaRegistryObserver observer;
SchemaRegistry registry;
- EXPECT_FALSE(registry.HasObservers());
registry.AddObserver(&observer);
- EXPECT_TRUE(registry.HasObservers());
ASSERT_TRUE(registry.schema_map());
EXPECT_FALSE(registry.schema_map()->GetSchema(
@@ -98,7 +96,6 @@ TEST(SchemaRegistryTest, Notifications) {
Mock::VerifyAndClearExpectations(&observer);
registry.RemoveObserver(&observer);
- EXPECT_FALSE(registry.HasObservers());
}
TEST(SchemaRegistryTest, IsReady) {
@@ -134,25 +131,25 @@ TEST(SchemaRegistryTest, Combined) {
ASSERT_TRUE(schema.valid()) << error;
MockSchemaRegistryObserver observer;
- SchemaRegistry registry1;
- SchemaRegistry registry2;
+ scoped_ptr<SchemaRegistry> registry1(new SchemaRegistry);
bartfab (slow) 2014/06/20 14:48:01 Nit: #include "base/memory/scoped_ptr.h"
Joao da Silva 2014/06/20 15:30:14 Done.
+ scoped_ptr<SchemaRegistry> registry2(new SchemaRegistry);
CombinedSchemaRegistry combined;
combined.AddObserver(&observer);
EXPECT_CALL(observer, OnSchemaRegistryUpdated(_)).Times(0);
- registry1.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"),
- schema);
+ registry1->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"),
+ schema);
Mock::VerifyAndClearExpectations(&observer);
// Starting to track a registry issues notifications when it comes with new
// schemas.
EXPECT_CALL(observer, OnSchemaRegistryUpdated(true));
- combined.Track(&registry1);
+ combined.Track(registry1.get());
Mock::VerifyAndClearExpectations(&observer);
// Adding a new empty registry does not trigger notifications.
EXPECT_CALL(observer, OnSchemaRegistryUpdated(_)).Times(0);
- combined.Track(&registry2);
+ combined.Track(registry2.get());
Mock::VerifyAndClearExpectations(&observer);
// Adding the same component to the combined registry itself triggers
@@ -164,15 +161,15 @@ TEST(SchemaRegistryTest, Combined) {
// Adding components to the sub-registries triggers notifications.
EXPECT_CALL(observer, OnSchemaRegistryUpdated(true));
- registry2.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def"),
- schema);
+ registry2->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def"),
+ schema);
Mock::VerifyAndClearExpectations(&observer);
// If the same component is published in 2 sub-registries then the combined
// registry publishes one of them.
EXPECT_CALL(observer, OnSchemaRegistryUpdated(true));
- registry1.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def"),
- schema);
+ registry1->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def"),
+ schema);
Mock::VerifyAndClearExpectations(&observer);
ASSERT_EQ(1u, combined.schema_map()->GetDomains().size());
@@ -188,7 +185,7 @@ TEST(SchemaRegistryTest, Combined) {
PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "xyz")));
EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
- registry1.UnregisterComponent(
+ registry1->UnregisterComponent(
PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"));
Mock::VerifyAndClearExpectations(&observer);
// Still registered at the combined registry.
@@ -204,7 +201,7 @@ TEST(SchemaRegistryTest, Combined) {
PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc")));
EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
- registry1.UnregisterComponent(
+ registry1->UnregisterComponent(
PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def"));
Mock::VerifyAndClearExpectations(&observer);
// Still registered at registry2.
@@ -212,7 +209,7 @@ TEST(SchemaRegistryTest, Combined) {
PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def")));
EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
- registry2.UnregisterComponent(
+ registry2->UnregisterComponent(
PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def"));
Mock::VerifyAndClearExpectations(&observer);
// Now it's gone.
@@ -220,20 +217,20 @@ TEST(SchemaRegistryTest, Combined) {
PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "def")));
EXPECT_CALL(observer, OnSchemaRegistryUpdated(true)).Times(2);
- registry1.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_CHROME, ""),
- schema);
- registry2.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "hij"),
- schema);
+ registry1->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_CHROME, ""),
+ schema);
+ registry2->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "hij"),
+ schema);
Mock::VerifyAndClearExpectations(&observer);
// Untracking |registry1| doesn't trigger an update notification, because it
// doesn't contain any components.
EXPECT_CALL(observer, OnSchemaRegistryUpdated(_)).Times(0);
- combined.Untrack(&registry1);
+ registry1.reset();
Mock::VerifyAndClearExpectations(&observer);
EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
- combined.Untrack(&registry2);
+ registry2.reset();
Mock::VerifyAndClearExpectations(&observer);
combined.RemoveObserver(&observer);

Powered by Google App Engine
This is Rietveld 408576698