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

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

Issue 10661027: Remove TODOs from the code in accordance with the decision to not change the default enrollment typ… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/device_token_fetcher.h" 5 #include "chrome/browser/policy/device_token_fetcher.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/cloud_policy_data_store.h" 9 #include "chrome/browser/policy/cloud_policy_data_store.h"
10 #include "chrome/browser/policy/logging_work_scheduler.h" 10 #include "chrome/browser/policy/logging_work_scheduler.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 &notifier_); 144 &notifier_);
145 EXPECT_EQ("", data_store->device_token()); 145 EXPECT_EQ("", data_store->device_token());
146 EXPECT_EQ(DEVICE_MODE_PENDING, data_store->device_mode()); 146 EXPECT_EQ(DEVICE_MODE_PENDING, data_store->device_mode());
147 FetchToken(&fetcher, data_store.get()); 147 FetchToken(&fetcher, data_store.get());
148 loop_.RunAllPending(); 148 loop_.RunAllPending();
149 EXPECT_NE("", data_store->device_token()); 149 EXPECT_NE("", data_store->device_token());
150 // For device registrations, the fetcher needs to determine device mode. 150 // For device registrations, the fetcher needs to determine device mode.
151 EXPECT_EQ(DEVICE_MODE_ENTERPRISE, data_store->device_mode()); 151 EXPECT_EQ(DEVICE_MODE_ENTERPRISE, data_store->device_mode());
152 } 152 }
153 153
154 // TODO(pastarmovj): This test must be changed in accordance with
155 // http://crosbug.com/26624.
156 TEST_F(DeviceTokenFetcherTest, FetchDeviceTokenMissingMode) { 154 TEST_F(DeviceTokenFetcherTest, FetchDeviceTokenMissingMode) {
157 testing::InSequence s; 155 testing::InSequence s;
158 scoped_ptr<CloudPolicyDataStore> data_store( 156 scoped_ptr<CloudPolicyDataStore> data_store(
159 CloudPolicyDataStore::CreateForDevicePolicies()); 157 CloudPolicyDataStore::CreateForDevicePolicies());
160 SetUpSuccessfulRegistrationExpectation(false); 158 SetUpSuccessfulRegistrationExpectation(false);
161 DeviceTokenFetcher fetcher(&service_, cache_.get(), data_store.get(), 159 DeviceTokenFetcher fetcher(&service_, cache_.get(), data_store.get(),
162 &notifier_); 160 &notifier_);
163 EXPECT_EQ("", data_store->device_token()); 161 EXPECT_EQ("", data_store->device_token());
164 EXPECT_EQ(DEVICE_MODE_PENDING, data_store->device_mode()); 162 EXPECT_EQ(DEVICE_MODE_PENDING, data_store->device_mode());
165 successful_registration_response_.mutable_register_response()-> 163 successful_registration_response_.mutable_register_response()->
166 clear_enrollment_type(); 164 clear_enrollment_type();
167 FetchToken(&fetcher, data_store.get()); 165 FetchToken(&fetcher, data_store.get());
168 loop_.RunAllPending(); 166 loop_.RunAllPending();
169 Mock::VerifyAndClearExpectations(&observer_); 167 Mock::VerifyAndClearExpectations(&observer_);
170 EXPECT_NE("", data_store->device_token()); 168 EXPECT_NE("", data_store->device_token());
171 // TODO(pastarmovj): Modify when http://crosbug.com/26624 is resolved.
172 EXPECT_EQ(DEVICE_MODE_ENTERPRISE, data_store->device_mode()); 169 EXPECT_EQ(DEVICE_MODE_ENTERPRISE, data_store->device_mode());
173 } 170 }
174 171
175 TEST_F(DeviceTokenFetcherTest, RetryOnError) { 172 TEST_F(DeviceTokenFetcherTest, RetryOnError) {
176 testing::InSequence s; 173 testing::InSequence s;
177 EXPECT_CALL(service_, 174 EXPECT_CALL(service_,
178 CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION)) 175 CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION))
179 .WillOnce(service_.FailJob(DM_STATUS_REQUEST_FAILED)) 176 .WillOnce(service_.FailJob(DM_STATUS_REQUEST_FAILED))
180 .WillOnce(service_.SucceedJob(successful_registration_response_)); 177 .WillOnce(service_.SucceedJob(successful_registration_response_));
181 DeviceTokenFetcher fetcher(&service_, cache_.get(), data_store_.get(), 178 DeviceTokenFetcher fetcher(&service_, cache_.get(), data_store_.get(),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 data_store_->set_known_machine_id(true); 254 data_store_->set_known_machine_id(true);
258 FetchToken(&fetcher, data_store_.get()); 255 FetchToken(&fetcher, data_store_.get());
259 loop_.RunAllPending(); 256 loop_.RunAllPending();
260 257
261 Mock::VerifyAndClearExpectations(&observer_); 258 Mock::VerifyAndClearExpectations(&observer_);
262 std::string token = data_store_->device_token(); 259 std::string token = data_store_->device_token();
263 EXPECT_NE("", token); 260 EXPECT_NE("", token);
264 } 261 }
265 262
266 } // namespace policy 263 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698