| 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(
|
|
|