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 8ccf6c0a1383e72c02031cf1ccfe93de72a4ece4..e2aa18969c856244df9dc0bdc29808f2d4092268 100644 |
--- a/chrome/browser/sync/sync_ui_util_unittest.cc |
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc |
@@ -274,7 +274,7 @@ void GetDistinctCase(ProfileSyncServiceMock* service, |
EXPECT_CALL(*service, IsPassphraseRequired()) |
.WillRepeatedly(Return(false)); |
syncer::SyncProtocolError protocolError; |
- protocolError.action = syncer::STOP_AND_RESTART_SYNC; |
+ protocolError.action = syncer::UPGRADE_CLIENT; |
syncer::SyncBackendHost::Status status; |
status.sync_protocol_error = protocolError; |
EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) |
@@ -351,9 +351,10 @@ TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { |
GetDistinctCase(&service, &signin, provider.get(), idx); |
base::string16 status_label; |
base::string16 link_label; |
+ sync_ui_util::ActionType action_type(sync_ui_util::NO_ACTION); |
maxbogue
2016/11/03 23:08:50
sync_ui_util::ActionType action_type = sync_ui_uti
Moe
2016/11/04 21:34:08
Done.
|
sync_ui_util::GetStatusLabels(profile.get(), &service, signin, |
sync_ui_util::WITH_HTML, &status_label, |
- &link_label); |
+ &link_label, &action_type); |
// If the status and link message combination is already present in the set |
// of messages already seen, this is a duplicate rather than a unique |
// message, and the test has failed. |
@@ -389,9 +390,10 @@ TEST_F(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) { |
GetDistinctCase(&service, &signin, provider.get(), idx); |
base::string16 status_label; |
base::string16 link_label; |
+ sync_ui_util::ActionType action_type(sync_ui_util::NO_ACTION); |
maxbogue
2016/11/03 23:08:49
Please use = here as well, and check the output of
Moe
2016/11/04 21:34:08
Done.
|
sync_ui_util::GetStatusLabels(profile.get(), &service, signin, |
sync_ui_util::PLAIN_TEXT, &status_label, |
- &link_label); |
+ &link_label, &action_type); |
// Ensures a search for string 'href' (found in links, not a string to be |
// found in an English language message) fails when links are excluded from |
@@ -424,9 +426,13 @@ TEST_F(SyncUIUtilTest, UnrecoverableErrorWithActionableError) { |
base::string16 link_label; |
base::string16 unrecoverable_error_status_label; |
+ sync_ui_util::ActionType action_type(sync_ui_util::NO_ACTION); |
maxbogue
2016/11/03 23:08:50
Please use =
Moe
2016/11/04 21:34:08
Done.
|
sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, |
sync_ui_util::PLAIN_TEXT, |
- &unrecoverable_error_status_label, &link_label); |
+ &unrecoverable_error_status_label, &link_label, |
+ &action_type); |
+ // Expect the generic unrecoverable error action which is to reauthenticate. |
+ EXPECT_EQ(action_type, sync_ui_util::REAUTHENTICATE); |
maxbogue
2016/11/03 23:08:50
Expected value should go first.
Moe
2016/11/04 21:34:08
Done.
|
// This time set action to UPGRADE_CLIENT. Ensure that status label differs |
// from previous one. |
@@ -436,6 +442,54 @@ TEST_F(SyncUIUtilTest, UnrecoverableErrorWithActionableError) { |
base::string16 upgrade_client_status_label; |
sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, |
sync_ui_util::PLAIN_TEXT, |
- &upgrade_client_status_label, &link_label); |
+ &upgrade_client_status_label, &link_label, |
+ &action_type); |
+ // Expect an explicit 'client upgrade' action. |
+ EXPECT_EQ(action_type, sync_ui_util::UPGRADE_CLIENT); |
maxbogue
2016/11/03 23:08:50
Expected value should go first.
Moe
2016/11/04 21:34:08
Done.
|
+ |
EXPECT_NE(unrecoverable_error_status_label, upgrade_client_status_label); |
} |
+ |
+TEST_F(SyncUIUtilTest, ActionableErrorWithPassiveMessage) { |
+ std::unique_ptr<Profile> profile(MakeSignedInTestingProfile()); |
+ SigninManagerBase* signin = |
+ SigninManagerFactory::GetForProfile(profile.get()); |
+ |
+ ProfileSyncServiceMock service( |
+ CreateProfileSyncServiceParamsForTest(profile.get())); |
+ EXPECT_CALL(service, IsFirstSetupComplete()).WillRepeatedly(Return(true)); |
+ EXPECT_CALL(service, HasUnrecoverableError()).WillRepeatedly(Return(true)); |
+ |
+ // Set action to UPGRADE_CLIENT. |
+ syncer::SyncStatus status; |
+ status.sync_protocol_error.action = syncer::UPGRADE_CLIENT; |
+ EXPECT_CALL(service, QueryDetailedSyncStatus(_)) |
+ .WillOnce(DoAll(SetArgPointee<0>(status), Return(true))); |
+ |
+ base::string16 first_actionable_error_status_label; |
+ base::string16 link_label; |
+ sync_ui_util::ActionType action_type(sync_ui_util::NO_ACTION); |
maxbogue
2016/11/03 23:08:50
= here as well
Moe
2016/11/04 21:34:08
Done.
|
+ sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, |
+ sync_ui_util::PLAIN_TEXT, |
+ &first_actionable_error_status_label, |
+ &link_label, &action_type); |
+ // Expect a 'client upgrade' call to action. |
+ EXPECT_EQ(action_type, sync_ui_util::UPGRADE_CLIENT); |
maxbogue
2016/11/03 23:08:50
Expected value first.
Moe
2016/11/04 21:34:08
Done.
|
+ |
+ // This time set action to ENABLE_SYNC_ON_ACCOUNT. |
+ status.sync_protocol_error.action = syncer::ENABLE_SYNC_ON_ACCOUNT; |
+ EXPECT_CALL(service, QueryDetailedSyncStatus(_)) |
+ .WillOnce(DoAll(SetArgPointee<0>(status), Return(true))); |
+ |
+ base::string16 second_actionable_error_status_label; |
+ action_type = sync_ui_util::NO_ACTION; |
+ sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, |
+ sync_ui_util::PLAIN_TEXT, |
+ &second_actionable_error_status_label, |
+ &link_label, &action_type); |
+ // Expect a passive message instead of a call to action. |
+ EXPECT_EQ(action_type, sync_ui_util::NO_ACTION); |
maxbogue
2016/11/03 23:08:50
Expected value first.
Moe
2016/11/04 21:34:08
Done.
|
+ |
+ EXPECT_NE(first_actionable_error_status_label, |
+ second_actionable_error_status_label); |
+} |