| 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "components/policy/core/common/policy_namespace.h" | 8 #include "components/policy/core/common/policy_namespace.h" |
| 9 #include "components/policy/core/common/schema.h" | 9 #include "components/policy/core/common/schema.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 TEST(SchemaRegistryTest, Notifications) { | 62 TEST(SchemaRegistryTest, Notifications) { |
| 63 std::string error; | 63 std::string error; |
| 64 Schema schema = Schema::Parse(kTestSchema, &error); | 64 Schema schema = Schema::Parse(kTestSchema, &error); |
| 65 ASSERT_TRUE(schema.valid()) << error; | 65 ASSERT_TRUE(schema.valid()) << error; |
| 66 | 66 |
| 67 MockSchemaRegistryObserver observer; | 67 MockSchemaRegistryObserver observer; |
| 68 SchemaRegistry registry; | 68 SchemaRegistry registry; |
| 69 registry.AddObserver(&observer); | 69 registry.AddObserver(&observer); |
| 70 | 70 |
| 71 ASSERT_TRUE(registry.schema_map()); | 71 ASSERT_TRUE(registry.schema_map().get()); |
| 72 EXPECT_FALSE(registry.schema_map()->GetSchema( | 72 EXPECT_FALSE(registry.schema_map()->GetSchema( |
| 73 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"))); | 73 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"))); |
| 74 | 74 |
| 75 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true)); | 75 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true)); |
| 76 registry.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"), | 76 registry.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"), |
| 77 schema); | 77 schema); |
| 78 Mock::VerifyAndClearExpectations(&observer); | 78 Mock::VerifyAndClearExpectations(&observer); |
| 79 | 79 |
| 80 // Re-register also triggers notifications, because the Schema might have | 80 // Re-register also triggers notifications, because the Schema might have |
| 81 // changed. | 81 // changed. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // No notifications are expected in this case either. | 298 // No notifications are expected in this case either. |
| 299 scoped_refptr<SchemaMap> schema_map = registry->schema_map(); | 299 scoped_refptr<SchemaMap> schema_map = registry->schema_map(); |
| 300 registry.reset(); | 300 registry.reset(); |
| 301 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map())); | 301 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map())); |
| 302 Mock::VerifyAndClearExpectations(&observer); | 302 Mock::VerifyAndClearExpectations(&observer); |
| 303 | 303 |
| 304 forwarding.RemoveObserver(&observer); | 304 forwarding.RemoveObserver(&observer); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace policy | 307 } // namespace policy |
| OLD | NEW |