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

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

Issue 7096013: Allow device policy code to be optionally included. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make changes requested by torne. Created 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "chrome/browser/policy/configuration_policy_pref_store.h" 7 #include "chrome/browser/policy/configuration_policy_pref_store.h"
8 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 8 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
9 #include "chrome/browser/prefs/proxy_config_dictionary.h" 9 #include "chrome/browser/prefs/proxy_config_dictionary.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 20 matching lines...) Expand all
31 private: 31 private:
32 ConfigurationPolicyType type_; 32 ConfigurationPolicyType type_;
33 const char* pref_name_; 33 const char* pref_name_;
34 }; 34 };
35 35
36 template<typename TESTBASE> 36 template<typename TESTBASE>
37 class ConfigurationPolicyPrefStoreTestBase : public TESTBASE { 37 class ConfigurationPolicyPrefStoreTestBase : public TESTBASE {
38 protected: 38 protected:
39 ConfigurationPolicyPrefStoreTestBase() 39 ConfigurationPolicyPrefStoreTestBase()
40 : provider_(), 40 : provider_(),
41 store_(new ConfigurationPolicyPrefStore(&provider_)) {} 41 store_(ConfigurationPolicyPrefStore::Create(&provider_)) {}
42 42
43 MockConfigurationPolicyProvider provider_; 43 MockConfigurationPolicyProvider provider_;
44 scoped_refptr<ConfigurationPolicyPrefStore> store_; 44 scoped_refptr<ConfigurationPolicyPrefStore> store_;
45 }; 45 };
46 46
47 // Test cases for list-valued policy settings. 47 // Test cases for list-valued policy settings.
48 class ConfigurationPolicyPrefStoreListTest 48 class ConfigurationPolicyPrefStoreListTest
49 : public ConfigurationPolicyPrefStoreTestBase< 49 : public ConfigurationPolicyPrefStoreTestBase<
50 testing::TestWithParam<TypeAndName> > { 50 testing::TestWithParam<TypeAndName> > {
51 }; 51 };
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 MockConfigurationPolicyProvider provider; 319 MockConfigurationPolicyProvider provider;
320 provider.AddPolicy(kPolicyProxyBypassList, 320 provider.AddPolicy(kPolicyProxyBypassList,
321 Value::CreateStringValue("http://chromium.org/override")); 321 Value::CreateStringValue("http://chromium.org/override"));
322 provider.AddPolicy(kPolicyProxyServer, 322 provider.AddPolicy(kPolicyProxyServer,
323 Value::CreateStringValue("chromium.org")); 323 Value::CreateStringValue("chromium.org"));
324 provider.AddPolicy(kPolicyProxyServerMode, 324 provider.AddPolicy(kPolicyProxyServerMode,
325 Value::CreateIntegerValue( 325 Value::CreateIntegerValue(
326 kPolicyManuallyConfiguredProxyServerMode)); 326 kPolicyManuallyConfiguredProxyServerMode));
327 327
328 scoped_refptr<ConfigurationPolicyPrefStore> store( 328 scoped_refptr<ConfigurationPolicyPrefStore> store(
329 new ConfigurationPolicyPrefStore(&provider)); 329 ConfigurationPolicyPrefStore::Create(&provider));
330 VerifyProxyPrefs( 330 VerifyProxyPrefs(
331 *store, "chromium.org", "", "http://chromium.org/override", 331 *store, "chromium.org", "", "http://chromium.org/override",
332 ProxyPrefs::MODE_FIXED_SERVERS); 332 ProxyPrefs::MODE_FIXED_SERVERS);
333 } 333 }
334 334
335 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsReversedApplyOrder) { 335 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsReversedApplyOrder) {
336 MockConfigurationPolicyProvider provider; 336 MockConfigurationPolicyProvider provider;
337 provider.AddPolicy(kPolicyProxyServerMode, 337 provider.AddPolicy(kPolicyProxyServerMode,
338 Value::CreateIntegerValue( 338 Value::CreateIntegerValue(
339 kPolicyManuallyConfiguredProxyServerMode)); 339 kPolicyManuallyConfiguredProxyServerMode));
340 provider.AddPolicy(kPolicyProxyBypassList, 340 provider.AddPolicy(kPolicyProxyBypassList,
341 Value::CreateStringValue("http://chromium.org/override")); 341 Value::CreateStringValue("http://chromium.org/override"));
342 provider.AddPolicy(kPolicyProxyServer, 342 provider.AddPolicy(kPolicyProxyServer,
343 Value::CreateStringValue("chromium.org")); 343 Value::CreateStringValue("chromium.org"));
344 scoped_refptr<ConfigurationPolicyPrefStore> store( 344 scoped_refptr<ConfigurationPolicyPrefStore> store(
345 new ConfigurationPolicyPrefStore(&provider)); 345 ConfigurationPolicyPrefStore::Create(&provider));
346 VerifyProxyPrefs( 346 VerifyProxyPrefs(
347 *store, "chromium.org", "", "http://chromium.org/override", 347 *store, "chromium.org", "", "http://chromium.org/override",
348 ProxyPrefs::MODE_FIXED_SERVERS); 348 ProxyPrefs::MODE_FIXED_SERVERS);
349 } 349 }
350 350
351 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsInvalid) { 351 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ManualOptionsInvalid) {
352 MockConfigurationPolicyProvider provider; 352 MockConfigurationPolicyProvider provider;
353 provider.AddPolicy(kPolicyProxyServerMode, 353 provider.AddPolicy(kPolicyProxyServerMode,
354 Value::CreateIntegerValue( 354 Value::CreateIntegerValue(
355 kPolicyManuallyConfiguredProxyServerMode)); 355 kPolicyManuallyConfiguredProxyServerMode));
356 356
357 scoped_refptr<ConfigurationPolicyPrefStore> store( 357 scoped_refptr<ConfigurationPolicyPrefStore> store(
358 new ConfigurationPolicyPrefStore(&provider)); 358 ConfigurationPolicyPrefStore::Create(&provider));
359 const Value* value = NULL; 359 const Value* value = NULL;
360 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value)); 360 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value));
361 } 361 }
362 362
363 363
364 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyServerMode) { 364 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyServerMode) {
365 MockConfigurationPolicyProvider provider; 365 MockConfigurationPolicyProvider provider;
366 provider.AddPolicy(kPolicyProxyServerMode, 366 provider.AddPolicy(kPolicyProxyServerMode,
367 Value::CreateIntegerValue(kPolicyNoProxyServerMode)); 367 Value::CreateIntegerValue(kPolicyNoProxyServerMode));
368 368
369 scoped_refptr<ConfigurationPolicyPrefStore> store( 369 scoped_refptr<ConfigurationPolicyPrefStore> store(
370 new ConfigurationPolicyPrefStore(&provider)); 370 ConfigurationPolicyPrefStore::Create(&provider));
371 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT); 371 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT);
372 } 372 }
373 373
374 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyModeName) { 374 TEST_F(ConfigurationPolicyPrefStoreProxyTest, NoProxyModeName) {
375 MockConfigurationPolicyProvider provider; 375 MockConfigurationPolicyProvider provider;
376 provider.AddPolicy( 376 provider.AddPolicy(
377 kPolicyProxyMode, 377 kPolicyProxyMode,
378 Value::CreateStringValue(ProxyPrefs::kDirectProxyModeName)); 378 Value::CreateStringValue(ProxyPrefs::kDirectProxyModeName));
379 379
380 scoped_refptr<ConfigurationPolicyPrefStore> store( 380 scoped_refptr<ConfigurationPolicyPrefStore> store(
381 new ConfigurationPolicyPrefStore(&provider)); 381 ConfigurationPolicyPrefStore::Create(&provider));
382 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT); 382 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_DIRECT);
383 } 383 }
384 384
385 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyServerMode) { 385 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyServerMode) {
386 MockConfigurationPolicyProvider provider; 386 MockConfigurationPolicyProvider provider;
387 provider.AddPolicy( 387 provider.AddPolicy(
388 kPolicyProxyServerMode, 388 kPolicyProxyServerMode,
389 Value::CreateIntegerValue(kPolicyAutoDetectProxyServerMode)); 389 Value::CreateIntegerValue(kPolicyAutoDetectProxyServerMode));
390 390
391 scoped_refptr<ConfigurationPolicyPrefStore> store( 391 scoped_refptr<ConfigurationPolicyPrefStore> store(
392 new ConfigurationPolicyPrefStore(&provider)); 392 ConfigurationPolicyPrefStore::Create(&provider));
393 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); 393 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT);
394 } 394 }
395 395
396 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyModeName) { 396 TEST_F(ConfigurationPolicyPrefStoreProxyTest, AutoDetectProxyModeName) {
397 MockConfigurationPolicyProvider provider; 397 MockConfigurationPolicyProvider provider;
398 provider.AddPolicy( 398 provider.AddPolicy(
399 kPolicyProxyMode, 399 kPolicyProxyMode,
400 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName)); 400 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName));
401 401
402 scoped_refptr<ConfigurationPolicyPrefStore> store( 402 scoped_refptr<ConfigurationPolicyPrefStore> store(
403 new ConfigurationPolicyPrefStore(&provider)); 403 ConfigurationPolicyPrefStore::Create(&provider));
404 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); 404 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT);
405 } 405 }
406 406
407 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyMode) { 407 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyMode) {
408 MockConfigurationPolicyProvider provider; 408 MockConfigurationPolicyProvider provider;
409 provider.AddPolicy(kPolicyProxyPacUrl, 409 provider.AddPolicy(kPolicyProxyPacUrl,
410 Value::CreateStringValue("http://short.org/proxy.pac")); 410 Value::CreateStringValue("http://short.org/proxy.pac"));
411 provider.AddPolicy( 411 provider.AddPolicy(
412 kPolicyProxyMode, 412 kPolicyProxyMode,
413 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); 413 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName));
414 414
415 scoped_refptr<ConfigurationPolicyPrefStore> store( 415 scoped_refptr<ConfigurationPolicyPrefStore> store(
416 new ConfigurationPolicyPrefStore(&provider)); 416 ConfigurationPolicyPrefStore::Create(&provider));
417 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "", 417 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "",
418 ProxyPrefs::MODE_PAC_SCRIPT); 418 ProxyPrefs::MODE_PAC_SCRIPT);
419 } 419 }
420 420
421 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeInvalid) { 421 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeInvalid) {
422 MockConfigurationPolicyProvider provider; 422 MockConfigurationPolicyProvider provider;
423 provider.AddPolicy( 423 provider.AddPolicy(
424 kPolicyProxyMode, 424 kPolicyProxyMode,
425 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); 425 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName));
426 426
427 scoped_refptr<ConfigurationPolicyPrefStore> store( 427 scoped_refptr<ConfigurationPolicyPrefStore> store(
428 new ConfigurationPolicyPrefStore(&provider)); 428 ConfigurationPolicyPrefStore::Create(&provider));
429 const Value* value = NULL; 429 const Value* value = NULL;
430 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value)); 430 EXPECT_EQ(PrefStore::READ_NO_VALUE, store->GetValue(prefs::kProxy, &value));
431 } 431 }
432 432
433 // Regression test for http://crbug.com/78016, CPanel returns empty strings 433 // Regression test for http://crbug.com/78016, CPanel returns empty strings
434 // for unset properties. 434 // for unset properties.
435 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeBug78016) { 435 TEST_F(ConfigurationPolicyPrefStoreProxyTest, PacScriptProxyModeBug78016) {
436 MockConfigurationPolicyProvider provider; 436 MockConfigurationPolicyProvider provider;
437 provider.AddPolicy(kPolicyProxyServer, 437 provider.AddPolicy(kPolicyProxyServer,
438 Value::CreateStringValue("")); 438 Value::CreateStringValue(""));
439 provider.AddPolicy(kPolicyProxyPacUrl, 439 provider.AddPolicy(kPolicyProxyPacUrl,
440 Value::CreateStringValue("http://short.org/proxy.pac")); 440 Value::CreateStringValue("http://short.org/proxy.pac"));
441 provider.AddPolicy( 441 provider.AddPolicy(
442 kPolicyProxyMode, 442 kPolicyProxyMode,
443 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName)); 443 Value::CreateStringValue(ProxyPrefs::kPacScriptProxyModeName));
444 444
445 scoped_refptr<ConfigurationPolicyPrefStore> store( 445 scoped_refptr<ConfigurationPolicyPrefStore> store(
446 new ConfigurationPolicyPrefStore(&provider)); 446 ConfigurationPolicyPrefStore::Create(&provider));
447 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "", 447 VerifyProxyPrefs(*store, "", "http://short.org/proxy.pac", "",
448 ProxyPrefs::MODE_PAC_SCRIPT); 448 ProxyPrefs::MODE_PAC_SCRIPT);
449 } 449 }
450 450
451 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyServerMode) { 451 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyServerMode) {
452 MockConfigurationPolicyProvider provider; 452 MockConfigurationPolicyProvider provider;
453 provider.AddPolicy( 453 provider.AddPolicy(
454 kPolicyProxyServerMode, 454 kPolicyProxyServerMode,
455 Value::CreateIntegerValue(kPolicyUseSystemProxyServerMode)); 455 Value::CreateIntegerValue(kPolicyUseSystemProxyServerMode));
456 456
457 scoped_refptr<ConfigurationPolicyPrefStore> store( 457 scoped_refptr<ConfigurationPolicyPrefStore> store(
458 new ConfigurationPolicyPrefStore(&provider)); 458 ConfigurationPolicyPrefStore::Create(&provider));
459 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM); 459 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM);
460 } 460 }
461 461
462 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyMode) { 462 TEST_F(ConfigurationPolicyPrefStoreProxyTest, UseSystemProxyMode) {
463 MockConfigurationPolicyProvider provider; 463 MockConfigurationPolicyProvider provider;
464 provider.AddPolicy( 464 provider.AddPolicy(
465 kPolicyProxyMode, 465 kPolicyProxyMode,
466 Value::CreateStringValue(ProxyPrefs::kSystemProxyModeName)); 466 Value::CreateStringValue(ProxyPrefs::kSystemProxyModeName));
467 467
468 scoped_refptr<ConfigurationPolicyPrefStore> store( 468 scoped_refptr<ConfigurationPolicyPrefStore> store(
469 new ConfigurationPolicyPrefStore(&provider)); 469 ConfigurationPolicyPrefStore::Create(&provider));
470 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM); 470 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_SYSTEM);
471 } 471 }
472 472
473 TEST_F(ConfigurationPolicyPrefStoreProxyTest, 473 TEST_F(ConfigurationPolicyPrefStoreProxyTest,
474 ProxyModeOverridesProxyServerMode) { 474 ProxyModeOverridesProxyServerMode) {
475 MockConfigurationPolicyProvider provider; 475 MockConfigurationPolicyProvider provider;
476 provider.AddPolicy(kPolicyProxyServerMode, 476 provider.AddPolicy(kPolicyProxyServerMode,
477 Value::CreateIntegerValue(kPolicyNoProxyServerMode)); 477 Value::CreateIntegerValue(kPolicyNoProxyServerMode));
478 provider.AddPolicy( 478 provider.AddPolicy(
479 kPolicyProxyMode, 479 kPolicyProxyMode,
480 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName)); 480 Value::CreateStringValue(ProxyPrefs::kAutoDetectProxyModeName));
481 481
482 scoped_refptr<ConfigurationPolicyPrefStore> store( 482 scoped_refptr<ConfigurationPolicyPrefStore> store(
483 new ConfigurationPolicyPrefStore(&provider)); 483 ConfigurationPolicyPrefStore::Create(&provider));
484 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT); 484 VerifyProxyPrefs(*store, "", "", "", ProxyPrefs::MODE_AUTO_DETECT);
485 } 485 }
486 486
487 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ProxyInvalid) { 487 TEST_F(ConfigurationPolicyPrefStoreProxyTest, ProxyInvalid) {
488 for (int i = 0; i < MODE_COUNT; ++i) { 488 for (int i = 0; i < MODE_COUNT; ++i) {
489 MockConfigurationPolicyProvider provider; 489 MockConfigurationPolicyProvider provider;
490 provider.AddPolicy(kPolicyProxyServerMode, Value::CreateIntegerValue(i)); 490 provider.AddPolicy(kPolicyProxyServerMode, Value::CreateIntegerValue(i));
491 // No mode expects all three parameters being set. 491 // No mode expects all three parameters being set.
492 provider.AddPolicy(kPolicyProxyPacUrl, 492 provider.AddPolicy(kPolicyProxyPacUrl,
493 Value::CreateStringValue("http://short.org/proxy.pac")); 493 Value::CreateStringValue("http://short.org/proxy.pac"));
494 provider.AddPolicy(kPolicyProxyBypassList, 494 provider.AddPolicy(kPolicyProxyBypassList,
495 Value::CreateStringValue( 495 Value::CreateStringValue(
496 "http://chromium.org/override")); 496 "http://chromium.org/override"));
497 provider.AddPolicy(kPolicyProxyServer, 497 provider.AddPolicy(kPolicyProxyServer,
498 Value::CreateStringValue("chromium.org")); 498 Value::CreateStringValue("chromium.org"));
499 499
500 scoped_refptr<ConfigurationPolicyPrefStore> store( 500 scoped_refptr<ConfigurationPolicyPrefStore> store(
501 new ConfigurationPolicyPrefStore(&provider)); 501 ConfigurationPolicyPrefStore::Create(&provider));
502 const Value* value = NULL; 502 const Value* value = NULL;
503 EXPECT_EQ(PrefStore::READ_NO_VALUE, 503 EXPECT_EQ(PrefStore::READ_NO_VALUE,
504 store->GetValue(prefs::kProxy, &value)); 504 store->GetValue(prefs::kProxy, &value));
505 } 505 }
506 } 506 }
507 507
508 class ConfigurationPolicyPrefStoreDefaultSearchTest : public testing::Test { 508 class ConfigurationPolicyPrefStoreDefaultSearchTest : public testing::Test {
509 }; 509 };
510 510
511 // Checks that if the policy for default search is valid, i.e. there's a 511 // Checks that if the policy for default search is valid, i.e. there's a
512 // search URL, that all the elements have been given proper defaults. 512 // search URL, that all the elements have been given proper defaults.
513 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) { 513 TEST_F(ConfigurationPolicyPrefStoreDefaultSearchTest, MinimallyDefined) {
514 const char* const search_url = "http://test.com/search?t={searchTerms}"; 514 const char* const search_url = "http://test.com/search?t={searchTerms}";
515 MockConfigurationPolicyProvider provider; 515 MockConfigurationPolicyProvider provider;
516 provider.AddPolicy(kPolicyDefaultSearchProviderEnabled, 516 provider.AddPolicy(kPolicyDefaultSearchProviderEnabled,
517 Value::CreateBooleanValue(true)); 517 Value::CreateBooleanValue(true));
518 provider.AddPolicy(kPolicyDefaultSearchProviderSearchURL, 518 provider.AddPolicy(kPolicyDefaultSearchProviderSearchURL,
519 Value::CreateStringValue(search_url)); 519 Value::CreateStringValue(search_url));
520 520
521 scoped_refptr<ConfigurationPolicyPrefStore> store( 521 scoped_refptr<ConfigurationPolicyPrefStore> store(
522 new ConfigurationPolicyPrefStore(&provider)); 522 ConfigurationPolicyPrefStore::Create(&provider));
523 523
524 const Value* value = NULL; 524 const Value* value = NULL;
525 EXPECT_EQ(PrefStore::READ_OK, 525 EXPECT_EQ(PrefStore::READ_OK,
526 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value)); 526 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value));
527 EXPECT_TRUE(StringValue(search_url).Equals(value)); 527 EXPECT_TRUE(StringValue(search_url).Equals(value));
528 528
529 EXPECT_EQ(PrefStore::READ_OK, 529 EXPECT_EQ(PrefStore::READ_OK,
530 store->GetValue(prefs::kDefaultSearchProviderName, &value)); 530 store->GetValue(prefs::kDefaultSearchProviderName, &value));
531 EXPECT_TRUE(StringValue("test.com").Equals(value)); 531 EXPECT_TRUE(StringValue("test.com").Equals(value));
532 532
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 Value::CreateStringValue(name)); 571 Value::CreateStringValue(name));
572 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword, 572 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword,
573 Value::CreateStringValue(keyword)); 573 Value::CreateStringValue(keyword));
574 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL, 574 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL,
575 Value::CreateStringValue(suggest_url)); 575 Value::CreateStringValue(suggest_url));
576 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL, 576 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL,
577 Value::CreateStringValue(icon_url)); 577 Value::CreateStringValue(icon_url));
578 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings); 578 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings);
579 579
580 scoped_refptr<ConfigurationPolicyPrefStore> store( 580 scoped_refptr<ConfigurationPolicyPrefStore> store(
581 new ConfigurationPolicyPrefStore(&provider)); 581 ConfigurationPolicyPrefStore::Create(&provider));
582 582
583 const Value* value = NULL; 583 const Value* value = NULL;
584 EXPECT_EQ(PrefStore::READ_OK, 584 EXPECT_EQ(PrefStore::READ_OK,
585 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value)); 585 store->GetValue(prefs::kDefaultSearchProviderSearchURL, &value));
586 EXPECT_TRUE(StringValue(search_url).Equals(value)); 586 EXPECT_TRUE(StringValue(search_url).Equals(value));
587 587
588 EXPECT_EQ(PrefStore::READ_OK, 588 EXPECT_EQ(PrefStore::READ_OK,
589 store->GetValue(prefs::kDefaultSearchProviderName, &value)); 589 store->GetValue(prefs::kDefaultSearchProviderName, &value));
590 EXPECT_TRUE(StringValue(name).Equals(value)); 590 EXPECT_TRUE(StringValue(name).Equals(value));
591 591
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 Value::CreateStringValue(name)); 623 Value::CreateStringValue(name));
624 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword, 624 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword,
625 Value::CreateStringValue(keyword)); 625 Value::CreateStringValue(keyword));
626 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL, 626 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL,
627 Value::CreateStringValue(suggest_url)); 627 Value::CreateStringValue(suggest_url));
628 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL, 628 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL,
629 Value::CreateStringValue(icon_url)); 629 Value::CreateStringValue(icon_url));
630 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings); 630 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings);
631 631
632 scoped_refptr<ConfigurationPolicyPrefStore> store( 632 scoped_refptr<ConfigurationPolicyPrefStore> store(
633 new ConfigurationPolicyPrefStore(&provider)); 633 ConfigurationPolicyPrefStore::Create(&provider));
634 634
635 EXPECT_EQ(PrefStore::READ_NO_VALUE, 635 EXPECT_EQ(PrefStore::READ_NO_VALUE,
636 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL)); 636 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL));
637 EXPECT_EQ(PrefStore::READ_NO_VALUE, 637 EXPECT_EQ(PrefStore::READ_NO_VALUE,
638 store->GetValue(prefs::kDefaultSearchProviderName, NULL)); 638 store->GetValue(prefs::kDefaultSearchProviderName, NULL));
639 EXPECT_EQ(PrefStore::READ_NO_VALUE, 639 EXPECT_EQ(PrefStore::READ_NO_VALUE,
640 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL)); 640 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL));
641 EXPECT_EQ(PrefStore::READ_NO_VALUE, 641 EXPECT_EQ(PrefStore::READ_NO_VALUE,
642 store->GetValue(prefs::kDefaultSearchProviderSuggestURL, NULL)); 642 store->GetValue(prefs::kDefaultSearchProviderSuggestURL, NULL));
643 EXPECT_EQ(PrefStore::READ_NO_VALUE, 643 EXPECT_EQ(PrefStore::READ_NO_VALUE,
(...skipping 22 matching lines...) Expand all
666 Value::CreateStringValue(name)); 666 Value::CreateStringValue(name));
667 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword, 667 provider.AddPolicy(kPolicyDefaultSearchProviderKeyword,
668 Value::CreateStringValue(keyword)); 668 Value::CreateStringValue(keyword));
669 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL, 669 provider.AddPolicy(kPolicyDefaultSearchProviderSuggestURL,
670 Value::CreateStringValue(suggest_url)); 670 Value::CreateStringValue(suggest_url));
671 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL, 671 provider.AddPolicy(kPolicyDefaultSearchProviderIconURL,
672 Value::CreateStringValue(icon_url)); 672 Value::CreateStringValue(icon_url));
673 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings); 673 provider.AddPolicy(kPolicyDefaultSearchProviderEncodings, encodings);
674 674
675 scoped_refptr<ConfigurationPolicyPrefStore> store( 675 scoped_refptr<ConfigurationPolicyPrefStore> store(
676 new ConfigurationPolicyPrefStore(&provider)); 676 ConfigurationPolicyPrefStore::Create(&provider));
677 677
678 EXPECT_EQ(PrefStore::READ_NO_VALUE, 678 EXPECT_EQ(PrefStore::READ_NO_VALUE,
679 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL)); 679 store->GetValue(prefs::kDefaultSearchProviderSearchURL, NULL));
680 EXPECT_EQ(PrefStore::READ_NO_VALUE, 680 EXPECT_EQ(PrefStore::READ_NO_VALUE,
681 store->GetValue(prefs::kDefaultSearchProviderName, NULL)); 681 store->GetValue(prefs::kDefaultSearchProviderName, NULL));
682 EXPECT_EQ(PrefStore::READ_NO_VALUE, 682 EXPECT_EQ(PrefStore::READ_NO_VALUE,
683 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL)); 683 store->GetValue(prefs::kDefaultSearchProviderKeyword, NULL));
684 EXPECT_EQ(PrefStore::READ_NO_VALUE, 684 EXPECT_EQ(PrefStore::READ_NO_VALUE,
685 store->GetValue(prefs::kDefaultSearchProviderSuggestURL, NULL)); 685 store->GetValue(prefs::kDefaultSearchProviderSuggestURL, NULL));
686 EXPECT_EQ(PrefStore::READ_NO_VALUE, 686 EXPECT_EQ(PrefStore::READ_NO_VALUE,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 863
864 provider_.SetInitializationComplete(true); 864 provider_.SetInitializationComplete(true);
865 EXPECT_FALSE(store_->IsInitializationComplete()); 865 EXPECT_FALSE(store_->IsInitializationComplete());
866 866
867 store_->OnUpdatePolicy(); 867 store_->OnUpdatePolicy();
868 Mock::VerifyAndClearExpectations(&observer_); 868 Mock::VerifyAndClearExpectations(&observer_);
869 EXPECT_TRUE(store_->IsInitializationComplete()); 869 EXPECT_TRUE(store_->IsInitializationComplete());
870 } 870 }
871 871
872 } // namespace policy 872 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_pref_store.cc ('k') | chrome/browser/policy/policy_stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698