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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 EXPECT_NE(error->MenuItemCommandID(), 0); | 98 EXPECT_NE(error->MenuItemCommandID(), 0); |
99 EXPECT_NE(error->MenuItemLabel().empty(), is_error); | 99 EXPECT_NE(error->MenuItemLabel().empty(), is_error); |
100 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error); | 100 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error); |
101 | 101 |
102 // We never have a cancel button. | 102 // We never have a cancel button. |
103 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty()); | 103 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty()); |
104 // We always return a hardcoded title. | 104 // We always return a hardcoded title. |
105 EXPECT_FALSE(error->GetBubbleViewTitle().empty()); | 105 EXPECT_FALSE(error->GetBubbleViewTitle().empty()); |
106 | 106 |
107 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
| 108 // TODO(altimofeev): Implement this in a way that doesn't involve subclassing |
| 109 // Browser or using GMock on browser/ui types which is |
| 110 // banned. Consider observing NOTIFICATION_APP_TERMINATING |
| 111 // instead. |
| 112 // http://crbug.com/134675 |
| 113 #else |
| 114 #if defined(OS_CHROMEOS) |
108 if (error_state != GoogleServiceAuthError::NONE) { | 115 if (error_state != GoogleServiceAuthError::NONE) { |
109 // In CrOS sign-in/sign-out is made to fix the error. | 116 // In CrOS sign-in/sign-out is made to fix the error. |
110 EXPECT_CALL(*static_cast<BrowserMock*>(browser), | 117 EXPECT_CALL(*static_cast<BrowserMock*>(browser), |
111 ExecuteCommandWithDisposition(IDC_EXIT, _)); | 118 ExecuteCommandWithDisposition(IDC_EXIT, _)); |
112 error->ExecuteMenuItem(browser); | 119 error->ExecuteMenuItem(browser); |
113 } | 120 } |
114 #else | 121 #else |
115 // Test message handler. | 122 // Test message handler. |
116 if (is_error) { | 123 if (is_error) { |
117 EXPECT_CALL(*login_ui_service, ShowLoginUI()); | 124 EXPECT_CALL(*login_ui_service, ShowLoginUI()); |
118 error->ExecuteMenuItem(browser); | 125 error->ExecuteMenuItem(browser); |
119 EXPECT_CALL(*login_ui_service, ShowLoginUI()); | 126 EXPECT_CALL(*login_ui_service, ShowLoginUI()); |
120 error->BubbleViewAcceptButtonPressed(browser); | 127 error->BubbleViewAcceptButtonPressed(browser); |
121 error->BubbleViewDidClose(browser); | 128 error->BubbleViewDidClose(browser); |
122 } | 129 } |
123 #endif | 130 #endif |
| 131 #endif |
124 } | 132 } |
125 | 133 |
126 } // namespace | 134 } // namespace |
127 | 135 |
128 // Test that SyncGlobalError shows an error if a passphrase is required. | 136 // Test that SyncGlobalError shows an error if a passphrase is required. |
129 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { | 137 TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) { |
130 scoped_ptr<Profile> profile( | 138 scoped_ptr<Profile> profile( |
131 ProfileSyncServiceMock::MakeSignedInTestingProfile()); | 139 ProfileSyncServiceMock::MakeSignedInTestingProfile()); |
132 NiceMock<ProfileSyncServiceMock> service(profile.get()); | 140 NiceMock<ProfileSyncServiceMock> service(profile.get()); |
133 SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get()); | 141 SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, | 191 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, |
184 }; | 192 }; |
185 | 193 |
186 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { | 194 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { |
187 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 195 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
188 table[i].error_state, true, table[i].is_error); | 196 table[i].error_state, true, table[i].is_error); |
189 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | 197 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, |
190 table[i].error_state, false, false); | 198 table[i].error_state, false, false); |
191 } | 199 } |
192 } | 200 } |
OLD | NEW |