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

Side by Side Diff: components/policy/core/common/schema_registry_unittest.cc

Issue 2440473004: Add policy domain for signin screen apps (Closed)
Patch Set: Fix compilation Created 4 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
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 "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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.SetReady(POLICY_DOMAIN_EXTENSIONS);
120 registry.SetReady(POLICY_DOMAIN_SIGNIN_EXTENSIONS);
120 Mock::VerifyAndClearExpectations(&observer); 121 Mock::VerifyAndClearExpectations(&observer);
121 EXPECT_FALSE(registry.IsReady()); 122 EXPECT_FALSE(registry.IsReady());
122 #endif 123 #endif
123 EXPECT_CALL(observer, OnSchemaRegistryReady()); 124 EXPECT_CALL(observer, OnSchemaRegistryReady());
124 registry.SetReady(POLICY_DOMAIN_CHROME); 125 registry.SetReady(POLICY_DOMAIN_CHROME);
125 Mock::VerifyAndClearExpectations(&observer); 126 Mock::VerifyAndClearExpectations(&observer);
126 EXPECT_TRUE(registry.IsReady()); 127 EXPECT_TRUE(registry.IsReady());
127 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0); 128 EXPECT_CALL(observer, OnSchemaRegistryReady()).Times(0);
128 registry.SetReady(POLICY_DOMAIN_CHROME); 129 registry.SetReady(POLICY_DOMAIN_CHROME);
129 Mock::VerifyAndClearExpectations(&observer); 130 Mock::VerifyAndClearExpectations(&observer);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 registry->UnregisterComponent( 268 registry->UnregisterComponent(
268 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc")); 269 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"));
269 Mock::VerifyAndClearExpectations(&observer); 270 Mock::VerifyAndClearExpectations(&observer);
270 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); 271 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map()));
271 272
272 // No notifications expected for these calls. 273 // No notifications expected for these calls.
273 EXPECT_FALSE(registry->IsReady()); 274 EXPECT_FALSE(registry->IsReady());
274 EXPECT_FALSE(forwarding.IsReady()); 275 EXPECT_FALSE(forwarding.IsReady());
275 276
276 registry->SetReady(POLICY_DOMAIN_EXTENSIONS); 277 registry->SetReady(POLICY_DOMAIN_EXTENSIONS);
278 registry->SetReady(POLICY_DOMAIN_SIGNIN_EXTENSIONS);
277 EXPECT_FALSE(registry->IsReady()); 279 EXPECT_FALSE(registry->IsReady());
278 EXPECT_FALSE(forwarding.IsReady()); 280 EXPECT_FALSE(forwarding.IsReady());
279 281
280 registry->SetReady(POLICY_DOMAIN_CHROME); 282 registry->SetReady(POLICY_DOMAIN_CHROME);
281 EXPECT_TRUE(registry->IsReady()); 283 EXPECT_TRUE(registry->IsReady());
282 // The ForwardingSchemaRegistry becomes ready independently of the wrapped 284 // The ForwardingSchemaRegistry becomes ready independently of the wrapped
283 // registry. 285 // registry.
284 EXPECT_FALSE(forwarding.IsReady()); 286 EXPECT_FALSE(forwarding.IsReady());
285 287
286 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); 288 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map()));
287 Mock::VerifyAndClearExpectations(&observer); 289 Mock::VerifyAndClearExpectations(&observer);
288 290
289 forwarding.SetReady(POLICY_DOMAIN_EXTENSIONS); 291 forwarding.SetReady(POLICY_DOMAIN_EXTENSIONS);
292 forwarding.SetReady(POLICY_DOMAIN_SIGNIN_EXTENSIONS);
290 EXPECT_FALSE(forwarding.IsReady()); 293 EXPECT_FALSE(forwarding.IsReady());
291 Mock::VerifyAndClearExpectations(&observer); 294 Mock::VerifyAndClearExpectations(&observer);
292 295
293 EXPECT_CALL(observer, OnSchemaRegistryReady()); 296 EXPECT_CALL(observer, OnSchemaRegistryReady());
294 forwarding.SetReady(POLICY_DOMAIN_CHROME); 297 forwarding.SetReady(POLICY_DOMAIN_CHROME);
295 EXPECT_TRUE(forwarding.IsReady()); 298 EXPECT_TRUE(forwarding.IsReady());
296 Mock::VerifyAndClearExpectations(&observer); 299 Mock::VerifyAndClearExpectations(&observer);
297 300
298 // Keep the same SchemaMap when the original registry is gone. 301 // Keep the same SchemaMap when the original registry is gone.
299 // No notifications are expected in this case either. 302 // No notifications are expected in this case either.
300 scoped_refptr<SchemaMap> schema_map = registry->schema_map(); 303 scoped_refptr<SchemaMap> schema_map = registry->schema_map();
301 registry.reset(); 304 registry.reset();
302 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map())); 305 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map()));
303 Mock::VerifyAndClearExpectations(&observer); 306 Mock::VerifyAndClearExpectations(&observer);
304 307
305 forwarding.RemoveObserver(&observer); 308 forwarding.RemoveObserver(&observer);
306 } 309 }
307 310
308 } // namespace policy 311 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698