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

Side by Side Diff: chrome/browser/policy/schema_registry_unittest.cc

Issue 60823003: Introduced a ForwardingPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fixes Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/policy/schema_registry.h" 5 #include "chrome/browser/policy/schema_registry.h"
6 6
7 #include "components/policy/core/common/policy_namespace.h" 7 #include "components/policy/core/common/policy_namespace.h"
8 #include "components/policy/core/common/schema.h" 8 #include "components/policy/core/common/schema.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 27 matching lines...) Expand all
38 " }" 38 " }"
39 " }" 39 " }"
40 "}"; 40 "}";
41 41
42 class MockSchemaRegistryObserver : public SchemaRegistry::Observer { 42 class MockSchemaRegistryObserver : public SchemaRegistry::Observer {
43 public: 43 public:
44 MockSchemaRegistryObserver() {} 44 MockSchemaRegistryObserver() {}
45 virtual ~MockSchemaRegistryObserver() {} 45 virtual ~MockSchemaRegistryObserver() {}
46 46
47 MOCK_METHOD1(OnSchemaRegistryUpdated, void(bool)); 47 MOCK_METHOD1(OnSchemaRegistryUpdated, void(bool));
48 MOCK_METHOD0(OnSchemaRegistryReady, void());
48 }; 49 };
49 50
50 } // namespace 51 } // namespace
51 52
52 TEST(SchemaRegistryTest, Notifications) { 53 TEST(SchemaRegistryTest, Notifications) {
53 std::string error; 54 std::string error;
54 Schema schema = Schema::Parse(kTestSchema, &error); 55 Schema schema = Schema::Parse(kTestSchema, &error);
55 ASSERT_TRUE(schema.valid()) << error; 56 ASSERT_TRUE(schema.valid()) << error;
56 57
57 MockSchemaRegistryObserver observer; 58 MockSchemaRegistryObserver observer;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 components["def"] = schema; 94 components["def"] = schema;
94 components["xyz"] = schema; 95 components["xyz"] = schema;
95 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true)); 96 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true));
96 registry.RegisterComponents(POLICY_DOMAIN_EXTENSIONS, components); 97 registry.RegisterComponents(POLICY_DOMAIN_EXTENSIONS, components);
97 Mock::VerifyAndClearExpectations(&observer); 98 Mock::VerifyAndClearExpectations(&observer);
98 99
99 registry.RemoveObserver(&observer); 100 registry.RemoveObserver(&observer);
100 EXPECT_FALSE(registry.HasObservers()); 101 EXPECT_FALSE(registry.HasObservers());
101 } 102 }
102 103
104 TEST(SchemaRegistryTest, IsReady) {
105 SchemaRegistry registry;
106 EXPECT_FALSE(registry.IsReady());
107 registry.SetReady(POLICY_DOMAIN_CHROME);
108 #if defined(ENABLE_EXTENSIONS)
109 EXPECT_FALSE(registry.IsReady());
110 registry.SetReady(POLICY_DOMAIN_EXTENSIONS);
111 EXPECT_TRUE(registry.IsReady());
112 registry.SetReady(POLICY_DOMAIN_EXTENSIONS);
bartfab (slow) 2013/11/11 14:40:08 Nit 1: It would be useful to have an observer in t
Joao da Silva 2013/11/12 15:26:33 Done.
113 #endif
114 EXPECT_TRUE(registry.IsReady());
115
116 CombinedSchemaRegistry combined;
117 EXPECT_TRUE(combined.IsReady());
118 }
119
103 TEST(SchemaRegistryTest, Combined) { 120 TEST(SchemaRegistryTest, Combined) {
104 std::string error; 121 std::string error;
105 Schema schema = Schema::Parse(kTestSchema, &error); 122 Schema schema = Schema::Parse(kTestSchema, &error);
106 ASSERT_TRUE(schema.valid()) << error; 123 ASSERT_TRUE(schema.valid()) << error;
107 124
108 MockSchemaRegistryObserver observer; 125 MockSchemaRegistryObserver observer;
109 SchemaRegistry registry1; 126 SchemaRegistry registry1;
110 SchemaRegistry registry2; 127 SchemaRegistry registry2;
111 CombinedSchemaRegistry combined; 128 CombinedSchemaRegistry combined;
112 combined.AddObserver(&observer); 129 combined.AddObserver(&observer);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 Mock::VerifyAndClearExpectations(&observer); 222 Mock::VerifyAndClearExpectations(&observer);
206 223
207 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false)); 224 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
208 combined.Untrack(&registry2); 225 combined.Untrack(&registry2);
209 Mock::VerifyAndClearExpectations(&observer); 226 Mock::VerifyAndClearExpectations(&observer);
210 227
211 combined.RemoveObserver(&observer); 228 combined.RemoveObserver(&observer);
212 } 229 }
213 230
214 } // namespace policy 231 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698