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 20 matching lines...) Expand all Loading... |
31 class BrowserMock: public Browser { | 31 class BrowserMock: public Browser { |
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() : LoginUIService() {} |
42 MOCK_METHOD0(ShowLoginUI, void()); | 42 MOCK_METHOD1(ShowLoginUI, void(Browser*)); |
43 }; | 43 }; |
44 | 44 |
45 ProfileKeyedService* BuildMockLoginUIService(Profile* profile) { | 45 ProfileKeyedService* BuildMockLoginUIService(Profile* profile) { |
46 return new LoginUIServiceMock(profile); | 46 return new LoginUIServiceMock(); |
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: |
53 SyncGlobalErrorTest() {} | 53 SyncGlobalErrorTest() {} |
54 virtual ~SyncGlobalErrorTest() {} | 54 virtual ~SyncGlobalErrorTest() {} |
55 | 55 |
56 virtual void SetUp() OVERRIDE { | 56 virtual void SetUp() OVERRIDE { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
108 if (error_state != GoogleServiceAuthError::NONE) { | 108 if (error_state != GoogleServiceAuthError::NONE) { |
109 // In CrOS sign-in/sign-out is made to fix the error. | 109 // In CrOS sign-in/sign-out is made to fix the error. |
110 EXPECT_CALL(*static_cast<BrowserMock*>(browser), | 110 EXPECT_CALL(*static_cast<BrowserMock*>(browser), |
111 ExecuteCommandWithDisposition(IDC_EXIT, _)); | 111 ExecuteCommandWithDisposition(IDC_EXIT, _)); |
112 error->ExecuteMenuItem(browser); | 112 error->ExecuteMenuItem(browser); |
113 } | 113 } |
114 #else | 114 #else |
115 // Test message handler. | 115 // Test message handler. |
116 if (is_error) { | 116 if (is_error) { |
117 EXPECT_CALL(*login_ui_service, ShowLoginUI()); | 117 EXPECT_CALL(*login_ui_service, ShowLoginUI(browser)); |
118 error->ExecuteMenuItem(browser); | 118 error->ExecuteMenuItem(browser); |
119 EXPECT_CALL(*login_ui_service, ShowLoginUI()); | 119 EXPECT_CALL(*login_ui_service, ShowLoginUI(browser)); |
120 error->BubbleViewAcceptButtonPressed(browser); | 120 error->BubbleViewAcceptButtonPressed(browser); |
121 error->BubbleViewDidClose(browser); | 121 error->BubbleViewDidClose(browser); |
122 } | 122 } |
123 #endif | 123 #endif |
124 } | 124 } |
125 | 125 |
126 } // namespace | 126 } // namespace |
127 | 127 |
128 // Test that SyncGlobalError shows an error if a passphrase is required. | 128 // Test that SyncGlobalError shows an error if a passphrase is required. |
129 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { | 129 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, | 183 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, |
184 }; | 184 }; |
185 | 185 |
186 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { | 186 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { |
187 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 187 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
188 table[i].error_state, true, table[i].is_error); | 188 table[i].error_state, true, table[i].is_error); |
189 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 189 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
190 table[i].error_state, false, false); | 190 table[i].error_state, false, false); |
191 } | 191 } |
192 } | 192 } |
OLD | NEW |