| 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 <stddef.h> |    5 #include <stddef.h> | 
|    6  |    6  | 
|    7 #include <memory> |    7 #include <memory> | 
|    8  |    8  | 
|    9 #include <set> |    9 #include <set> | 
|   10 #include "base/macros.h" |   10 #include "base/macros.h" | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|   41  |   41  | 
|   42 // A number of distinct states of the ProfileSyncService can be generated for |   42 // A number of distinct states of the ProfileSyncService can be generated for | 
|   43 // tests. |   43 // tests. | 
|   44 enum DistinctState { |   44 enum DistinctState { | 
|   45   STATUS_CASE_SETUP_IN_PROGRESS, |   45   STATUS_CASE_SETUP_IN_PROGRESS, | 
|   46   STATUS_CASE_SETUP_ERROR, |   46   STATUS_CASE_SETUP_ERROR, | 
|   47   STATUS_CASE_AUTHENTICATING, |   47   STATUS_CASE_AUTHENTICATING, | 
|   48   STATUS_CASE_AUTH_ERROR, |   48   STATUS_CASE_AUTH_ERROR, | 
|   49   STATUS_CASE_PROTOCOL_ERROR, |   49   STATUS_CASE_PROTOCOL_ERROR, | 
|   50   STATUS_CASE_PASSPHRASE_ERROR, |   50   STATUS_CASE_PASSPHRASE_ERROR, | 
 |   51   STATUS_CASE_CONFIRM_SYNC_SETTINGS, | 
|   51   STATUS_CASE_SYNCED, |   52   STATUS_CASE_SYNCED, | 
|   52   STATUS_CASE_SYNC_DISABLED_BY_POLICY, |   53   STATUS_CASE_SYNC_DISABLED_BY_POLICY, | 
|   53   NUMBER_OF_STATUS_CASES |   54   NUMBER_OF_STATUS_CASES | 
|   54 }; |   55 }; | 
|   55  |   56  | 
|   56 namespace { |   57 namespace { | 
|   57  |   58  | 
|   58 const char kTestGaiaId[] = "gaia-id-test_user@test.com"; |   59 const char kTestGaiaId[] = "gaia-id-test_user@test.com"; | 
|   59 const char kTestUser[] = "test_user@test.com"; |   60 const char kTestUser[] = "test_user@test.com"; | 
|   60  |   61  | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  166       syncer::SyncProtocolError protocolError; |  167       syncer::SyncProtocolError protocolError; | 
|  167       protocolError.action = syncer::UPGRADE_CLIENT; |  168       protocolError.action = syncer::UPGRADE_CLIENT; | 
|  168       syncer::SyncEngine::Status status; |  169       syncer::SyncEngine::Status status; | 
|  169       status.sync_protocol_error = protocolError; |  170       status.sync_protocol_error = protocolError; | 
|  170       EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) |  171       EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) | 
|  171           .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); |  172           .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); | 
|  172       EXPECT_CALL(*service, HasUnrecoverableError()) |  173       EXPECT_CALL(*service, HasUnrecoverableError()) | 
|  173           .WillRepeatedly(Return(false)); |  174           .WillRepeatedly(Return(false)); | 
|  174       return; |  175       return; | 
|  175     } |  176     } | 
 |  177     case STATUS_CASE_CONFIRM_SYNC_SETTINGS: { | 
 |  178       EXPECT_CALL(*service, IsSyncConfirmationNeeded()) | 
 |  179           .WillRepeatedly(Return(true)); | 
 |  180       EXPECT_CALL(*service, IsPassphraseRequired()) | 
 |  181           .WillRepeatedly(Return(false)); | 
 |  182       syncer::SyncEngine::Status status; | 
 |  183       EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) | 
 |  184           .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); | 
 |  185       return; | 
 |  186     } | 
