| OLD | NEW |
| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 received_callback_ = true; | 224 received_callback_ = true; |
| 225 error_ = error; | 225 error_ = error; |
| 226 token_ = token; | 226 token_ = token; |
| 227 run_loop_.Quit(); | 227 run_loop_.Quit(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 TEST_F(ManagedUserRegistrationUtilityTest, Register) { | 230 TEST_F(ManagedUserRegistrationUtilityTest, Register) { |
| 231 StartInitialSync(); | 231 StartInitialSync(); |
| 232 GetRegistrationUtility()->Register( | 232 GetRegistrationUtility()->Register( |
| 233 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 233 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), |
| 234 ManagedUserRegistrationInfo(ASCIIToUTF16("Dug")), | 234 ManagedUserRegistrationInfo(ASCIIToUTF16("Dug"), 0), |
| 235 GetRegistrationCallback()); | 235 GetRegistrationCallback()); |
| 236 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 236 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 237 Acknowledge(); | 237 Acknowledge(); |
| 238 | 238 |
| 239 EXPECT_TRUE(received_callback()); | 239 EXPECT_TRUE(received_callback()); |
| 240 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); | 240 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); |
| 241 EXPECT_FALSE(token().empty()); | 241 EXPECT_FALSE(token().empty()); |
| 242 } | 242 } |
| 243 | 243 |
| 244 TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) { | 244 TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) { |
| 245 GetRegistrationUtility()->Register( | 245 GetRegistrationUtility()->Register( |
| 246 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 246 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), |
| 247 ManagedUserRegistrationInfo(ASCIIToUTF16("Nemo")), | 247 ManagedUserRegistrationInfo(ASCIIToUTF16("Nemo"), 5), |
| 248 GetRegistrationCallback()); | 248 GetRegistrationCallback()); |
| 249 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 249 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 250 StartInitialSync(); | 250 StartInitialSync(); |
| 251 Acknowledge(); | 251 Acknowledge(); |
| 252 | 252 |
| 253 EXPECT_TRUE(received_callback()); | 253 EXPECT_TRUE(received_callback()); |
| 254 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); | 254 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); |
| 255 EXPECT_FALSE(token().empty()); | 255 EXPECT_FALSE(token().empty()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) { | 258 TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) { |
| 259 StartInitialSync(); | 259 StartInitialSync(); |
| 260 GetRegistrationUtility()->Register( | 260 GetRegistrationUtility()->Register( |
| 261 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 261 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), |
| 262 ManagedUserRegistrationInfo(ASCIIToUTF16("Remy")), | 262 ManagedUserRegistrationInfo(ASCIIToUTF16("Remy"), 12), |
| 263 GetRegistrationCallback()); | 263 GetRegistrationCallback()); |
| 264 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 264 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 265 service()->Shutdown(); | 265 service()->Shutdown(); |
| 266 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 266 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 267 EXPECT_TRUE(received_callback()); | 267 EXPECT_TRUE(received_callback()); |
| 268 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); | 268 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); |
| 269 EXPECT_EQ(std::string(), token()); | 269 EXPECT_EQ(std::string(), token()); |
| 270 } | 270 } |
| 271 | 271 |
| 272 TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) { | 272 TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) { |
| 273 StartInitialSync(); | 273 StartInitialSync(); |
| 274 GetRegistrationUtility()->Register( | 274 GetRegistrationUtility()->Register( |
| 275 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 275 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), |
| 276 ManagedUserRegistrationInfo(ASCIIToUTF16("Mike")), | 276 ManagedUserRegistrationInfo(ASCIIToUTF16("Mike"), 17), |
| 277 GetRegistrationCallback()); | 277 GetRegistrationCallback()); |
| 278 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 278 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 279 service()->StopSyncing(MANAGED_USERS); | 279 service()->StopSyncing(MANAGED_USERS); |
| 280 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 280 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 281 EXPECT_TRUE(received_callback()); | 281 EXPECT_TRUE(received_callback()); |
| 282 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); | 282 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); |
| 283 EXPECT_EQ(std::string(), token()); | 283 EXPECT_EQ(std::string(), token()); |
| 284 } | 284 } |
| OLD | NEW |