Chromium Code Reviews| Index: chrome/browser/sync/sync_error_notifier_ash_unittest.cc |
| diff --git a/chrome/browser/sync/sync_error_notifier_ash_unittest.cc b/chrome/browser/sync/sync_error_notifier_ash_unittest.cc |
| index 07b46dc92595a5be42ed4511a1d16cda09145208..04a0a0a65042b9d186aae4016e3ed17fad01de67 100644 |
| --- a/chrome/browser/sync/sync_error_notifier_ash_unittest.cc |
| +++ b/chrome/browser/sync/sync_error_notifier_ash_unittest.cc |
| @@ -134,7 +134,8 @@ class SyncErrorNotifierTest : public AshTestBase { |
| // given error condition. |
| void VerifySyncErrorNotifierResult(GoogleServiceAuthError::State error_state, |
| bool is_signed_in, |
| - bool is_error) { |
| + bool is_error, |
| + bool expected_notification) { |
| EXPECT_CALL(*service_, IsFirstSetupComplete()) |
| .WillRepeatedly(Return(is_signed_in)); |
| @@ -145,13 +146,12 @@ class SyncErrorNotifierTest : public AshTestBase { |
| error_controller_->OnStateChanged(service_.get()); |
| EXPECT_EQ(is_error, error_controller_->HasError()); |
| - // If there is an error we should see a notification. |
| const Notification* notification = notification_ui_manager_->FindById( |
| kNotificationId, NotificationUIManager::GetProfileID(profile_)); |
| - if (is_error) { |
| + if (expected_notification) { |
| ASSERT_TRUE(notification); |
| ASSERT_FALSE(notification->title().empty()); |
| - ASSERT_FALSE(notification->title().empty()); |
| + ASSERT_FALSE(notification->message().empty()); |
|
skym
2017/03/27 20:56:56
Nice catch
|
| ASSERT_EQ((size_t)1, notification->buttons().size()); |
| } else { |
| ASSERT_FALSE(notification); |
| @@ -202,8 +202,18 @@ TEST_F(SyncErrorNotifierTest, MAYBE_PassphraseNotification) { |
| { |
| SCOPED_TRACE("Expected a notification for passphrase error"); |
| VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE, |
| - true /* signed in */, |
| - true /* error */); |
| + true /* signed in */, true /* error */, |
|
skym
2017/03/27 20:56:56
Did you git cl format this?
pavely
2017/03/27 21:06:54
Yeah, I did. The result is worse than before, but
|
| + true /* expecting notification */); |
| + } |
| + |
| + // Sumulate discarded notification and check that notification is not shown. |
| + notification_ui_manager_->CancelById( |
| + kNotificationId, NotificationUIManager::GetProfileID(profile_)); |
| + { |
| + SCOPED_TRACE("Not expecting notification, one was already discarded"); |
| + VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE, |
| + true /* signed in */, true /* error */, |
| + false /* not expecting notification */); |
| } |
| // Check that no notification is shown if there is no error. |
| @@ -214,8 +224,8 @@ TEST_F(SyncErrorNotifierTest, MAYBE_PassphraseNotification) { |
| { |
| SCOPED_TRACE("Not expecting notification since no error exists"); |
| VerifySyncErrorNotifierResult(GoogleServiceAuthError::NONE, |
| - true /* signed in */, |
| - false /* no error */); |
| + true /* signed in */, false /* no error */, |
| + false /* not expecting notification */); |
| } |
| // Check that no notification is shown if sync setup is not completed. |
| @@ -227,8 +237,8 @@ TEST_F(SyncErrorNotifierTest, MAYBE_PassphraseNotification) { |
| SCOPED_TRACE("Not expecting notification since sync setup is incomplete"); |
| VerifySyncErrorNotifierResult( |
| GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, |
| - false /* not signed in */, |
| - false /* no error */); |
| + false /* not signed in */, false /* no error */, |
| + false /* not expecting notification */); |
| } |
| } |