|  176     case STATUS_CASE_PASSPHRASE_ERROR: { |  187     case STATUS_CASE_PASSPHRASE_ERROR: { | 
|  177       EXPECT_CALL(*service, IsFirstSetupComplete()) |  188       EXPECT_CALL(*service, IsFirstSetupComplete()) | 
|  178           .WillRepeatedly(Return(true)); |  189           .WillRepeatedly(Return(true)); | 
|  179       EXPECT_CALL(*service, IsSyncActive()).WillRepeatedly(Return(true)); |  190       EXPECT_CALL(*service, IsSyncActive()).WillRepeatedly(Return(true)); | 
|  180       syncer::SyncEngine::Status status; |  191       syncer::SyncEngine::Status status; | 
|  181       EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) |  192       EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) | 
|  182           .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); |  193           .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); | 
|  183       EXPECT_CALL(*service, HasUnrecoverableError()) |  194       EXPECT_CALL(*service, HasUnrecoverableError()) | 
|  184           .WillRepeatedly(Return(false)); |  195           .WillRepeatedly(Return(false)); | 
|  185       EXPECT_CALL(*service, IsPassphraseRequired()) |  196       EXPECT_CALL(*service, IsPassphraseRequired()) | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  231     case STATUS_CASE_SETUP_ERROR: |  242     case STATUS_CASE_SETUP_ERROR: | 
|  232       return sync_ui_util::REAUTHENTICATE; |  243       return sync_ui_util::REAUTHENTICATE; | 
|  233     case STATUS_CASE_AUTHENTICATING: |  244     case STATUS_CASE_AUTHENTICATING: | 
|  234       return sync_ui_util::NO_ACTION; |  245       return sync_ui_util::NO_ACTION; | 
|  235     case STATUS_CASE_AUTH_ERROR: |  246     case STATUS_CASE_AUTH_ERROR: | 
|  236       return sync_ui_util::REAUTHENTICATE; |  247       return sync_ui_util::REAUTHENTICATE; | 
|  237     case STATUS_CASE_PROTOCOL_ERROR: |  248     case STATUS_CASE_PROTOCOL_ERROR: | 
|  238       return sync_ui_util::UPGRADE_CLIENT; |  249       return sync_ui_util::UPGRADE_CLIENT; | 
|  239     case STATUS_CASE_PASSPHRASE_ERROR: |  250     case STATUS_CASE_PASSPHRASE_ERROR: | 
|  240       return sync_ui_util::ENTER_PASSPHRASE; |  251       return sync_ui_util::ENTER_PASSPHRASE; | 
 |  252     case STATUS_CASE_CONFIRM_SYNC_SETTINGS: | 
 |  253       return sync_ui_util::CONFIRM_SYNC_SETTINGS; | 
|  241     case STATUS_CASE_SYNCED: |  254     case STATUS_CASE_SYNCED: | 
|  242       return sync_ui_util::NO_ACTION; |  255       return sync_ui_util::NO_ACTION; | 
|  243     case STATUS_CASE_SYNC_DISABLED_BY_POLICY: |  256     case STATUS_CASE_SYNC_DISABLED_BY_POLICY: | 
|  244       return sync_ui_util::NO_ACTION; |  257       return sync_ui_util::NO_ACTION; | 
|  245     default: |  258     default: | 
|  246       NOTREACHED(); |  259       NOTREACHED(); | 
|  247       return sync_ui_util::NO_ACTION; |  260       return sync_ui_util::NO_ACTION; | 
|  248   } |  261   } | 
|  249 } |  262 } | 
|  250  |  263  | 
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  406   sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, |  419   sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, | 
|  407                                 sync_ui_util::PLAIN_TEXT, |  420                                 sync_ui_util::PLAIN_TEXT, | 
|  408                                 &second_actionable_error_status_label, |  421                                 &second_actionable_error_status_label, | 
|  409                                 &link_label, &action_type); |  422                                 &link_label, &action_type); | 
|  410   // Expect a passive message instead of a call to action. |  423   // Expect a passive message instead of a call to action. | 
|  411   EXPECT_EQ(sync_ui_util::NO_ACTION, action_type); |  424   EXPECT_EQ(sync_ui_util::NO_ACTION, action_type); | 
|  412  |  425  | 
|  413   EXPECT_NE(first_actionable_error_status_label, |  426   EXPECT_NE(first_actionable_error_status_label, | 
|  414             second_actionable_error_status_label); |  427             second_actionable_error_status_label); | 
|  415 } |  428 } | 
 |  429  | 
 |  430 TEST_F(SyncUIUtilTest, SyncSettingsConfirmationNeededTest) { | 
 |  431   std::unique_ptr<Profile> profile(MakeSignedInTestingProfile()); | 
 |  432   SigninManagerBase* signin = | 
 |  433       SigninManagerFactory::GetForProfile(profile.get()); | 
 |  434  | 
 |  435   ProfileSyncServiceMock service( | 
 |  436       CreateProfileSyncServiceParamsForTest(profile.get())); | 
 |  437   EXPECT_CALL(service, IsSyncConfirmationNeeded()).WillRepeatedly(Return(true)); | 
 |  438  | 
 |  439   base::string16 actionable_error_status_label; | 
 |  440   base::string16 link_label; | 
 |  441   sync_ui_util::ActionType action_type = sync_ui_util::NO_ACTION; | 
 |  442  | 
 |  443   sync_ui_util::GetStatusLabels( | 
 |  444       profile.get(), &service, *signin, sync_ui_util::PLAIN_TEXT, | 
 |  445       &actionable_error_status_label, &link_label, &action_type); | 
 |  446  | 
 |  447   EXPECT_EQ(action_type, sync_ui_util::CONFIRM_SYNC_SETTINGS); | 
 |  448 } | 
| OLD | NEW |