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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 .WillRepeatedly(Return(is_signed_in)); | 106 .WillRepeatedly(Return(is_signed_in)); |
107 | 107 |
108 GoogleServiceAuthError auth_error(error_state); | 108 GoogleServiceAuthError auth_error(error_state); |
109 EXPECT_CALL(*service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error)); | 109 EXPECT_CALL(*service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error)); |
110 | 110 |
111 error->OnStateChanged(); | 111 error->OnStateChanged(); |
112 | 112 |
113 // If there is an error then a wrench button badge, menu item, and bubble view | 113 // If there is an error then a wrench button badge, menu item, and bubble view |
114 // should be shown. | 114 // should be shown. |
115 EXPECT_EQ(error->HasBadge(), is_error); | 115 EXPECT_EQ(error->HasBadge(), is_error); |
116 EXPECT_EQ(error->HasMenuItem() || error->HasCustomizedSyncMenuItem(), | 116 EXPECT_EQ(error->HasMenuItem() || error->HasBadge(), is_error); |
117 is_error); | |
118 EXPECT_EQ(error->HasBubbleView(), is_error); | 117 EXPECT_EQ(error->HasBubbleView(), is_error); |
119 | 118 |
120 // If there is an error then labels should not be empty. | 119 // If there is an error then labels should not be empty. |
121 EXPECT_NE(error->MenuItemCommandID(), 0); | 120 EXPECT_NE(error->MenuItemCommandID(), 0); |
122 EXPECT_NE(error->MenuItemLabel().empty(), is_error); | 121 EXPECT_NE(error->MenuItemLabel().empty(), is_error); |
123 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error); | 122 EXPECT_NE(error->GetBubbleViewAcceptButtonLabel().empty(), is_error); |
124 | 123 |
125 // We never have a cancel button. | 124 // We never have a cancel button. |
126 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty()); | 125 EXPECT_TRUE(error->GetBubbleViewCancelButtonLabel().empty()); |
127 // We always return a hardcoded title. | 126 // We always return a hardcoded title. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 .WillRepeatedly(Return(false)); | 174 .WillRepeatedly(Return(false)); |
176 | 175 |
177 EXPECT_CALL(service, IsPassphraseRequired()) | 176 EXPECT_CALL(service, IsPassphraseRequired()) |
178 .WillRepeatedly(Return(true)); | 177 .WillRepeatedly(Return(true)); |
179 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) | 178 EXPECT_CALL(service, IsPassphraseRequiredForDecryption()) |
180 .WillRepeatedly(Return(true)); | 179 .WillRepeatedly(Return(true)); |
181 VerifySyncGlobalErrorResult( | 180 VerifySyncGlobalErrorResult( |
182 &service, login_ui_service, browser(), &error, | 181 &service, login_ui_service, browser(), &error, |
183 GoogleServiceAuthError::NONE, true, true); | 182 GoogleServiceAuthError::NONE, true, true); |
184 } | 183 } |
185 | |
186 // Test that SyncGlobalError shows an error for conditions that can be resolved | |
187 // by the user and suppresses errors for conditions that cannot be resolved by | |
188 // the user. | |
189 TEST_F(SyncGlobalErrorTest, AuthStateGlobalError) { | |
190 scoped_ptr<Profile> profile( | |
191 ProfileSyncServiceMock::MakeSignedInTestingProfile()); | |
192 NiceMock<ProfileSyncServiceMock> service(profile.get()); | |
193 SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get()); | |
194 FakeLoginUIService* login_ui_service = static_cast<FakeLoginUIService*>( | |
195 LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( | |
196 profile.get(), BuildMockLoginUIService)); | |
197 FakeLoginUI login_ui; | |
198 login_ui_service->SetLoginUI(&login_ui); | |
199 SyncGlobalError error(&service, signin); | |
200 | |
201 browser_sync::SyncBackendHost::Status status; | |
202 EXPECT_CALL(service, QueryDetailedSyncStatus(_)) | |
203 .WillRepeatedly(Return(false)); | |
204 | |
205 struct { | |
206 GoogleServiceAuthError::State error_state; | |
207 bool is_error; | |
208 } table[] = { | |
209 { GoogleServiceAuthError::NONE, false }, | |
210 { GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, true }, | |
211 { GoogleServiceAuthError::USER_NOT_SIGNED_UP, true }, | |
212 { GoogleServiceAuthError::CONNECTION_FAILED, false }, | |
213 { GoogleServiceAuthError::CAPTCHA_REQUIRED, true }, | |
214 { GoogleServiceAuthError::ACCOUNT_DELETED, true }, | |
215 { GoogleServiceAuthError::ACCOUNT_DISABLED, true }, | |
216 { GoogleServiceAuthError::SERVICE_UNAVAILABLE, true }, | |
217 { GoogleServiceAuthError::TWO_FACTOR, true }, | |
218 { GoogleServiceAuthError::REQUEST_CANCELED, true }, | |
219 { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true }, | |
220 }; | |
221 | |
222 for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) { | |
223 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | |
224 table[i].error_state, true, table[i].is_error); | |
225 VerifySyncGlobalErrorResult(&service, login_ui_service, browser(), &error, | |
226 table[i].error_state, false, false); | |
227 } | |
228 } | |
OLD | NEW |