OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <cstdlib> | 6 #include <cstdlib> |
7 #include <map> | 7 #include <map> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 for (Schema::Iterator it = chrome_schema.GetPropertiesIterator(); | 483 for (Schema::Iterator it = chrome_schema.GetPropertiesIterator(); |
484 !it.IsAtEnd(); it.Advance()) { | 484 !it.IsAtEnd(); it.Advance()) { |
485 EXPECT_TRUE(ContainsKey(policy_test_cases.map(), it.key())) | 485 EXPECT_TRUE(ContainsKey(policy_test_cases.map(), it.key())) |
486 << "Missing policy test case for: " << it.key(); | 486 << "Missing policy test case for: " << it.key(); |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 // Base class for tests that change policy. | 490 // Base class for tests that change policy. |
491 class PolicyPrefsTest : public InProcessBrowserTest { | 491 class PolicyPrefsTest : public InProcessBrowserTest { |
492 protected: | 492 protected: |
493 virtual void SetUpInProcessBrowserTestFixture() override { | 493 void SetUpInProcessBrowserTestFixture() override { |
494 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 494 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
495 .WillRepeatedly(Return(true)); | 495 .WillRepeatedly(Return(true)); |
496 BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 496 BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
497 } | 497 } |
498 | 498 |
499 virtual void SetUpOnMainThread() override { | 499 void SetUpOnMainThread() override { |
500 ui_test_utils::WaitForTemplateURLServiceToLoad( | 500 ui_test_utils::WaitForTemplateURLServiceToLoad( |
501 TemplateURLServiceFactory::GetForProfile(browser()->profile())); | 501 TemplateURLServiceFactory::GetForProfile(browser()->profile())); |
502 } | 502 } |
503 | 503 |
504 virtual void TearDownOnMainThread() override { | 504 void TearDownOnMainThread() override { ClearProviderPolicy(); } |
505 ClearProviderPolicy(); | |
506 } | |
507 | 505 |
508 void ClearProviderPolicy() { | 506 void ClearProviderPolicy() { |
509 provider_.UpdateChromePolicy(PolicyMap()); | 507 provider_.UpdateChromePolicy(PolicyMap()); |
510 base::RunLoop().RunUntilIdle(); | 508 base::RunLoop().RunUntilIdle(); |
511 } | 509 } |
512 | 510 |
513 void SetProviderPolicy(const base::DictionaryValue& policies, | 511 void SetProviderPolicy(const base::DictionaryValue& policies, |
514 PolicyLevel level) { | 512 PolicyLevel level) { |
515 PolicyMap policy_map; | 513 PolicyMap policy_map; |
516 for (base::DictionaryValue::Iterator it(policies); | 514 for (base::DictionaryValue::Iterator it(policies); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 742 } |
745 } | 743 } |
746 } | 744 } |
747 } | 745 } |
748 | 746 |
749 INSTANTIATE_TEST_CASE_P(PolicyPrefIndicatorTestInstance, | 747 INSTANTIATE_TEST_CASE_P(PolicyPrefIndicatorTestInstance, |
750 PolicyPrefIndicatorTest, | 748 PolicyPrefIndicatorTest, |
751 testing::ValuesIn(SplitPoliciesIntoChunks(10))); | 749 testing::ValuesIn(SplitPoliciesIntoChunks(10))); |
752 | 750 |
753 } // namespace policy | 751 } // namespace policy |
OLD | NEW |