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

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

Issue 2441653003: Enable fetching of admin policies for login screen apps (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 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
« no previous file with comments | « components/policy/core/common/schema_registry.cc ('k') | components/policy/proto/device_management_backend.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698