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

Side by Side Diff: chrome/browser/managed_mode/managed_user_registration_utility_unittest.cc

Issue 23653007: Avatar syncing for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: strings Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h" 10 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 received_callback_ = true; 219 received_callback_ = true;
220 error_ = error; 220 error_ = error;
221 token_ = token; 221 token_ = token;
222 run_loop_.Quit(); 222 run_loop_.Quit();
223 } 223 }
224 224
225 TEST_F(ManagedUserRegistrationUtilityTest, Register) { 225 TEST_F(ManagedUserRegistrationUtilityTest, Register) {
226 StartInitialSync(); 226 StartInitialSync();
227 GetRegistrationUtility()->Register( 227 GetRegistrationUtility()->Register(
228 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), 228 ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
229 ManagedUserRegistrationInfo(ASCIIToUTF16("Dug")), 229 ManagedUserRegistrationInfo(ASCIIToUTF16("Dug"), 4),
230 GetRegistrationCallback()); 230 GetRegistrationCallback());
231 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); 231 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
232 Acknowledge(); 232 Acknowledge();
233 233
234 EXPECT_TRUE(received_callback()); 234 EXPECT_TRUE(received_callback());
235 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); 235 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state());
236 EXPECT_FALSE(token().empty()); 236 EXPECT_FALSE(token().empty());
237 } 237 }
238 238
239 TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) { 239 TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) {
240 GetRegistrationUtility()->Register( 240 GetRegistrationUtility()->Register(
241 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), 241 ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
242 ManagedUserRegistrationInfo(ASCIIToUTF16("Nemo")), 242 ManagedUserRegistrationInfo(ASCIIToUTF16("Nemo"), 0),
243 GetRegistrationCallback()); 243 GetRegistrationCallback());
244 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); 244 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
245 StartInitialSync(); 245 StartInitialSync();
246 Acknowledge(); 246 Acknowledge();
247 247
248 EXPECT_TRUE(received_callback()); 248 EXPECT_TRUE(received_callback());
249 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); 249 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state());
250 EXPECT_FALSE(token().empty()); 250 EXPECT_FALSE(token().empty());
251 } 251 }
252 252
253 TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) { 253 TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) {
254 StartInitialSync(); 254 StartInitialSync();
255 GetRegistrationUtility()->Register( 255 GetRegistrationUtility()->Register(
256 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), 256 ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
257 ManagedUserRegistrationInfo(ASCIIToUTF16("Remy")), 257 ManagedUserRegistrationInfo(ASCIIToUTF16("Remy"), 5),
258 GetRegistrationCallback()); 258 GetRegistrationCallback());
259 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); 259 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
260 service()->Shutdown(); 260 service()->Shutdown();
261 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); 261 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
262 EXPECT_TRUE(received_callback()); 262 EXPECT_TRUE(received_callback());
263 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); 263 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state());
264 EXPECT_EQ(std::string(), token()); 264 EXPECT_EQ(std::string(), token());
265 } 265 }
266 266
267 TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) { 267 TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) {
268 StartInitialSync(); 268 StartInitialSync();
269 GetRegistrationUtility()->Register( 269 GetRegistrationUtility()->Register(
270 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), 270 ManagedUserRegistrationUtility::GenerateNewManagedUserId(),
271 ManagedUserRegistrationInfo(ASCIIToUTF16("Mike")), 271 ManagedUserRegistrationInfo(ASCIIToUTF16("Mike"), 25),
272 GetRegistrationCallback()); 272 GetRegistrationCallback());
273 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); 273 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
274 service()->StopSyncing(MANAGED_USERS); 274 service()->StopSyncing(MANAGED_USERS);
275 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); 275 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size());
276 EXPECT_TRUE(received_callback()); 276 EXPECT_TRUE(received_callback());
277 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); 277 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state());
278 EXPECT_EQ(std::string(), token()); 278 EXPECT_EQ(std::string(), token());
279 } 279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698