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

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

Issue 10496013: Implement the mac policy provider based on the AsyncPolicyLoader. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Renamed to PolicyLoaderMac Created 8 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
OLDNEW
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 "chrome/browser/policy/configuration_policy_provider_test.h" 5 #include "chrome/browser/policy/configuration_policy_provider_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/policy/configuration_policy_provider.h" 10 #include "chrome/browser/policy/configuration_policy_provider.h"
11 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 11 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
12 #include "chrome/browser/policy/policy_bundle.h" 12 #include "chrome/browser/policy/policy_bundle.h"
13 #include "chrome/browser/policy/policy_map.h" 13 #include "chrome/browser/policy/policy_map.h"
14 #include "policy/policy_constants.h" 14 #include "policy/policy_constants.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 16
17 using content::BrowserThread;
17 using ::testing::Mock; 18 using ::testing::Mock;
18 using ::testing::_; 19 using ::testing::_;
19 20
20 namespace policy { 21 namespace policy {
21 22
22 namespace test_policy_definitions { 23 namespace test_policy_definitions {
23 24
24 const char kKeyString[] = "StringPolicy"; 25 const char kKeyString[] = "StringPolicy";
25 const char kKeyBoolean[] = "BooleanPolicy"; 26 const char kKeyBoolean[] = "BooleanPolicy";
26 const char kKeyInteger[] = "IntegerPolicy"; 27 const char kKeyInteger[] = "IntegerPolicy";
27 const char kKeyStringList[] = "StringListPolicy"; 28 const char kKeyStringList[] = "StringListPolicy";
28 const char kKeyDictionary[] = "DictionaryPolicy"; 29 const char kKeyDictionary[] = "DictionaryPolicy";
29 30
30 static const PolicyDefinitionList::Entry kEntries[] = { 31 static const PolicyDefinitionList::Entry kEntries[] = {
31 { kKeyString, base::Value::TYPE_STRING }, 32 { kKeyString, base::Value::TYPE_STRING },
32 { kKeyBoolean, base::Value::TYPE_BOOLEAN }, 33 { kKeyBoolean, base::Value::TYPE_BOOLEAN },
33 { kKeyInteger, base::Value::TYPE_INTEGER }, 34 { kKeyInteger, base::Value::TYPE_INTEGER },
34 { kKeyStringList, base::Value::TYPE_LIST }, 35 { kKeyStringList, base::Value::TYPE_LIST },
35 { kKeyDictionary, base::Value::TYPE_DICTIONARY }, 36 { kKeyDictionary, base::Value::TYPE_DICTIONARY },
36 }; 37 };
37 38
38 const PolicyDefinitionList kList = { 39 const PolicyDefinitionList kList = {
39 kEntries, kEntries + arraysize(kEntries) 40 kEntries, kEntries + arraysize(kEntries)
40 }; 41 };
41 42
42 } // namespace test_policy_definitions 43 } // namespace test_policy_definitions
43 44
45 PolicyTestBase::PolicyTestBase()
46 : ui_thread_(BrowserThread::UI, &loop_),
47 file_thread_(BrowserThread::FILE, &loop_) {}
48
49 PolicyTestBase::~PolicyTestBase() {}
50
51 void PolicyTestBase::TearDown() {
52 loop_.RunAllPending();
53 }
54
44 PolicyProviderTestHarness::PolicyProviderTestHarness(PolicyLevel level, 55 PolicyProviderTestHarness::PolicyProviderTestHarness(PolicyLevel level,
45 PolicyScope scope) 56 PolicyScope scope)
46 : level_(level), scope_(scope) {} 57 : level_(level), scope_(scope) {}
47 58
48 PolicyProviderTestHarness::~PolicyProviderTestHarness() {} 59 PolicyProviderTestHarness::~PolicyProviderTestHarness() {}
49 60
50 PolicyLevel PolicyProviderTestHarness::policy_level() const { 61 PolicyLevel PolicyProviderTestHarness::policy_level() const {
51 return level_; 62 return level_;
52 } 63 }
53 64
54 PolicyScope PolicyProviderTestHarness::policy_scope() const { 65 PolicyScope PolicyProviderTestHarness::policy_scope() const {
55 return scope_; 66 return scope_;
56 } 67 }
57 68
58 ConfigurationPolicyProviderTest::ConfigurationPolicyProviderTest() {} 69 ConfigurationPolicyProviderTest::ConfigurationPolicyProviderTest() {}
59 70
60 ConfigurationPolicyProviderTest::~ConfigurationPolicyProviderTest() {} 71 ConfigurationPolicyProviderTest::~ConfigurationPolicyProviderTest() {}
61 72
62 void ConfigurationPolicyProviderTest::SetUp() { 73 void ConfigurationPolicyProviderTest::SetUp() {
63 AsynchronousPolicyTestBase::SetUp(); 74 PolicyTestBase::SetUp();
64 75
65 test_harness_.reset((*GetParam())()); 76 test_harness_.reset((*GetParam())());
66 test_harness_->SetUp(); 77 test_harness_->SetUp();
67 78
68 provider_.reset( 79 provider_.reset(
69 test_harness_->CreateProvider(&test_policy_definitions::kList)); 80 test_harness_->CreateProvider(&test_policy_definitions::kList));
70 // Some providers do a reload on init. Make sure any notifications generated 81 // Some providers do a reload on init. Make sure any notifications generated
71 // are fired now. 82 // are fired now.
72 loop_.RunAllPending(); 83 loop_.RunAllPending();
73 84
74 const PolicyBundle kEmptyBundle; 85 const PolicyBundle kEmptyBundle;
75 EXPECT_TRUE(provider_->policies().Equals(kEmptyBundle)); 86 EXPECT_TRUE(provider_->policies().Equals(kEmptyBundle));
76 } 87 }
77 88
78 void ConfigurationPolicyProviderTest::TearDown() { 89 void ConfigurationPolicyProviderTest::TearDown() {
79 // Give providers the chance to clean up after themselves on the file thread. 90 // Give providers the chance to clean up after themselves on the file thread.
80 provider_.reset(); 91 provider_.reset();
81 92
82 AsynchronousPolicyTestBase::TearDown(); 93 PolicyTestBase::TearDown();
83 } 94 }
84 95
85 void ConfigurationPolicyProviderTest::CheckValue( 96 void ConfigurationPolicyProviderTest::CheckValue(
86 const char* policy_name, 97 const char* policy_name,
87 const base::Value& expected_value, 98 const base::Value& expected_value,
88 base::Closure install_value) { 99 base::Closure install_value) {
89 // Install the value, reload policy and check the provider for the value. 100 // Install the value, reload policy and check the provider for the value.
90 install_value.Run(); 101 install_value.Run();
91 provider_->RefreshPolicies(); 102 provider_->RefreshPolicies();
92 loop_.RunAllPending(); 103 loop_.RunAllPending();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 PolicyBundle expected_bundle; 250 PolicyBundle expected_bundle;
240 base::DictionaryValue* expected_value = new base::DictionaryValue(); 251 base::DictionaryValue* expected_value = new base::DictionaryValue();
241 expected_value->SetInteger(key::kProxyServerMode, 3); 252 expected_value->SetInteger(key::kProxyServerMode, 3);
242 expected_bundle.Get(POLICY_DOMAIN_CHROME, "") 253 expected_bundle.Get(POLICY_DOMAIN_CHROME, "")
243 .Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 254 .Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
244 expected_value); 255 expected_value);
245 EXPECT_TRUE(provider.policies().Equals(expected_bundle)); 256 EXPECT_TRUE(provider.policies().Equals(expected_bundle));
246 } 257 }
247 258
248 } // namespace policy 259 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_provider_test.h ('k') | chrome/browser/policy/policy_loader_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698