OLD | NEW |
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/signin/signin_tracker.h" | 5 #include "chrome/browser/signin/signin_tracker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 Return(false)); | 356 Return(false)); |
357 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); | 357 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); |
358 // Any error should result in SigninFailed() being called. | 358 // Any error should result in SigninFailed() being called. |
359 EXPECT_CALL(observer_, SigninFailed(error)); | 359 EXPECT_CALL(observer_, SigninFailed(error)); |
360 tracker_.reset(new SigninTracker(profile_.get(), &observer_, | 360 tracker_.reset(new SigninTracker(profile_.get(), &observer_, |
361 SigninTracker::SERVICES_INITIALIZING)); | 361 SigninTracker::SERVICES_INITIALIZING)); |
362 } | 362 } |
363 | 363 |
364 TEST_F(SigninTrackerTest, SigninFailedWhenInitializing) { | 364 TEST_F(SigninTrackerTest, SigninFailedWhenInitializing) { |
365 tracker_.reset(); | 365 tracker_.reset(); |
366 // SigninFailed() should be called. | 366 // SigninFailed() should be called because we are not signed in. |
367 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); | 367 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); |
368 EXPECT_CALL(observer_, SigninFailed(error)); | 368 EXPECT_CALL(observer_, SigninFailed(error)); |
369 tracker_.reset(new SigninTracker(profile_.get(), &observer_, | 369 tracker_.reset(new SigninTracker(profile_.get(), &observer_, |
370 SigninTracker::SERVICES_INITIALIZING)); | 370 SigninTracker::SERVICES_INITIALIZING)); |
371 tracker_->OnStateChanged(); | 371 tracker_->OnStateChanged(); |
372 } | 372 } |
| 373 |
| 374 TEST_F(SigninTrackerTest, ConnectionErrorWhenInitializing) { |
| 375 // SigninFailed() should not be called for a CONNECTION_FAILED error. |
| 376 GoogleServiceAuthError error(GoogleServiceAuthError::CONNECTION_FAILED); |
| 377 ExpectSignedInSyncService(mock_pss_, mock_token_service_, error); |
| 378 mock_signin_manager_->SetAuthenticatedUsername("username@gmail.com"); |
| 379 EXPECT_CALL(observer_, SigninFailed(_)).Times(0); |
| 380 tracker_.reset(new SigninTracker(profile_.get(), &observer_, |
| 381 SigninTracker::SERVICES_INITIALIZING)); |
| 382 tracker_->OnStateChanged(); |
| 383 } |
OLD | NEW |