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 5df0599c6ce8e9392988ccf80a1bd5a384e0d29d..08134d2f7d9b250d0f3e30f2dba6062afa647992 100644 |
--- a/components/policy/core/common/schema_registry_unittest.cc |
+++ b/components/policy/core/common/schema_registry_unittest.cc |
@@ -277,23 +277,18 @@ TEST(SchemaRegistryTest, ForwardingSchemaRegistry) { |
EXPECT_FALSE(registry->IsReady()); |
EXPECT_FALSE(forwarding.IsReady()); |
+ EXPECT_CALL(observer, OnSchemaRegistryReady()); |
registry->SetDomainReady(POLICY_DOMAIN_CHROME); |
EXPECT_TRUE(registry->IsReady()); |
- // The ForwardingSchemaRegistry becomes ready independently of the wrapped |
- // registry. |
- EXPECT_FALSE(forwarding.IsReady()); |
+ EXPECT_TRUE(forwarding.IsReady()); |
+ Mock::VerifyAndClearExpectations(&observer); |
EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); |
Mock::VerifyAndClearExpectations(&observer); |
forwarding.SetExtensionsDomainsReady(); |
- EXPECT_FALSE(forwarding.IsReady()); |
- Mock::VerifyAndClearExpectations(&observer); |
- |
- EXPECT_CALL(observer, OnSchemaRegistryReady()); |
forwarding.SetDomainReady(POLICY_DOMAIN_CHROME); |
EXPECT_TRUE(forwarding.IsReady()); |
- Mock::VerifyAndClearExpectations(&observer); |
// Keep the same SchemaMap when the original registry is gone. |
// No notifications are expected in this case either. |
@@ -305,4 +300,29 @@ TEST(SchemaRegistryTest, ForwardingSchemaRegistry) { |
forwarding.RemoveObserver(&observer); |
} |
+TEST(SchemaRegistryTest, ForwardingSchemaRegistryReadiness) { |
+ std::unique_ptr<SchemaRegistry> registry(new SchemaRegistry); |
+ |
+ ForwardingSchemaRegistry forwarding_1(registry.get()); |
+ EXPECT_FALSE(registry->IsReady()); |
+ EXPECT_FALSE(forwarding_1.IsReady()); |
+ |
+ // Once the wrapped registry gets ready, the forwarding schema registry |
+ // becomes ready too. |
+ registry->SetAllDomainsReady(); |
+ EXPECT_TRUE(registry->IsReady()); |
+ EXPECT_TRUE(forwarding_1.IsReady()); |
+ |
+ // The wrapped registry was ready at the time when the forwarding registry was |
+ // constructed, so the forwarding registry is immediately ready too. |
+ ForwardingSchemaRegistry forwarding_2(registry.get()); |
+ EXPECT_TRUE(forwarding_2.IsReady()); |
+ |
+ // Destruction of the wrapped registry doesn't change the readiness of the |
+ // forwarding registry. |
+ registry.reset(); |
+ EXPECT_TRUE(forwarding_1.IsReady()); |
+ EXPECT_TRUE(forwarding_2.IsReady()); |
+} |
+ |
} // namespace policy |