| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/policy/core/common/schema_registry.h" | 5 #include "components/policy/core/common/schema_registry.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "components/policy/core/common/policy_namespace.h" | 9 #include "components/policy/core/common/policy_namespace.h" |
| 10 #include "components/policy/core/common/schema.h" | 10 #include "components/policy/core/common/schema.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 TEST(SchemaRegistryTest, IsReady) { | 111 TEST(SchemaRegistryTest, IsReady) { |
| 112 SchemaRegistry registry; | 112 SchemaRegistry registry; |
| 113 MockSchemaRegistryObserver observer; | 113 MockSchemaRegistryObserver observer; |
| 114 registry.AddObserver(&observer); | 114 registry.AddObserver(&observer); |
| 115 | 115 |
| 116 EXPECT_FALSE(registry.IsReady()); | 116 EXPECT_FALSE(registry.IsReady()); |
| 117 #if defined(ENABLE_EXTENSIONS) | 117 #if defined(ENABLE_EXTENSIONS) |
| 118 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0); | 118 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0); |
| 119 registry.SetReady(POLICY_DOMAIN_EXTENSIONS); | 119 registry.SetExtensionsDomainsReady(); |
| 120 Mock::VerifyAndClearExpectations(&observer); | 120 Mock::VerifyAndClearExpectations(&observer); |
| 121 EXPECT_FALSE(registry.IsReady()); | 121 EXPECT_FALSE(registry.IsReady()); |
| 122 #endif | 122 #endif |
| 123 EXPECT_CALL(observer, OnSchemaRegistryReady()); | 123 EXPECT_CALL(observer, OnSchemaRegistryReady()); |
| 124 registry.SetReady(POLICY_DOMAIN_CHROME); | 124 registry.SetReady(POLICY_DOMAIN_CHROME); |
| 125 Mock::VerifyAndClearExpectations(&observer); | 125 Mock::VerifyAndClearExpectations(&observer); |
| 126 EXPECT_TRUE(registry.IsReady()); | 126 EXPECT_TRUE(registry.IsReady()); |
| 127 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0); | 127 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0); |
| 128 registry.SetReady(POLICY_DOMAIN_CHROME); | 128 registry.SetReady(POLICY_DOMAIN_CHROME); |
| 129 Mock::VerifyAndClearExpectations(&observer); | 129 Mock::VerifyAndClearExpectations(&observer); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false)); | 266 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false)); |
| 267 registry->UnregisterComponent( | 267 registry->UnregisterComponent( |
| 268 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc")); | 268 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc")); |
| 269 Mock::VerifyAndClearExpectations(&observer); | 269 Mock::VerifyAndClearExpectations(&observer); |
| 270 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); | 270 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); |
| 271 | 271 |
| 272 // No notifications expected for these calls. | 272 // No notifications expected for these calls. |
| 273 EXPECT_FALSE(registry->IsReady()); | 273 EXPECT_FALSE(registry->IsReady()); |
| 274 EXPECT_FALSE(forwarding.IsReady()); | 274 EXPECT_FALSE(forwarding.IsReady()); |
| 275 | 275 |
| 276 registry->SetReady(POLICY_DOMAIN_EXTENSIONS); | 276 registry->SetExtensionsDomainsReady(); |
| 277 EXPECT_FALSE(registry->IsReady()); | 277 EXPECT_FALSE(registry->IsReady()); |
| 278 EXPECT_FALSE(forwarding.IsReady()); | 278 EXPECT_FALSE(forwarding.IsReady()); |
| 279 | 279 |
| 280 registry->SetReady(POLICY_DOMAIN_CHROME); | 280 registry->SetReady(POLICY_DOMAIN_CHROME); |
| 281 EXPECT_TRUE(registry->IsReady()); | 281 EXPECT_TRUE(registry->IsReady()); |
| 282 // The ForwardingSchemaRegistry becomes ready independently of the wrapped | 282 // The ForwardingSchemaRegistry becomes ready independently of the wrapped |
| 283 // registry. | 283 // registry. |
| 284 EXPECT_FALSE(forwarding.IsReady()); | 284 EXPECT_FALSE(forwarding.IsReady()); |
| 285 | 285 |
| 286 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); | 286 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); |
| 287 Mock::VerifyAndClearExpectations(&observer); | 287 Mock::VerifyAndClearExpectations(&observer); |
| 288 | 288 |
| 289 forwarding.SetReady(POLICY_DOMAIN_EXTENSIONS); | 289 forwarding.SetExtensionsDomainsReady(); |
| 290 EXPECT_FALSE(forwarding.IsReady()); | 290 EXPECT_FALSE(forwarding.IsReady()); |
| 291 Mock::VerifyAndClearExpectations(&observer); | 291 Mock::VerifyAndClearExpectations(&observer); |
| 292 | 292 |
| 293 EXPECT_CALL(observer, OnSchemaRegistryReady()); | 293 EXPECT_CALL(observer, OnSchemaRegistryReady()); |
| 294 forwarding.SetReady(POLICY_DOMAIN_CHROME); | 294 forwarding.SetReady(POLICY_DOMAIN_CHROME); |
| 295 EXPECT_TRUE(forwarding.IsReady()); | 295 EXPECT_TRUE(forwarding.IsReady()); |
| 296 Mock::VerifyAndClearExpectations(&observer); | 296 Mock::VerifyAndClearExpectations(&observer); |
| 297 | 297 |
| 298 // Keep the same SchemaMap when the original registry is gone. | 298 // Keep the same SchemaMap when the original registry is gone. |
| 299 // No notifications are expected in this case either. | 299 // No notifications are expected in this case either. |
| 300 scoped_refptr<SchemaMap> schema_map = registry->schema_map(); | 300 scoped_refptr<SchemaMap> schema_map = registry->schema_map(); |
| 301 registry.reset(); | 301 registry.reset(); |
| 302 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map())); | 302 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map())); |
| 303 Mock::VerifyAndClearExpectations(&observer); | 303 Mock::VerifyAndClearExpectations(&observer); |
| 304 | 304 |
| 305 forwarding.RemoveObserver(&observer); | 305 forwarding.RemoveObserver(&observer); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace policy | 308 } // namespace policy |
| OLD | NEW |