| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/signin/signin_manager.h" | 10 #include "chrome/browser/signin/signin_manager.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public: | 32 public: |
| 33 explicit BrowserMock(Type type, Profile* profile) : Browser(type, profile) {} | 33 explicit BrowserMock(Type type, Profile* profile) : Browser(type, profile) {} |
| 34 | 34 |
| 35 MOCK_METHOD2(ExecuteCommandWithDisposition, | 35 MOCK_METHOD2(ExecuteCommandWithDisposition, |
| 36 void(int command_id, WindowOpenDisposition)); | 36 void(int command_id, WindowOpenDisposition)); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class LoginUIServiceMock: public LoginUIService { | 39 class LoginUIServiceMock: public LoginUIService { |
| 40 public: | 40 public: |
| 41 explicit LoginUIServiceMock(Profile* profile) : LoginUIService(profile) {} | 41 explicit LoginUIServiceMock(Profile* profile) : LoginUIService(profile) {} |
| 42 MOCK_METHOD1(ShowLoginUI, void(bool)); | 42 MOCK_METHOD0(ShowLoginUI, void()); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 ProfileKeyedService* BuildMockLoginUIService(Profile* profile) { | 45 ProfileKeyedService* BuildMockLoginUIService(Profile* profile) { |
| 46 return new LoginUIServiceMock(profile); | 46 return new LoginUIServiceMock(profile); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to | 49 // Same as BrowserWithTestWindowTest, but uses MockBrowser to test calls to |
| 50 // ExecuteCommand method. | 50 // ExecuteCommand method. |
| 51 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { | 51 class SyncGlobalErrorTest : public BrowserWithTestWindowTest { |
| 52 public: | 52 public: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 #if defined(OS_CHROMEOS) | 103 #if defined(OS_CHROMEOS) |
| 104 if (error_state != GoogleServiceAuthError::NONE) { | 104 if (error_state != GoogleServiceAuthError::NONE) { |
| 105 // In CrOS sign-in/sign-out is made to fix the error. | 105 // In CrOS sign-in/sign-out is made to fix the error. |
| 106 EXPECT_CALL(*static_cast<BrowserMock*>(browser), | 106 EXPECT_CALL(*static_cast<BrowserMock*>(browser), |
| 107 ExecuteCommandWithDisposition(IDC_EXIT, _)); | 107 ExecuteCommandWithDisposition(IDC_EXIT, _)); |
| 108 error->ExecuteMenuItem(browser); | 108 error->ExecuteMenuItem(browser); |
| 109 } | 109 } |
| 110 #else | 110 #else |
| 111 // Test message handler. | 111 // Test message handler. |
| 112 if (is_error) { | 112 if (is_error) { |
| 113 EXPECT_CALL(*login_ui_service, ShowLoginUI(false)); | 113 EXPECT_CALL(*login_ui_service, ShowLoginUI()); |
| 114 error->ExecuteMenuItem(browser); | 114 error->ExecuteMenuItem(browser); |
| 115 EXPECT_CALL(*login_ui_service, ShowLoginUI(false)); | 115 EXPECT_CALL(*login_ui_service, ShowLoginUI()); |
| 116 error->BubbleViewAcceptButtonPressed(browser); | 116 error->BubbleViewAcceptButtonPressed(browser); |
| 117 error->BubbleViewDidClose(browser); | 117 error->BubbleViewDidClose(browser); |
| 118 } | 118 } |
| 119 #endif | 119 #endif |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 | 123 |
| 124 // Test that SyncGlobalError shows an error if a passphrase is required. | 124 // Test that SyncGlobalError shows an error if a passphrase is required. |
| 125 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { | 125 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, | 175 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { | 178 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { |
| 179 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 179 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
| 180 table[i].error_state, true, table[i].is_error); | 180 table[i].error_state, true, table[i].is_error); |
| 181 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 181 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
| 182 table[i].error_state, false, false); | 182 table[i].error_state, false, false); |
| 183 } | 183 } |
| 184 } | 184 } |
| OLD | NEW |