| 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/sync/sync_global_error.h" | 5 #include "chrome/browser/sync/sync_global_error.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 std::unique_ptr<TestingProfile> profile_; | 75 std::unique_ptr<TestingProfile> profile_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest); | 77 DISALLOW_COPY_AND_ASSIGN(SyncGlobalErrorTest); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 // Utility function to test that SyncGlobalError behaves correctly for the given | 80 // Utility function to test that SyncGlobalError behaves correctly for the given |
| 81 // error condition. | 81 // error condition. |
| 82 void VerifySyncGlobalErrorResult(browser_sync::ProfileSyncServiceMock* service, | 82 void VerifySyncGlobalErrorResult(browser_sync::ProfileSyncServiceMock* service, |
| 83 FakeLoginUIService* login_ui_service, | 83 FakeLoginUIService* login_ui_service, |
| 84 Browser* browser, | 84 Browser* browser, |
| 85 syncer::SyncErrorController* error, | 85 SyncErrorController* error, |
| 86 SyncGlobalError* global_error, | 86 SyncGlobalError* global_error, |
| 87 GoogleServiceAuthError::State error_state, | 87 GoogleServiceAuthError::State error_state, |
| 88 bool is_signed_in, | 88 bool is_signed_in, |
| 89 bool is_error) { | 89 bool is_error) { |
| 90 EXPECT_CALL(*service, IsFirstSetupComplete()) | 90 EXPECT_CALL(*service, IsFirstSetupComplete()) |
| 91 .WillRepeatedly(Return(is_signed_in)); | 91 .WillRepeatedly(Return(is_signed_in)); |
| 92 | 92 |
| 93 GoogleServiceAuthError auth_error(error_state); | 93 GoogleServiceAuthError auth_error(error_state); |
| 94 EXPECT_CALL(*service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error)); | 94 EXPECT_CALL(*service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error)); |
| 95 | 95 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { | 127 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { |
| 128 browser_sync::ProfileSyncServiceMock service( | 128 browser_sync::ProfileSyncServiceMock service( |
| 129 CreateProfileSyncServiceParamsForTest(profile())); | 129 CreateProfileSyncServiceParamsForTest(profile())); |
| 130 | 130 |
| 131 FakeLoginUIService* login_ui_service = static_cast<FakeLoginUIService*>( | 131 FakeLoginUIService* login_ui_service = static_cast<FakeLoginUIService*>( |
| 132 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 132 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 133 profile(), BuildMockLoginUIService)); | 133 profile(), BuildMockLoginUIService)); |
| 134 FakeLoginUI login_ui; | 134 FakeLoginUI login_ui; |
| 135 login_ui_service->SetLoginUI(&login_ui); | 135 login_ui_service->SetLoginUI(&login_ui); |
| 136 | 136 |
| 137 syncer::SyncErrorController error(&service); | 137 SyncErrorController error(&service); |
| 138 SyncGlobalError global_error( | 138 SyncGlobalError global_error( |
| 139 GlobalErrorServiceFactory::GetForProfile(profile()), login_ui_service, | 139 GlobalErrorServiceFactory::GetForProfile(profile()), login_ui_service, |
| 140 &error, &service); | 140 &error, &service); |
| 141 | 141 |
| 142 syncer::SyncBackendHost::Status status; | 142 browser_sync::SyncBackendHost::Status status; |
| 143 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) | 143 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) |
| 144 .WillRepeatedly(Return(false)); | 144 .WillRepeatedly(Return(false)); |
| 145 | 145 |
| 146 EXPECT_CALL(service, IsPassphraseRequired()) | 146 EXPECT_CALL(service, IsPassphraseRequired()) |
| 147 .WillRepeatedly(Return(true)); | 147 .WillRepeatedly(Return(true)); |
| 148 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) | 148 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) |
| 149 .WillRepeatedly(Return(true)); | 149 .WillRepeatedly(Return(true)); |
| 150 VerifySyncGlobalErrorResult( | 150 VerifySyncGlobalErrorResult( |
| 151 &service, login_ui_service, browser(), &error, &global_error, | 151 &service, login_ui_service, browser(), &error, &global_error, |
| 152 GoogleServiceAuthError::NONE, true /* signed in*/, true /* error */); | 152 GoogleServiceAuthError::NONE, true /* signed in*/, true /* error */); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 165 .WillRepeatedly(Return(true)); | 165 .WillRepeatedly(Return(true)); |
| 166 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) | 166 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) |
| 167 .WillRepeatedly(Return(true)); | 167 .WillRepeatedly(Return(true)); |
| 168 VerifySyncGlobalErrorResult( | 168 VerifySyncGlobalErrorResult( |
| 169 &service, login_ui_service, browser(), &error, &global_error, | 169 &service, login_ui_service, browser(), &error, &global_error, |
| 170 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, | 170 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, |
| 171 false /* not signed in */, false /* no error */); | 171 false /* not signed in */, false /* no error */); |
| 172 | 172 |
| 173 global_error.Shutdown(); | 173 global_error.Shutdown(); |
| 174 } | 174 } |
| OLD | NEW |