Chromium Code Reviews| 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(®istry1); |
| + combined.Track(registry1.get()); |
| Mock::VerifyAndClearExpectations(&observer); |
| // Adding a new empty registry does not trigger notifications. |
| EXPECT_CALL(observer, OnSchemaRegistryUpdated(_)).Times(0); |
| - combined.Track(®istry2); |
| + 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(®istry1); |
| + registry1.reset(); |
| Mock::VerifyAndClearExpectations(&observer); |
| EXPECT_CALL(observer, OnSchemaRegistryUpdated(false)); |
| - combined.Untrack(®istry2); |
| + registry2.reset(); |
| Mock::VerifyAndClearExpectations(&observer); |
| combined.RemoveObserver(&observer); |