Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: chrome/browser/sync/sync_ui_util_unittest.cc

Issue 8308005: Suppress bubble view for CONNECTION_FAILED error (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/browser/sync/sync_ui_util.cc ('K') | « chrome/browser/sync/sync_ui_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/sync_ui_util_unittest.cc
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
index 17f2f18e3884fa830585a294d38be3302ca3503c..c3480a1b317b1aeb90ff3281ba6dc5101e869a97 100644
--- a/chrome/browser/sync/sync_ui_util_unittest.cc
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -13,6 +13,31 @@
using ::testing::Return;
using ::testing::NiceMock;
+
+namespace {
+
+// Utility function to test that GetStatusLabelsForSyncGlobalError returns
+// the correct results for the given states.
+void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
+ GoogleServiceAuthError::State error_state,
+ bool is_signed_in,
+ bool is_error) {
+ GoogleServiceAuthError auth_error(error_state);
+ service->UpdateAuthErrorState(auth_error);
+
+ EXPECT_CALL(*service, HasSyncSetupCompleted())
+ .WillRepeatedly(Return(is_signed_in));
+
+ string16 label1, label2, label3;
+ sync_ui_util::GetStatusLabelsForSyncGlobalError(
+ service, &label1, &label2, &label3);
+ EXPECT_EQ(label1.empty(), !is_error);
+ EXPECT_EQ(label2.empty(), !is_error);
+ EXPECT_EQ(label3.empty(), !is_error);
+}
+
+} // namespace
+
TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
MessageLoopForUI message_loop;
BrowserThread ui_thread(BrowserThread::UI, &message_loop);
@@ -48,15 +73,49 @@ TEST(SyncUIUtilTest, PassphraseGlobalError) {
BrowserThread ui_thread(BrowserThread::UI, &message_loop);
NiceMock<ProfileSyncServiceMock> service;
- EXPECT_CALL(service, HasSyncSetupCompleted())
- .WillOnce(Return(true));
EXPECT_CALL(service, IsPassphraseRequired())
.WillOnce(Return(true));
EXPECT_CALL(service, IsPassphraseRequiredForDecryption())
.WillOnce(Return(true));
+ VerifySyncGlobalErrorResult(
+ &service, GoogleServiceAuthError::NONE, true, true);
+}
+
+// Test that GetStatusLabelsForSyncGlobalError indicates errors for conditions
+// that can be resolved by the user and suppresses errors for conditions that
+// cannot be resolved by the user.
+TEST(SyncUIUtilTest, AuthStateGlobalError) {
+ MessageLoopForUI message_loop;
+ BrowserThread ui_thread(BrowserThread::UI, &message_loop);
+ NiceMock<ProfileSyncServiceMock> service;
+
+ EXPECT_CALL(service, GetAuthenticatedUsername())
+ .WillRepeatedly(Return(UTF8ToUTF16("foo")));
+ browser_sync::SyncBackendHost::Status status;
+ EXPECT_CALL(service, QueryDetailedSyncStatus())
+ .WillRepeatedly(Return(status));
+
+ struct {
+ GoogleServiceAuthError::State error_state;
+ bool is_error;
+ } table[] = {
+ { GoogleServiceAuthError::NONE, false },
+ { GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, true },
+ { GoogleServiceAuthError::USER_NOT_SIGNED_UP, true },
+ { GoogleServiceAuthError::CONNECTION_FAILED, false },
+ { GoogleServiceAuthError::CAPTCHA_REQUIRED, true },
+ { GoogleServiceAuthError::ACCOUNT_DELETED, true },
+ { GoogleServiceAuthError::ACCOUNT_DISABLED, true },
+ { GoogleServiceAuthError::SERVICE_UNAVAILABLE, true },
+ { GoogleServiceAuthError::TWO_FACTOR, true },
+ { GoogleServiceAuthError::REQUEST_CANCELED, true },
+ { GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true },
+ };
- sync_ui_util::MessageType type =
- sync_ui_util::GetStatusLabelsForSyncGlobalError(
- &service, NULL, NULL, NULL);
- EXPECT_EQ(type, sync_ui_util::SYNC_ERROR);
+ for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) {
+ VerifySyncGlobalErrorResult(
+ &service, table[i].error_state, true, table[i].is_error);
+ VerifySyncGlobalErrorResult(
+ &service, table[i].error_state, false, false);
+ }
}
« chrome/browser/sync/sync_ui_util.cc ('K') | « chrome/browser/sync/sync_ui_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698