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

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: fixed ios 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
« no previous file with comments | « chrome/browser/policy/schema_registry_service.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 MockSchemaRegistryObserver observer;
107 registry.AddObserver(&observer);
108
109 EXPECT_FALSE(registry.IsReady());
110 #if defined(ENABLE_EXTENSIONS)
111 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0);
112 registry.SetReady(POLICY_DOMAIN_EXTENSIONS);
113 Mock::VerifyAndClearExpectations(&observer);
114 EXPECT_FALSE(registry.IsReady());
115 #endif
116 EXPECT_CALL(observer, OnSchemaRegistryReady());
117 registry.SetReady(POLICY_DOMAIN_CHROME);
118 Mock::VerifyAndClearExpectations(&observer);
119 EXPECT_TRUE(registry.IsReady());
120 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0);
121 registry.SetReady(POLICY_DOMAIN_CHROME);
122 Mock::VerifyAndClearExpectations(&observer);
123 EXPECT_TRUE(registry.IsReady());
124
125 CombinedSchemaRegistry combined;
126 EXPECT_TRUE(combined.IsReady());
127
128 registry.RemoveObserver(&observer);
129 }
130
103 TEST(SchemaRegistryTest, Combined) { 131 TEST(SchemaRegistryTest, Combined) {
104 std::string error; 132 std::string error;
105 Schema schema = Schema::Parse(kTestSchema, &error); 133 Schema schema = Schema::Parse(kTestSchema, &error);
106 ASSERT_TRUE(schema.valid()) << error; 134 ASSERT_TRUE(schema.valid()) << error;
107 135
108 MockSchemaRegistryObserver observer; 136 MockSchemaRegistryObserver observer;
109 SchemaRegistry registry1; 137 SchemaRegistry registry1;
110 SchemaRegistry registry2; 138 SchemaRegistry registry2;
111 CombinedSchemaRegistry combined; 139 CombinedSchemaRegistry combined;
112 combined.AddObserver(&observer); 140 combined.AddObserver(&observer);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 Mock::VerifyAndClearExpectations(&observer); 233 Mock::VerifyAndClearExpectations(&observer);
206 234
207 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false)); 235 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
208 combined.Untrack(&registry2); 236 combined.Untrack(&registry2);
209 Mock::VerifyAndClearExpectations(&observer); 237 Mock::VerifyAndClearExpectations(&observer);
210 238
211 combined.RemoveObserver(&observer); 239 combined.RemoveObserver(&observer);
212 } 240 }
213 241
214 } // namespace policy 242 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/schema_registry_service.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698