diff options
author | mathp@chromium.org <mathp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-11 19:32:04 +0000 |
---|---|---|
committer | mathp@chromium.org <mathp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-11 19:33:08 +0000 |
commit | a7a5511bd0bebd4e549a8f53770d8c2f4b1ce4ee (patch) | |
tree | d7982a0786f328d44081ddca19ccece17764ea45 /components/suggestions | |
parent | 523a72051334673661d395369d7f6af4e9c3cf90 (diff) | |
download | chromium_src-a7a5511bd0bebd4e549a8f53770d8c2f4b1ce4ee.zip chromium_src-a7a5511bd0bebd4e549a8f53770d8c2f4b1ce4ee.tar.gz chromium_src-a7a5511bd0bebd4e549a8f53770d8c2f4b1ce4ee.tar.bz2 |
[Suggestions Service] Initialize the ThumbnailManager when loading from cache.
BUG=389145
TEST=SuggestionsServiceTest*
Review URL: https://codereview.chromium.org/458993002
Cr-Commit-Position: refs/heads/master@{#288762}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288762 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/suggestions')
-rw-r--r-- | components/suggestions/suggestions_service.cc | 2 | ||||
-rw-r--r-- | components/suggestions/suggestions_service_unittest.cc | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/components/suggestions/suggestions_service.cc b/components/suggestions/suggestions_service.cc index f887157..db1e3fc 100644 --- a/components/suggestions/suggestions_service.cc +++ b/components/suggestions/suggestions_service.cc @@ -323,6 +323,7 @@ void SuggestionsService::OnURLFetchComplete(const net::URLFetcher* source) { } else { LogResponseState(RESPONSE_INVALID); suggestions_store_->LoadSuggestions(&suggestions); + thumbnail_manager_->Initialize(suggestions); } FilterAndServe(&suggestions); @@ -352,6 +353,7 @@ void SuggestionsService::Shutdown() { void SuggestionsService::ServeFromCache() { SuggestionsProfile suggestions; suggestions_store_->LoadSuggestions(&suggestions); + thumbnail_manager_->Initialize(suggestions); FilterAndServe(&suggestions); } diff --git a/components/suggestions/suggestions_service_unittest.cc b/components/suggestions/suggestions_service_unittest.cc index f1d8568..819e92b 100644 --- a/components/suggestions/suggestions_service_unittest.cc +++ b/components/suggestions/suggestions_service_unittest.cc @@ -203,7 +203,7 @@ class SuggestionsServiceTest : public testing::Test { // SuggestionsStore in |mock_suggestions_store_|. SuggestionsService* CreateSuggestionsServiceWithMocks() { mock_suggestions_store_ = new StrictMock<MockSuggestionsStore>(); - mock_thumbnail_manager_ = new NiceMock<MockImageManager>(); + mock_thumbnail_manager_ = new StrictMock<MockImageManager>(); mock_blacklist_store_ = new MockBlacklistStore(); return new SuggestionsService( request_context_, scoped_ptr<SuggestionsStore>(mock_suggestions_store_), @@ -235,6 +235,11 @@ class SuggestionsServiceTest : public testing::Test { .Times(expected_count) .WillRepeatedly(Return(true)); + // Since there are two requests below, Initialize() will be called twice. + EXPECT_CALL(*mock_thumbnail_manager_, + Initialize(EqualsProto(*suggestions_profile))) + .Times(expected_count); + // Expect a call to the blacklist store. Return that there's nothing to // blacklist. EXPECT_CALL(*mock_blacklist_store_, FilterSuggestions(_)) @@ -311,6 +316,7 @@ TEST_F(SuggestionsServiceTest, FetchSuggestionsDataRequestError) { // Set up expectations on the SuggestionsStore. EXPECT_CALL(*mock_suggestions_store_, LoadSuggestions(_)) .WillOnce(Return(true)); + EXPECT_CALL(*mock_thumbnail_manager_, Initialize(_)); // Expect a call to the blacklist store. Return that there's nothing to // blacklist. @@ -384,6 +390,8 @@ TEST_F(SuggestionsServiceTest, BlacklistURL) { EXPECT_CALL(*mock_suggestions_store_, StoreSuggestions(EqualsProto(*suggestions_profile))) .WillOnce(Return(true)); + EXPECT_CALL(*mock_thumbnail_manager_, + Initialize(EqualsProto(*suggestions_profile))); // Expected calls to the blacklist store. EXPECT_CALL(*mock_blacklist_store_, BlacklistUrl(Eq(blacklist_url))) @@ -443,6 +451,10 @@ TEST_F(SuggestionsServiceTest, BlacklistURLFails) { .WillOnce(Return(true)) .WillOnce(DoAll(SetArgPointee<0>(blacklist_url), Return(true))) .WillOnce(Return(false)); + // There will be two calls to Initialize() (one store, one load). + EXPECT_CALL(*mock_thumbnail_manager_, + Initialize(EqualsProto(*suggestions_profile))) + .Times(2); // Send the request. The data will be returned to the callback. suggestions_service->BlacklistURL( |