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

Unified Diff: chrome/browser/autocomplete/zero_suggest_provider_unittest.cc

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra inclusion from testing_profile.h Created 5 years, 11 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: chrome/browser/autocomplete/zero_suggest_provider_unittest.cc
diff --git a/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc b/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc
index e79c849545dc041a4e087d02a95333308b5ec91c..1c4085d51b435c8fd63b78511066c673d3318167 100644
--- a/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc
+++ b/chrome/browser/autocomplete/zero_suggest_provider_unittest.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/history/top_sites_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
@@ -64,7 +65,6 @@ class FakeEmptyTopSites : public history::TopSites {
return false;
}
void ClearBlacklistedURLs() override {}
- void Shutdown() override {}
base::CancelableTaskTracker::TaskId StartQueryForMostVisited() override {
return 0;
}
@@ -90,6 +90,10 @@ class FakeEmptyTopSites : public history::TopSites {
bool AddForcedURL(const GURL& url, const base::Time& time) override {
return false;
}
+
+ // RefcountedKeyedService:
+ void ShutdownOnUIThread() override {}
+
// content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
@@ -109,6 +113,12 @@ void FakeEmptyTopSites::GetMostVisitedURLs(
mv_callback = callback;
}
+scoped_refptr<RefcountedKeyedService> BuildFakeEmptyTopSites(
+ content::BrowserContext* profile) {
+ scoped_refptr<history::TopSites> top_sites = new FakeEmptyTopSites();
+ return top_sites;
+}
+
} // namespace
@@ -175,8 +185,9 @@ void ZeroSuggestProviderTest::SetUp() {
turl_model->Add(default_t_url_);
turl_model->SetUserSelectedDefaultSearchProvider(default_t_url_);
- profile_.SetTopSites(new FakeEmptyTopSites());
-
+ profile_.DestroyTopSites();
+ TopSitesFactory::GetInstance()->SetTestingFactory(&profile_,
+ BuildFakeEmptyTopSites);
provider_ = ZeroSuggestProvider::Create(this, turl_model, &profile_);
}
@@ -264,8 +275,9 @@ TEST_F(ZeroSuggestProviderTest, TestMostVisitedCallback) {
provider_->Start(input, false, true);
EXPECT_TRUE(provider_->matches().empty());
- static_cast<FakeEmptyTopSites*>(profile_.GetTopSites())->mv_callback.Run(
- urls);
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesFactory::GetForProfile(&profile_);
+ static_cast<FakeEmptyTopSites*>(top_sites.get())->mv_callback.Run(urls);
// Should have verbatim match + most visited url match.
EXPECT_EQ(2U, provider_->matches().size());
provider_->Stop(false);
@@ -275,8 +287,7 @@ TEST_F(ZeroSuggestProviderTest, TestMostVisitedCallback) {
EXPECT_TRUE(provider_->matches().empty());
// Most visited results arriving after Stop() has been called, ensure they
// are not displayed.
- static_cast<FakeEmptyTopSites*>(profile_.GetTopSites())->mv_callback.Run(
- urls);
+ static_cast<FakeEmptyTopSites*>(top_sites.get())->mv_callback.Run(urls);
EXPECT_TRUE(provider_->matches().empty());
}
@@ -316,8 +327,9 @@ TEST_F(ZeroSuggestProviderTest, TestMostVisitedNavigateToSearchPage) {
provider_->Start(srp_input, false, true);
EXPECT_TRUE(provider_->matches().empty());
// Most visited results arriving after a new request has been started.
- static_cast<FakeEmptyTopSites*>(profile_.GetTopSites())->mv_callback.Run(
- urls);
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesFactory::GetForProfile(&profile_);
+ static_cast<FakeEmptyTopSites*>(top_sites.get())->mv_callback.Run(urls);
EXPECT_TRUE(provider_->matches().empty());
}
« no previous file with comments | « chrome/browser/autocomplete/zero_suggest_provider.cc ('k') | chrome/browser/devtools/browser_list_tabcontents_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698