Index: components/suggestions/suggestions_service_unittest.cc |
diff --git a/components/suggestions/suggestions_service_unittest.cc b/components/suggestions/suggestions_service_unittest.cc |
index 819e92bdc3f9f42d4394b1aecc1f776de6b80f55..05a7f86dc00e78f1265258edc010c6fe19989c68 100644 |
--- a/components/suggestions/suggestions_service_unittest.cc |
+++ b/components/suggestions/suggestions_service_unittest.cc |
@@ -326,6 +326,8 @@ TEST_F(SuggestionsServiceTest, FetchSuggestionsDataRequestError) { |
// Send the request. Empty data will be returned to the callback. |
suggestions_service->FetchSuggestionsData( |
+ true /* sync_initialized */, |
+ true /* history sync enabled */, |
base::Bind(&SuggestionsServiceTest::ExpectEmptySuggestionsProfile, |
base::Unretained(this))); |
@@ -361,6 +363,8 @@ TEST_F(SuggestionsServiceTest, FetchSuggestionsDataResponseNotOK) { |
// Send the request. Empty data will be returned to the callback. |
suggestions_service->FetchSuggestionsData( |
+ true /* sync_initialized */, |
+ true /* history sync enabled */, |
base::Bind(&SuggestionsServiceTest::ExpectEmptySuggestionsProfile, |
base::Unretained(this))); |
@@ -371,6 +375,59 @@ TEST_F(SuggestionsServiceTest, FetchSuggestionsDataResponseNotOK) { |
EXPECT_EQ(1, suggestions_empty_data_count_); |
} |
+TEST_F(SuggestionsServiceTest, FetchSuggestionsDataHistorySyncNotEnabled) { |
+ // Field trial enabled with a specific suggestions URL. |
+ EnableFieldTrial(kFakeSuggestionsURL, kFakeSuggestionsCommonParams, |
+ kFakeBlacklistPath, kFakeBlacklistUrlParam, false); |
+ scoped_ptr<SuggestionsService> suggestions_service( |
+ CreateSuggestionsServiceWithMocks()); |
+ EXPECT_TRUE(suggestions_service != NULL); |
+ |
+ // Send the request. Empty data will be returned to the callback. |
+ suggestions_service->FetchSuggestionsData( |
+ true /* sync_initialized */, |
+ false /* history sync disabled */, |
+ base::Bind(&SuggestionsServiceTest::ExpectEmptySuggestionsProfile, |
+ base::Unretained(this))); |
+ |
manzagop (departed)
2014/08/15 13:01:52
Test the cache was cleared by calling a second tim
Mathieu
2014/08/20 14:21:32
Done.
|
+ // Wait for posted task to complete. |
+ base::MessageLoop::current()->RunUntilIdle(); |
+ |
+ // Ensure that ExpectEmptySuggestionsProfile ran once. |
+ EXPECT_EQ(1, suggestions_empty_data_count_); |
+} |
+ |
+TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncNotInitialized) { |
+ // Field trial enabled with a specific suggestions URL. |
+ EnableFieldTrial(kFakeSuggestionsURL, kFakeSuggestionsCommonParams, |
+ kFakeBlacklistPath, kFakeBlacklistUrlParam, false); |
+ scoped_ptr<SuggestionsService> suggestions_service( |
+ CreateSuggestionsServiceWithMocks()); |
+ EXPECT_TRUE(suggestions_service != NULL); |
+ scoped_ptr<SuggestionsProfile> suggestions_profile( |
+ CreateSuggestionsProfile()); |
+ |
+ // Expectations. |
+ EXPECT_CALL(*mock_suggestions_store_, LoadSuggestions(_)) |
+ .WillOnce(DoAll(SetArgPointee<0>(*suggestions_profile), Return(true))); |
+ EXPECT_CALL(*mock_thumbnail_manager_, |
+ Initialize(EqualsProto(*suggestions_profile))); |
+ EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)); |
+ |
+ // Send the request. Empty data will be returned to the callback. |
+ suggestions_service->FetchSuggestionsData( |
+ false /* sync_initialized */, |
+ false /* history sync disabled (doesn't matter) */, |
+ base::Bind(&SuggestionsServiceTest::CheckSuggestionsData, |
+ base::Unretained(this))); |
+ |
+ // Wait for posted task to complete. |
+ base::MessageLoop::current()->RunUntilIdle(); |
+ |
+ // Ensure that CheckSuggestionsData ran once. |
+ EXPECT_EQ(1, suggestions_data_check_count_); |
+} |
+ |
TEST_F(SuggestionsServiceTest, BlacklistURL) { |
EnableFieldTrial(kFakeSuggestionsURL, kFakeSuggestionsCommonParams, |
kFakeBlacklistPath, kFakeBlacklistUrlParam, false); |