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

Unified Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ScopedObserver to InMemoryHistoryBackend,PrerenderLocalPredictor,ChromeTemplateURLServiceClient Created 6 years, 1 month 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/ui/omnibox/omnibox_view_browsertest.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index 1ca983ce8810e1a3393c97517ade6a88181619a7..d68ace92444863406a73c1b7778948fc16739708 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -141,6 +141,14 @@ const int kCtrlOrCmdMask = ui::EF_CONTROL_DOWN;
class OmniboxViewTest : public InProcessBrowserTest,
public content::NotificationObserver,
public history::HistoryServiceObserver {
+ public:
+ OmniboxViewTest() : observer_(this) {}
+
+ // history::HisoryServiceObserver
+ void OnHistoryServiceLoaded(HistoryService* history_service) override {
+ base::MessageLoop::current()->Quit();
+ }
+
protected:
void SetUpOnMainThread() override {
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
@@ -285,9 +293,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
ASSERT_TRUE(history_service);
if (!history_service->BackendLoaded()) {
- content::NotificationRegistrar registrar;
- registrar.Add(this, chrome::NOTIFICATION_HISTORY_LOADED,
- content::Source<Profile>(profile));
+ observer_.Add(history_service);
content::RunMessageLoop();
}
@@ -349,7 +355,6 @@ class OmniboxViewTest : public InProcessBrowserTest,
case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
case chrome::NOTIFICATION_TAB_PARENTED:
case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY:
- case chrome::NOTIFICATION_HISTORY_LOADED:
break;
default:
FAIL() << "Unexpected notification type";
@@ -361,6 +366,11 @@ class OmniboxViewTest : public InProcessBrowserTest,
const history::URLRows& changed_urls) override {
base::MessageLoop::current()->Quit();
}
+
+ private:
+ ScopedObserver<HistoryService, OmniboxViewTest> observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(OmniboxViewTest);
};
// Test if ctrl-* accelerators are workable in omnibox.

Powered by Google App Engine
This is Rietveld 408576698