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

Side by Side Diff: chrome/browser/sync/sync_ui_util_unittest.cc

Issue 2044003005: [Sync] Display correct message for actionable error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/sync/sync_ui_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/signin/account_tracker_service_factory.h" 12 #include "chrome/browser/signin/account_tracker_service_factory.h"
13 #include "chrome/browser/signin/chrome_signin_client_factory.h" 13 #include "chrome/browser/signin/chrome_signin_client_factory.h"
14 #include "chrome/browser/signin/signin_error_controller_factory.h" 14 #include "chrome/browser/signin/signin_error_controller_factory.h"
15 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/sync/profile_sync_test_util.h" 16 #include "chrome/browser/sync/profile_sync_test_util.h"
16 #include "chrome/browser/sync/sync_ui_util.h" 17 #include "chrome/browser/sync/sync_ui_util.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
19 #include "components/browser_sync/browser/profile_sync_service_mock.h" 20 #include "components/browser_sync/browser/profile_sync_service_mock.h"
20 #include "components/signin/core/browser/fake_auth_status_provider.h" 21 #include "components/signin/core/browser/fake_auth_status_provider.h"
21 #include "components/signin/core/browser/fake_signin_manager.h" 22 #include "components/signin/core/browser/fake_signin_manager.h"
22 #include "components/signin/core/browser/signin_manager.h" 23 #include "components/signin/core/browser/signin_manager.h"
23 #include "content/public/test/test_browser_thread.h" 24 #include "content/public/test/test_browser_thread.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 GoogleServiceAuthError::CONNECTION_FAILED, 152 GoogleServiceAuthError::CONNECTION_FAILED,
152 GoogleServiceAuthError::CAPTCHA_REQUIRED, 153 GoogleServiceAuthError::CAPTCHA_REQUIRED,
153 GoogleServiceAuthError::ACCOUNT_DELETED, 154 GoogleServiceAuthError::ACCOUNT_DELETED,
154 GoogleServiceAuthError::ACCOUNT_DISABLED, 155 GoogleServiceAuthError::ACCOUNT_DISABLED,
155 GoogleServiceAuthError::SERVICE_UNAVAILABLE, 156 GoogleServiceAuthError::SERVICE_UNAVAILABLE,
156 GoogleServiceAuthError::TWO_FACTOR, 157 GoogleServiceAuthError::TWO_FACTOR,
157 GoogleServiceAuthError::REQUEST_CANCELED, 158 GoogleServiceAuthError::REQUEST_CANCELED,
158 GoogleServiceAuthError::HOSTED_NOT_ALLOWED 159 GoogleServiceAuthError::HOSTED_NOT_ALLOWED
159 }; 160 };
160 161
161 FakeSigninManagerBase signin(
162 ChromeSigninClientFactory::GetForProfile(profile.get()),
163 AccountTrackerServiceFactory::GetForProfile(profile.get()));
164 for (size_t i = 0; i < arraysize(table); ++i) { 162 for (size_t i = 0; i < arraysize(table); ++i) {
165 VerifySyncGlobalErrorResult(&service, 163 VerifySyncGlobalErrorResult(&service,
166 table[i], 164 table[i],
167 true /* signed in */, 165 true /* signed in */,
168 false /* no error */); 166 false /* no error */);
169 VerifySyncGlobalErrorResult(&service, 167 VerifySyncGlobalErrorResult(&service,
170 table[i], 168 table[i],
171 false /* not signed in */, 169 false /* not signed in */,
172 false /* no error */); 170 false /* no error */);
173 } 171 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 EXPECT_FALSE(status_label.empty()); 396 EXPECT_FALSE(status_label.empty());
399 EXPECT_EQ(status_label.find(base::ASCIIToUTF16("href")), 397 EXPECT_EQ(status_label.find(base::ASCIIToUTF16("href")),
400 base::string16::npos); 398 base::string16::npos);
401 testing::Mock::VerifyAndClearExpectations(&service); 399 testing::Mock::VerifyAndClearExpectations(&service);
402 testing::Mock::VerifyAndClearExpectations(&signin); 400 testing::Mock::VerifyAndClearExpectations(&signin);
403 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); 401 EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error));
404 provider.reset(); 402 provider.reset();
405 signin.Shutdown(); 403 signin.Shutdown();
406 } 404 }
407 } 405 }
406
407 TEST_F(SyncUIUtilTest, UnrecoverableErrorWithActionableError) {
408 std::unique_ptr<Profile> profile(MakeSignedInTestingProfile());
409 SigninManagerBase* signin =
410 SigninManagerFactory::GetForProfile(profile.get());
411
412 ProfileSyncServiceMock service(
413 CreateProfileSyncServiceParamsForTest(profile.get()));
414 EXPECT_CALL(service, IsFirstSetupComplete()).WillRepeatedly(Return(true));
415 EXPECT_CALL(service, HasUnrecoverableError()).WillRepeatedly(Return(true));
416
417 // First time action is not set. We should get unrecoverable error.
418 syncer::SyncStatus status;
419 EXPECT_CALL(service, QueryDetailedSyncStatus(_))
420 .WillOnce(DoAll(SetArgPointee<0>(status), Return(true)));
421
422 base::string16 link_label;
423 base::string16 unrecoverable_error_status_label;
424 sync_ui_util::GetStatusLabels(profile.get(), &service, *signin,
425 sync_ui_util::PLAIN_TEXT,
426 &unrecoverable_error_status_label, &link_label);
427
428 // This time set action to UPGRADE_CLIENT. Ensure that status label differs
429 // from previous one.
430 status.sync_protocol_error.action = syncer::UPGRADE_CLIENT;
431 EXPECT_CALL(service, QueryDetailedSyncStatus(_))
432 .WillOnce(DoAll(SetArgPointee<0>(status), Return(true)));
433 base::string16 upgrade_client_status_label;
434 sync_ui_util::GetStatusLabels(profile.get(), &service, *signin,
435 sync_ui_util::PLAIN_TEXT,
436 &upgrade_client_status_label, &link_label);
437 EXPECT_NE(unrecoverable_error_status_label, upgrade_client_status_label);
438 }
OLDNEW
« no previous file with comments | « 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