Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: components/suggestions/suggestions_service_unittest.cc

Issue 1314493013: Popular sites on the NTP: add thumbnails! (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android_clang_dbg_recipe build Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/suggestions/suggestions_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/suggestions/suggestions_service.h" 5 #include "components/suggestions/suggestions_service.h"
6 6
7 #include <map> 7 #include <map>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 }; 128 };
129 129
130 class MockImageManager : public suggestions::ImageManager { 130 class MockImageManager : public suggestions::ImageManager {
131 public: 131 public:
132 MockImageManager() {} 132 MockImageManager() {}
133 virtual ~MockImageManager() {} 133 virtual ~MockImageManager() {}
134 MOCK_METHOD1(Initialize, void(const SuggestionsProfile&)); 134 MOCK_METHOD1(Initialize, void(const SuggestionsProfile&));
135 MOCK_METHOD2(GetImageForURL, 135 MOCK_METHOD2(GetImageForURL,
136 void(const GURL&, 136 void(const GURL&,
137 base::Callback<void(const GURL&, const SkBitmap*)>)); 137 base::Callback<void(const GURL&, const SkBitmap*)>));
138 MOCK_METHOD2(AddImageURL, void(const GURL&, const GURL&));
138 }; 139 };
139 140
140 class MockBlacklistStore : public suggestions::BlacklistStore { 141 class MockBlacklistStore : public suggestions::BlacklistStore {
141 public: 142 public:
142 MOCK_METHOD1(BlacklistUrl, bool(const GURL&)); 143 MOCK_METHOD1(BlacklistUrl, bool(const GURL&));
143 MOCK_METHOD0(IsEmpty, bool()); 144 MOCK_METHOD0(IsEmpty, bool());
144 MOCK_METHOD1(GetTimeUntilReadyForUpload, bool(base::TimeDelta*)); 145 MOCK_METHOD1(GetTimeUntilReadyForUpload, bool(base::TimeDelta*));
145 MOCK_METHOD2(GetTimeUntilURLReadyForUpload, 146 MOCK_METHOD2(GetTimeUntilURLReadyForUpload,
146 bool(const GURL&, base::TimeDelta*)); 147 bool(const GURL&, base::TimeDelta*));
147 MOCK_METHOD1(GetCandidateForUpload, bool(GURL*)); 148 MOCK_METHOD1(GetCandidateForUpload, bool(GURL*));
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 TEST_F(SuggestionsServiceTest, CheckDefaultTimeStamps) { 626 TEST_F(SuggestionsServiceTest, CheckDefaultTimeStamps) {
626 scoped_ptr<SuggestionsService> suggestions_service( 627 scoped_ptr<SuggestionsService> suggestions_service(
627 CreateSuggestionsServiceWithMocks()); 628 CreateSuggestionsServiceWithMocks());
628 SuggestionsProfile suggestions = 629 SuggestionsProfile suggestions =
629 CreateSuggestionsProfileWithExpiryTimestamps(); 630 CreateSuggestionsProfileWithExpiryTimestamps();
630 suggestions_service->SetDefaultExpiryTimestamp(&suggestions, 631 suggestions_service->SetDefaultExpiryTimestamp(&suggestions,
631 kTestDefaultExpiry); 632 kTestDefaultExpiry);
632 EXPECT_EQ(kTestSetExpiry, suggestions.suggestions(0).expiry_ts()); 633 EXPECT_EQ(kTestSetExpiry, suggestions.suggestions(0).expiry_ts());
633 EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts()); 634 EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts());
634 } 635 }
636
637 TEST_F(SuggestionsServiceTest, GetPageThumbnail) {
638 scoped_ptr<SuggestionsService> suggestions_service(
639 CreateSuggestionsServiceWithMocks());
640 ASSERT_TRUE(suggestions_service != NULL);
641
642 GURL test_url(kTestUrl);
643 GURL thumbnail_url("https://www.thumbnails.com/thumb.jpg");
644 base::Callback<void(const GURL&, const SkBitmap*)> dummy_callback;
645
646 EXPECT_CALL(*mock_thumbnail_manager_, GetImageForURL(test_url, _));
647 suggestions_service->GetPageThumbnail(test_url, dummy_callback);
648
649 EXPECT_CALL(*mock_thumbnail_manager_, AddImageURL(test_url, thumbnail_url));
650 EXPECT_CALL(*mock_thumbnail_manager_, GetImageForURL(test_url, _));
651 suggestions_service->GetPageThumbnailWithURL(test_url, thumbnail_url,
652 dummy_callback);
653
654 }
655
635 } // namespace suggestions 656 } // namespace suggestions
OLDNEW
« no previous file with comments | « components/suggestions/suggestions_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698