| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "chrome/browser/sync/profile_sync_service_factory.h" | 6 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 7 #include "chrome/browser/sync/profile_sync_service_mock.h" | 7 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 8 #include "chrome/browser/sync/sync_startup_tracker.h" | 8 #include "chrome/browser/sync/sync_startup_tracker.h" |
| 9 #include "content/public/test/test_browser_thread_bundle.h" | 9 #include "content/public/test/test_browser_thread_bundle.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 public: | 22 public: |
| 23 MOCK_METHOD0(SyncStartupCompleted, void(void)); | 23 MOCK_METHOD0(SyncStartupCompleted, void(void)); |
| 24 MOCK_METHOD0(SyncStartupFailed, void(void)); | 24 MOCK_METHOD0(SyncStartupFailed, void(void)); |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 class SyncStartupTrackerTest : public testing::Test { | 27 class SyncStartupTrackerTest : public testing::Test { |
| 28 public: | 28 public: |
| 29 SyncStartupTrackerTest() : | 29 SyncStartupTrackerTest() : |
| 30 no_error_(GoogleServiceAuthError::NONE) { | 30 no_error_(GoogleServiceAuthError::NONE) { |
| 31 } | 31 } |
| 32 virtual void SetUp() OVERRIDE { | 32 virtual void SetUp() override { |
| 33 profile_.reset(new TestingProfile()); | 33 profile_.reset(new TestingProfile()); |
| 34 mock_pss_ = static_cast<ProfileSyncServiceMock*>( | 34 mock_pss_ = static_cast<ProfileSyncServiceMock*>( |
| 35 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 35 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 36 profile_.get(), | 36 profile_.get(), |
| 37 ProfileSyncServiceMock::BuildMockProfileSyncService)); | 37 ProfileSyncServiceMock::BuildMockProfileSyncService)); |
| 38 | 38 |
| 39 // Make gmock not spam the output with information about these uninteresting | 39 // Make gmock not spam the output with information about these uninteresting |
| 40 // calls. | 40 // calls. |
| 41 EXPECT_CALL(*mock_pss_, AddObserver(_)).Times(AnyNumber()); | 41 EXPECT_CALL(*mock_pss_, AddObserver(_)).Times(AnyNumber()); |
| 42 EXPECT_CALL(*mock_pss_, RemoveObserver(_)).Times(AnyNumber()); | 42 EXPECT_CALL(*mock_pss_, RemoveObserver(_)).Times(AnyNumber()); |
| 43 EXPECT_CALL(*mock_pss_, GetAuthError()). | 43 EXPECT_CALL(*mock_pss_, GetAuthError()). |
| 44 WillRepeatedly(ReturnRef(no_error_)); | 44 WillRepeatedly(ReturnRef(no_error_)); |
| 45 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) | 45 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) |
| 46 .WillByDefault(Return(syncer::ModelTypeSet())); | 46 .WillByDefault(Return(syncer::ModelTypeSet())); |
| 47 mock_pss_->Initialize(); | 47 mock_pss_->Initialize(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual void TearDown() OVERRIDE { | 50 virtual void TearDown() override { |
| 51 profile_.reset(); | 51 profile_.reset(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SetupNonInitializedPSS() { | 54 void SetupNonInitializedPSS() { |
| 55 EXPECT_CALL(*mock_pss_, GetAuthError()) | 55 EXPECT_CALL(*mock_pss_, GetAuthError()) |
| 56 .WillRepeatedly(ReturnRef(no_error_)); | 56 .WillRepeatedly(ReturnRef(no_error_)); |
| 57 EXPECT_CALL(*mock_pss_, SyncActive()).WillRepeatedly(Return(false)); | 57 EXPECT_CALL(*mock_pss_, SyncActive()).WillRepeatedly(Return(false)); |
| 58 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 58 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
| 59 .WillRepeatedly(Return(false)); | 59 .WillRepeatedly(Return(false)); |
| 60 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 60 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()).WillRepeatedly( | 146 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()).WillRepeatedly( |
| 147 Return(true)); | 147 Return(true)); |
| 148 GoogleServiceAuthError error( | 148 GoogleServiceAuthError error( |
| 149 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 149 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 150 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); | 150 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); |
| 151 EXPECT_CALL(observer_, SyncStartupFailed()); | 151 EXPECT_CALL(observer_, SyncStartupFailed()); |
| 152 tracker.OnStateChanged(); | 152 tracker.OnStateChanged(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace | 155 } // namespace |
| OLD | NEW |