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

Unified Diff: components/ntp_tiles/popular_sites_impl_unittest.cc

Issue 2946143002: Remove legacy popular sites cache cleaning (Closed)
Patch Set: Remove unused imports Created 3 years, 6 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 661cc2441bdd5f1890c07f4a92bb9d2c2abe3d27..419483eb4069272e2b10e0e2d4c39f40f7c3c9f4 100644
--- a/components/ntp_tiles/popular_sites_impl_unittest.cc
+++ b/components/ntp_tiles/popular_sites_impl_unittest.cc
@@ -11,16 +11,12 @@
#include "base/bind.h"
#include "base/command_line.h"
-#include "base/files/file_util.h"
-#include "base/files/important_file_writer.h"
-#include "base/files/scoped_temp_dir.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/optional.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
-#include "base/test/sequenced_worker_pool_owner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/ntp_tiles/constants.h"
@@ -85,14 +81,11 @@ class PopularSitesTest : public ::testing::Test {
{kUrl, "https://www.chromium.org/"},
{kFaviconUrl, "https://www.chromium.org/favicon.ico"},
},
- worker_pool_owner_(2, "PopularSitesTest."),
prefs_(new sync_preferences::TestingPrefServiceSyncable()),
url_fetcher_factory_(nullptr) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableNTPPopularSites);
PopularSitesImpl::RegisterProfilePrefs(prefs_->registry());
- CHECK(scoped_cache_dir_.CreateUniqueTempDir());
- cache_dir_ = scoped_cache_dir_.GetPath();
}
void SetCountryAndVersion(const std::string& country,
@@ -161,9 +154,9 @@ class PopularSitesTest : public ::testing::Test {
std::unique_ptr<PopularSites> CreatePopularSites(
net::URLRequestContextGetter* context) {
return base::MakeUnique<PopularSitesImpl>(
- worker_pool_owner_.pool().get(), prefs_.get(),
+ prefs_.get(),
/*template_url_service=*/nullptr,
- /*variations_service=*/nullptr, context, cache_dir_,
+ /*variations_service=*/nullptr, context,
base::Bind(JsonUnsafeParser::Parse));
}
@@ -172,9 +165,6 @@ class PopularSitesTest : public ::testing::Test {
const TestPopularSite kChromium;
base::MessageLoopForUI ui_loop_;
- base::SequencedWorkerPoolOwner worker_pool_owner_;
- base::ScopedTempDir scoped_cache_dir_;
- base::FilePath cache_dir_;
std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> prefs_;
net::FakeURLFetcherFactory url_fetcher_factory_;
};
@@ -309,22 +299,6 @@ TEST_F(PopularSitesTest, ProvidesDefaultSitesUntilCallbackReturns) {
EXPECT_THAT(popular_sites->sites().size(), Eq(1ul));
}
-TEST_F(PopularSitesTest, ClearsCacheFileFromOldVersions) {
- SetCountryAndVersion("ZZ", "9");
- RespondWithJSON(
- "https://www.gstatic.com/chrome/ntp/suggested_sites_ZZ_9.json",
- {kWikipedia});
-
- PopularSites::SitesVector sites;
- const base::FilePath old_cache_path =
- cache_dir_.AppendASCII("suggested_sites.json");
- CHECK(base::ImportantFileWriter::WriteFileAtomically(old_cache_path,
- "Old cache"));
- FetchPopularSites(/*force_download=*/false, &sites);
- worker_pool_owner_.pool()->FlushForTesting();
- EXPECT_FALSE(base::PathExists(old_cache_path));
-}
-
TEST_F(PopularSitesTest, UsesCachedJson) {
SetCountryAndVersion("ZZ", "9");
RespondWithJSON(
« no previous file with comments | « components/ntp_tiles/popular_sites_impl.cc ('k') | ios/chrome/browser/ntp_tiles/ios_popular_sites_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698