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

Unified Diff: chrome/test/base/testing_profile.cc

Issue 441623002: Eliminate sending NOTIFICATION_TOP_SITES_* from TopSites (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix incorrect parmeter being passed in notification Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/top_sites_impl_unittest.cc ('k') | components/history.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_profile.cc
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 84aa2519a04bdd64e3d25238ac7553df235557ec..1cdfbf7e74b7ca55d7e14e046d7a605d5a867b7f 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -53,6 +53,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/common/bookmark_constants.h"
+#include "components/history/core/browser/top_sites_observer.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/policy/core/common/policy_service.h"
#include "components/user_prefs/user_prefs.h"
@@ -105,6 +106,21 @@ using testing::Return;
namespace {
+// Used to make sure TopSites has finished loading
+class WaitTopSitesLoadedObserver : public history::TopSitesObserver {
+ public:
+ explicit WaitTopSitesLoadedObserver(content::MessageLoopRunner* runner)
+ : runner_(runner) {}
+ virtual void TopSitesLoaded(history::TopSites* top_sites) OVERRIDE {
+ runner_->Quit();
+ }
+ virtual void TopSitesChanged(history::TopSites* top_sites) OVERRIDE {}
+
+ private:
+ // weak
+ content::MessageLoopRunner* runner_;
+};
+
// Task used to make sure history has finished processing a request. Intended
// for use with BlockUntilHistoryProcessesPendingRequests.
@@ -536,7 +552,9 @@ static KeyedService* BuildChromeBookmarkClient(
static KeyedService* BuildChromeHistoryClient(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
- return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile));
+ return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile),
+ profile,
+ profile->GetTopSites());
}
void TestingProfile::CreateBookmarkModel(bool delete_file) {
@@ -582,10 +600,12 @@ void TestingProfile::BlockUntilHistoryIndexIsRefreshed() {
// TODO(phajdan.jr): Doesn't this hang if Top Sites are already loaded?
void TestingProfile::BlockUntilTopSitesLoaded() {
- content::WindowedNotificationObserver top_sites_loaded_observer(
- chrome::NOTIFICATION_TOP_SITES_LOADED,
- content::NotificationService::AllSources());
- top_sites_loaded_observer.Wait();
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ WaitTopSitesLoadedObserver observer(runner.get());
+ top_sites_->AddObserver(&observer);
+ runner->Run();
+ top_sites_->RemoveObserver(&observer);
}
void TestingProfile::SetGuestSession(bool guest) {
« no previous file with comments | « chrome/browser/history/top_sites_impl_unittest.cc ('k') | components/history.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698