Chromium Code Reviews| 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, IsFirstSetupComplete()) | |
| 179 .WillRepeatedly(Return(false)); | |
| 180 EXPECT_CALL(*service, IsSyncRequested()).WillRepeatedly(Return(true)); | |
| 181 EXPECT_CALL(*service, IsPassphraseRequired()) | |
| 182 .WillRepeatedly(Return(false)); | |
| 183 syncer::SyncEngine::Status status; | |
| 184 EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) | |
| 185 .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); | |
| 186 return; | |
| 187 } | |
| 176 case STATUS_CASE_PASSPHRASE_ERROR: { | 188 case STATUS_CASE_PASSPHRASE_ERROR: { |
| 177 EXPECT_CALL(*service, IsFirstSetupComplete()) | 189 EXPECT_CALL(*service, IsFirstSetupComplete()) |
| 178 .WillRepeatedly(Return(true)); | 190 .WillRepeatedly(Return(true)); |
| 179 EXPECT_CALL(*service, IsSyncActive()).WillRepeatedly(Return(true)); | 191 EXPECT_CALL(*service, IsSyncActive()).WillRepeatedly(Return(true)); |
| 180 syncer::SyncEngine::Status status; | 192 syncer::SyncEngine::Status status; |
| 181 EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) | 193 EXPECT_CALL(*service, QueryDetailedSyncStatus(_)) |
| 182 .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); | 194 .WillRepeatedly(DoAll(SetArgPointee<0>(status), Return(false))); |
| 183 EXPECT_CALL(*service, HasUnrecoverableError()) | 195 EXPECT_CALL(*service, HasUnrecoverableError()) |
| 184 .WillRepeatedly(Return(false)); | 196 .WillRepeatedly(Return(false)); |
| 185 EXPECT_CALL(*service, IsPassphraseRequired()) | 197 EXPECT_CALL(*service, IsPassphraseRequired()) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 case STATUS_CASE_SETUP_ERROR: | 243 case STATUS_CASE_SETUP_ERROR: |
| 232 return sync_ui_util::REAUTHENTICATE; | 244 return sync_ui_util::REAUTHENTICATE; |
| 233 case STATUS_CASE_AUTHENTICATING: | 245 case STATUS_CASE_AUTHENTICATING: |
| 234 return sync_ui_util::NO_ACTION; | 246 return sync_ui_util::NO_ACTION; |
| 235 case STATUS_CASE_AUTH_ERROR: | 247 case STATUS_CASE_AUTH_ERROR: |
| 236 return sync_ui_util::REAUTHENTICATE; | 248 return sync_ui_util::REAUTHENTICATE; |
| 237 case STATUS_CASE_PROTOCOL_ERROR: | 249 case STATUS_CASE_PROTOCOL_ERROR: |
| 238 return sync_ui_util::UPGRADE_CLIENT; | 250 return sync_ui_util::UPGRADE_CLIENT; |
| 239 case STATUS_CASE_PASSPHRASE_ERROR: | 251 case STATUS_CASE_PASSPHRASE_ERROR: |
| 240 return sync_ui_util::ENTER_PASSPHRASE; | 252 return sync_ui_util::ENTER_PASSPHRASE; |
| 253 case STATUS_CASE_CONFIRM_SYNC_SETTINGS: | |
| 254 return sync_ui_util::CONFIRM_SYNC_SETTINGS; | |
| 241 case STATUS_CASE_SYNCED: | 255 case STATUS_CASE_SYNCED: |
| 242 return sync_ui_util::NO_ACTION; | 256 return sync_ui_util::NO_ACTION; |
| 243 case STATUS_CASE_SYNC_DISABLED_BY_POLICY: | 257 case STATUS_CASE_SYNC_DISABLED_BY_POLICY: |
| 244 return sync_ui_util::NO_ACTION; | 258 return sync_ui_util::NO_ACTION; |
| 245 default: | 259 default: |
| 246 NOTREACHED(); | 260 NOTREACHED(); |
| 247 return sync_ui_util::NO_ACTION; | 261 return sync_ui_util::NO_ACTION; |
| 248 } | 262 } |
| 249 } | 263 } |
| 250 | 264 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, | 420 sync_ui_util::GetStatusLabels(profile.get(), &service, *signin, |
| 407 sync_ui_util::PLAIN_TEXT, | 421 sync_ui_util::PLAIN_TEXT, |
| 408 &second_actionable_error_status_label, | 422 &second_actionable_error_status_label, |
| 409 &link_label, &action_type); | 423 &link_label, &action_type); |
| 410 // Expect a passive message instead of a call to action. | 424 // Expect a passive message instead of a call to action. |
| 411 EXPECT_EQ(sync_ui_util::NO_ACTION, action_type); | 425 EXPECT_EQ(sync_ui_util::NO_ACTION, action_type); |
| 412 | 426 |
| 413 EXPECT_NE(first_actionable_error_status_label, | 427 EXPECT_NE(first_actionable_error_status_label, |
| 414 second_actionable_error_status_label); | 428 second_actionable_error_status_label); |
| 415 } | 429 } |
| 430 | |
| 431 TEST_F(SyncUIUtilTest, SyncSettingsConfirmationNeededTest) { | |
|
skym
2017/06/01 19:48:44
Can you make a unit test that has nullptr for the
Patrick Noland
2017/06/07 19:07:23
Alas, GetStatusLabels DCHECKS that link_label and
| |
| 432 std::unique_ptr<Profile> profile(MakeSignedInTestingProfile()); | |
| 433 SigninManagerBase* signin = | |
| 434 SigninManagerFactory::GetForProfile(profile.get()); | |
| 435 | |
| 436 ProfileSyncServiceMock service( | |
| 437 CreateProfileSyncServiceParamsForTest(profile.get())); | |
| 438 EXPECT_CALL(service, IsFirstSetupComplete()).WillRepeatedly(Return(false)); | |
| 439 EXPECT_CALL(service, IsSyncRequested()).WillRepeatedly(Return(true)); | |
| 440 | |
| 441 base::string16 actionable_error_status_label; | |
| 442 base::string16 link_label; | |
| 443 sync_ui_util::ActionType action_type = sync_ui_util::NO_ACTION; | |
| 444 | |
| 445 sync_ui_util::GetStatusLabels( | |
| 446 profile.get(), &service, *signin, sync_ui_util::PLAIN_TEXT, | |
| 447 &actionable_error_status_label, &link_label, &action_type); | |
| 448 | |
| 449 EXPECT_EQ(action_type, sync_ui_util::CONFIRM_SYNC_SETTINGS); | |
| 450 } | |
| OLD | NEW |