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

Unified Diff: components/ntp_tiles/popular_sites_impl_unittest.cc

Issue 2695713004: Add baked-in favicons for default popular sites on NTP (Closed)
Patch Set: Have python script adhere to guidelines Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_tiles/popular_sites_impl_unittest.cc
diff --git a/components/ntp_tiles/popular_sites_impl_unittest.cc b/components/ntp_tiles/popular_sites_impl_unittest.cc
index 6732e27cc0cca77c40ede17e986c36bc0622432b..32450260d2ea0e3230e1cf345d4f9dc3d8fea8cd 100644
--- a/components/ntp_tiles/popular_sites_impl_unittest.cc
+++ b/components/ntp_tiles/popular_sites_impl_unittest.cc
@@ -6,6 +6,7 @@
#include <map>
#include <string>
+#include <unordered_set>
#include <utility>
#include <vector>
@@ -21,6 +22,7 @@
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
+#include "components/ntp_tiles/icon_cacher.h"
#include "components/ntp_tiles/json_unsafe_parser.h"
#include "components/ntp_tiles/pref_names.h"
#include "components/ntp_tiles/switches.h"
@@ -63,6 +65,25 @@ size_t GetNumberOfDefaultPopularSitesForPlatform() {
#endif
}
+class FakeIconCacher : public IconCacher {
+ public:
+ FakeIconCacher() {}
+ ~FakeIconCacher() override {}
+
+ void StartFetch(PopularSites::Site site,
+ const base::Callback<void(bool)>& done) override {}
+
+ void AddDefaultImage(const PopularSites::Site& site,
+ int image_resource_id) override {
+ registered_sites_.insert(site.url.spec());
+ }
+
+ size_t GetRegisteredSitesCount() const { return registered_sites_.size(); }
+
+ private:
+ std::unordered_set<std::string> registered_sites_;
+};
+
class PopularSitesTest : public ::testing::Test {
protected:
PopularSitesTest()
@@ -234,6 +255,13 @@ TEST_F(PopularSitesTest, PopulatesWithDefaultResoucesOnFailure) {
EXPECT_THAT(sites.size(), Eq(GetNumberOfDefaultPopularSitesForPlatform()));
}
+TEST_F(PopularSitesTest, AddsIconUrlsToIconCacher) {
+ auto icon_cacher = base::MakeUnique<FakeIconCacher>();
+ PopularSitesImpl::AddIconsForDefaultPagesToCacher(prefs_, icon_cacher.get());
+ EXPECT_THAT(icon_cacher->GetRegisteredSitesCount(),
+ Eq(GetNumberOfDefaultPopularSitesForPlatform()));
+}
+
TEST_F(PopularSitesTest, ProvidesDefaultSitesUntilCallbackReturns) {
SetCountryAndVersion("ZZ", "9");
RespondWithJSON(

Powered by Google App Engine
This is Rietveld 408576698