| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 Profile* profile() { return profile_.get(); } | 72 Profile* profile() { return profile_.get(); } |
| 73 | 73 |
| 74 private: | 74 private: |
| 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(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 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 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 118 ASSERT_GT(login_ui->focus_ui_call_count(), 0); | 118 ASSERT_GT(login_ui->focus_ui_call_count(), 0); |
| 119 global_error->BubbleViewAcceptButtonPressed(browser); | 119 global_error->BubbleViewAcceptButtonPressed(browser); |
| 120 global_error->BubbleViewDidClose(browser); | 120 global_error->BubbleViewDidClose(browser); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 } // namespace | 124 } // namespace |
| 125 | 125 |
| 126 // Test that SyncGlobalError shows an error if a passphrase is required. | 126 // Test that SyncGlobalError shows an error if a passphrase is required. |
| 127 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { | 127 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { |
| 128 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 SyncErrorController error(&service); | 137 SyncErrorController error(&service); |
| 138 SyncGlobalError global_error( | 138 SyncGlobalError global_error( |
| (...skipping 26 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 |