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

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

Issue 2441653003: Enable fetching of admin policies for login screen apps (Closed)
Patch Set: Created 4 years, 2 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 426e84a815669af07353992319fff7d94b7ab355..3609ee86ed652fb55f80ed048f041698fdbc701a 100644
--- a/components/policy/core/common/schema_registry_unittest.cc
+++ b/components/policy/core/common/schema_registry_unittest.cc
@@ -249,7 +249,8 @@ TEST(SchemaRegistryTest, Combined) {
TEST(SchemaRegistryTest, ForwardingSchemaRegistry) {
std::unique_ptr<SchemaRegistry> registry(new SchemaRegistry);
- ForwardingSchemaRegistry forwarding(registry.get());
+ ForwardingSchemaRegistry forwarding(registry.get(),
+ false /* forward_readiness */);
MockSchemaRegistryObserver observer;
forwarding.AddObserver(&observer);
@@ -281,7 +282,8 @@ TEST(SchemaRegistryTest, ForwardingSchemaRegistry) {
registry->SetReady(POLICY_DOMAIN_CHROME);
EXPECT_TRUE(registry->IsReady());
- // The ForwardingSchemaRegistry becomes ready independently of the wrapped
+ // The ForwardingSchemaRegistry, if constructed with forward_readiness
+ // parameter equal to false, becomes ready independently of the wrapped
// registry.
EXPECT_FALSE(forwarding.IsReady());
@@ -308,4 +310,36 @@ TEST(SchemaRegistryTest, ForwardingSchemaRegistry) {
forwarding.RemoveObserver(&observer);
}
+TEST(SchemaRegistryTest, ReadinessForwardingSchemaRegistry) {
+ // Test ForwardingSchemaRegistry when constructed with forward_readiness equal
+ // to true.
+
+ std::unique_ptr<SchemaRegistry> registry(new SchemaRegistry);
+
+ ForwardingSchemaRegistry forwarding_1(registry.get(),
+ true /* forward_readiness */);
+ EXPECT_FALSE(registry->IsReady());
+ EXPECT_FALSE(forwarding_1.IsReady());
+
+ // Once the wrapped registry gets ready, the forwarding schema registry
+ // becomes ready too.
+ registry->SetReady(POLICY_DOMAIN_CHROME);
+ registry->SetReady(POLICY_DOMAIN_EXTENSIONS);
+ registry->SetReady(POLICY_DOMAIN_SIGNIN_EXTENSIONS);
+ 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(),
+ true /* forward_readiness */);
+ EXPECT_TRUE(forwarding_2.IsReady());
+
+ // Destruction of the wrapped registry doesn't change the readiness of
+ // forwarding registry.
+ registry.reset();
+ EXPECT_TRUE(forwarding_1.IsReady());
+ EXPECT_TRUE(forwarding_2.IsReady());
+}
+
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698