Chromium Code Reviews| Index: components/suggestions/suggestions_service_impl_unittest.cc |
| diff --git a/components/suggestions/suggestions_service_impl_unittest.cc b/components/suggestions/suggestions_service_impl_unittest.cc |
| index 5643ed1151431509e71a94d0ec234f9eedb86acd..a44fed0ef1299f1dde551b7837cf18462fc2787b 100644 |
| --- a/components/suggestions/suggestions_service_impl_unittest.cc |
| +++ b/components/suggestions/suggestions_service_impl_unittest.cc |
| @@ -307,6 +307,36 @@ TEST_F(SuggestionsServiceTest, IgnoresUninterestingSyncChange) { |
| base::RunLoop().RunUntilIdle(); |
| } |
| +// During startup, the state changes from NOT_INITIALIZED_ENABLED to |
| +// INITIALIZED_ENABLED_HISTORY (for a signed-in user with history sync enabled). |
| +// This should *not* result in an automatic fetch. |
| +TEST_F(SuggestionsServiceTest, DoesNotFetchOnStartup) { |
| + // The sync service starts out inactive. |
| + EXPECT_CALL(mock_sync_service_, IsSyncActive()).WillRepeatedly(Return(false)); |
| + suggestions_service_->OnStateChanged(&mock_sync_service_); |
| + |
| + ASSERT_EQ(SuggestionsServiceImpl::NOT_INITIALIZED_ENABLED, |
| + suggestions_service_->ComputeSyncState()); |
| + |
| + base::MockCallback<SuggestionsService::ResponseCallback> callback; |
| + auto subscription = suggestions_service_->AddCallback(callback.Get()); |
| + |
| + factory_.SetFakeResponse(SuggestionsServiceImpl::BuildSuggestionsURL(), |
| + CreateSuggestionsProfile().SerializeAsString(), |
| + net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| + |
| + // Sync getting enabled should not result in a fetch. |
| + EXPECT_CALL(mock_sync_service_, IsSyncActive()).WillRepeatedly(Return(true)); |
| + EXPECT_CALL(callback, Run(_)).Times(0); |
|
mastiz
2017/05/08 14:18:32
I should've mentioned this earlier (as part of the
Marc Treib
2017/05/08 14:57:46
Done.
|
| + suggestions_service_->OnStateChanged(&mock_sync_service_); |
| + |
| + ASSERT_EQ(SuggestionsServiceImpl::INITIALIZED_ENABLED_HISTORY, |
| + suggestions_service_->ComputeSyncState()); |
| + |
| + // Let any network request run (there shouldn't be one). |
| + base::RunLoop().RunUntilIdle(); |
| +} |
| + |
| TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncNotInitializedEnabled) { |
| EXPECT_CALL(mock_sync_service_, IsSyncActive()).WillRepeatedly(Return(false)); |
| suggestions_service_->OnStateChanged(&mock_sync_service_); |