OLD | NEW |
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 "chrome/browser/policy/cloud_policy_controller.h" | 5 #include "chrome/browser/policy/cloud_policy_controller.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
9 #include "chrome/browser/policy/device_management_service.h" | 9 #include "chrome/browser/policy/device_management_service.h" |
10 #include "chrome/browser/policy/device_token_fetcher.h" | 10 #include "chrome/browser/policy/device_token_fetcher.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 cache_.reset(new UserPolicyCache( | 87 cache_.reset(new UserPolicyCache( |
88 temp_user_data_dir_.path().AppendASCII("CloudPolicyControllerTest"))); | 88 temp_user_data_dir_.path().AppendASCII("CloudPolicyControllerTest"))); |
89 token_fetcher_.reset(new MockDeviceTokenFetcher(cache_.get())); | 89 token_fetcher_.reset(new MockDeviceTokenFetcher(cache_.get())); |
90 service_.set_backend(&backend_); | 90 service_.set_backend(&backend_); |
91 } | 91 } |
92 | 92 |
93 virtual void TearDown() { | 93 virtual void TearDown() { |
94 controller_.reset(); // Unregisters observers. | 94 controller_.reset(); // Unregisters observers. |
95 } | 95 } |
96 | 96 |
97 // Takes ownership of |backend|. | |
98 void CreateNewController() { | 97 void CreateNewController() { |
99 controller_.reset(new CloudPolicyController( | 98 controller_.reset(new CloudPolicyController( |
100 &service_, cache_.get(), token_fetcher_.get(), &identity_strategy_, | 99 &service_, cache_.get(), token_fetcher_.get(), &identity_strategy_, |
101 ¬ifier_, new DummyWorkScheduler)); | 100 ¬ifier_, new DummyWorkScheduler)); |
102 } | 101 } |
103 | 102 |
104 void ExpectHasSpdyPolicy() { | 103 void ExpectHasSpdyPolicy() { |
105 MockConfigurationPolicyStore store; | |
106 EXPECT_CALL(store, Apply(_, _)).Times(AtLeast(1)); | |
107 cache_->GetManagedPolicyProvider()->Provide(&store); | |
108 FundamentalValue expected(true); | 104 FundamentalValue expected(true); |
109 ASSERT_TRUE(store.Get(kPolicyDisableSpdy) != NULL); | 105 const PolicyMap* policy_map = cache_->policy( |
110 EXPECT_TRUE(store.Get(kPolicyDisableSpdy)->Equals(&expected)); | 106 CloudPolicyCacheBase::POLICY_LEVEL_MANDATORY); |
| 107 ASSERT_TRUE(Value::Equals(&expected, policy_map->Get(kPolicyDisableSpdy))); |
111 } | 108 } |
112 | 109 |
113 void SetupIdentityStrategy( | 110 void SetupIdentityStrategy( |
114 const std::string& device_token, | 111 const std::string& device_token, |
115 const std::string& device_id, | 112 const std::string& device_id, |
116 const std::string& machine_id, | 113 const std::string& machine_id, |
117 const std::string& machine_model, | 114 const std::string& machine_model, |
118 const std::string& policy_type, | 115 const std::string& policy_type, |
119 const em::DeviceRegisterRequest_Type& policy_register_type, | 116 const em::DeviceRegisterRequest_Type& policy_register_type, |
120 const std::string& user_name, | 117 const std::string& user_name, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 "who@what.com", "auth"); | 274 "who@what.com", "auth"); |
278 EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( | 275 EXPECT_CALL(backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( |
279 MockDeviceManagementBackendFailPolicy( | 276 MockDeviceManagementBackendFailPolicy( |
280 DeviceManagementBackend::kErrorServiceManagementNotSupported)); | 277 DeviceManagementBackend::kErrorServiceManagementNotSupported)); |
281 EXPECT_CALL(*token_fetcher_.get(), SetUnmanagedState()).Times(1); | 278 EXPECT_CALL(*token_fetcher_.get(), SetUnmanagedState()).Times(1); |
282 CreateNewController(); | 279 CreateNewController(); |
283 loop_.RunAllPending(); | 280 loop_.RunAllPending(); |
284 } | 281 } |
285 | 282 |
286 } // namespace policy | 283 } // namespace policy |
OLD | NEW |