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

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

Issue 337053005: Precache policy-for-extensions for device-local accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed ios tests Created 6 years, 6 months 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 "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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 combined.RemoveObserver(&observer); 245 combined.RemoveObserver(&observer);
246 } 246 }
247 247
248 TEST(SchemaRegistryTest, ForwardingSchemaRegistry) { 248 TEST(SchemaRegistryTest, ForwardingSchemaRegistry) {
249 scoped_ptr<SchemaRegistry> registry(new SchemaRegistry); 249 scoped_ptr<SchemaRegistry> registry(new SchemaRegistry);
250 ForwardingSchemaRegistry forwarding(registry.get()); 250 ForwardingSchemaRegistry forwarding(registry.get());
251 MockSchemaRegistryObserver observer; 251 MockSchemaRegistryObserver observer;
252 forwarding.AddObserver(&observer); 252 forwarding.AddObserver(&observer);
253 253
254 EXPECT_FALSE(registry->IsReady()); 254 EXPECT_FALSE(registry->IsReady());
255 // The ForwardingSchemaRegistry is always ready, even if the wrapped registry 255 EXPECT_FALSE(forwarding.IsReady());
256 // isn't. 256 // They always have the same SchemaMap.
257 EXPECT_TRUE(forwarding.IsReady());
258 // But they alreday have the same SchemaMap.
259 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); 257 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map()));
260 258
261 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true)); 259 EXPECT_CALL(observer, OnSchemaRegistryUpdated(true));
262 registry->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"), 260 registry->RegisterComponent(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"),
263 Schema()); 261 Schema());
264 Mock::VerifyAndClearExpectations(&observer); 262 Mock::VerifyAndClearExpectations(&observer);
265 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); 263 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map()));
266 264
267 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false)); 265 EXPECT_CALL(observer, OnSchemaRegistryUpdated(false));
268 registry->UnregisterComponent( 266 registry->UnregisterComponent(
269 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc")); 267 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "abc"));
270 Mock::VerifyAndClearExpectations(&observer); 268 Mock::VerifyAndClearExpectations(&observer);
271 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); 269 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map()));
272 270
273 // No notifications expected for this call. 271 // No notifications expected for these calls.
274 EXPECT_FALSE(registry->IsReady()); 272 EXPECT_FALSE(registry->IsReady());
273 EXPECT_FALSE(forwarding.IsReady());
274
275 #if defined(ENABLE_EXTENSIONS)
276 registry->SetReady(POLICY_DOMAIN_EXTENSIONS);
277 EXPECT_FALSE(registry->IsReady());
278 EXPECT_FALSE(forwarding.IsReady());
279 #endif
280
275 registry->SetReady(POLICY_DOMAIN_CHROME); 281 registry->SetReady(POLICY_DOMAIN_CHROME);
276 registry->SetReady(POLICY_DOMAIN_EXTENSIONS);
277 EXPECT_TRUE(registry->IsReady()); 282 EXPECT_TRUE(registry->IsReady());
283 // The ForwardingSchemaRegistry becomes ready independently of the wrapped
284 // registry.
285 EXPECT_FALSE(forwarding.IsReady());
286
278 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map())); 287 EXPECT_TRUE(SchemaMapEquals(registry->schema_map(), forwarding.schema_map()));
279 Mock::VerifyAndClearExpectations(&observer); 288 Mock::VerifyAndClearExpectations(&observer);
280 289
290 forwarding.SetReady(POLICY_DOMAIN_EXTENSIONS);
bartfab (slow) 2014/06/23 09:53:38 Why is this conditional for |registry| above but u
Joao da Silva 2014/07/16 11:47:52 Good catch, it's actually not needed above. POLIC
291 EXPECT_FALSE(forwarding.IsReady());
292 Mock::VerifyAndClearExpectations(&observer);
293
294 EXPECT_CALL(observer, OnSchemaRegistryReady());
295 forwarding.SetReady(POLICY_DOMAIN_CHROME);
296 EXPECT_TRUE(forwarding.IsReady());
297 Mock::VerifyAndClearExpectations(&observer);
298
281 // Keep the same SchemaMap when the original registry is gone. 299 // Keep the same SchemaMap when the original registry is gone.
282 // No notifications are expected in this case either. 300 // No notifications are expected in this case either.
283 scoped_refptr<SchemaMap> schema_map = registry->schema_map(); 301 scoped_refptr<SchemaMap> schema_map = registry->schema_map();
284 registry.reset(); 302 registry.reset();
285 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map())); 303 EXPECT_TRUE(SchemaMapEquals(schema_map, forwarding.schema_map()));
286 Mock::VerifyAndClearExpectations(&observer); 304 Mock::VerifyAndClearExpectations(&observer);
287 305
288 forwarding.RemoveObserver(&observer); 306 forwarding.RemoveObserver(&observer);
289 } 307 }
290 308
291 } // namespace policy 309 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698