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

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

Issue 773103004: Remove NOTIFICATION_HISTORY_URLS_DELETED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove NotificationObserver from InMemoryURLIndex Created 6 years 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/history_quick_provider_unittest.cc
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index a79c1f3ccd09decf898d09daa4827e51334671f6..5ebbaee2b4ba00d59118e88235deb96e0915c481 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -31,6 +31,7 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
+#include "components/history/core/browser/history_service_observer.h"
#include "components/history/core/browser/url_database.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/omnibox/autocomplete_match.h"
@@ -104,6 +105,46 @@ struct TestURLInfo {
"83.A6.E4.BD.93.E5.88.B6", "Title Unimportant", 2, 2, 0}
};
+// Wait for OnURLsDeletedNotification.
+class WaitForURLsDeletedObserver : public history::HistoryServiceObserver {
+ public:
+ explicit WaitForURLsDeletedObserver(content::MessageLoopRunner* runner);
+ ~WaitForURLsDeletedObserver() override;
+
+ // history::HistoryServiceObserver:
+ void OnURLsDeleted(
+ HistoryService* service,
+ const history::URLsDeletedDetails& deleted_details) override;
+
+ private:
+ // weak
+ content::MessageLoopRunner* runner_;
+};
+
+WaitForURLsDeletedObserver::WaitForURLsDeletedObserver(
+ content::MessageLoopRunner* runner)
+ : runner_(runner) {
+}
+
+WaitForURLsDeletedObserver::~WaitForURLsDeletedObserver() {
+}
+
+void WaitForURLsDeletedObserver::OnURLsDeleted(
+ HistoryService* service,
+ const history::URLsDeletedDetails& deleted_details) {
+ runner_->Quit();
+}
+
+void WaitForURLsDeletedNotification(HistoryService* history_service) {
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ WaitForURLsDeletedObserver observer(runner.get());
+ ScopedObserver<HistoryService, history::HistoryServiceObserver>
+ scoped_observer(&observer);
+ scoped_observer.Add(history_service);
+ runner->Run();
+}
+
class HistoryQuickProviderTest : public testing::Test {
public:
HistoryQuickProviderTest()
@@ -576,10 +617,7 @@ TEST_F(HistoryQuickProviderTest, DeleteMatch) {
// InMemoryURLIndex) will drop any data they might have pertaining to the URL.
// To ensure that the deletion has been propagated everywhere before we start
// verifying post-deletion states, first wait until we see the notification.
- content::WindowedNotificationObserver observer(
- chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- content::NotificationService::AllSources());
- observer.Wait();
+ WaitForURLsDeletedNotification(history_service_);
EXPECT_FALSE(history_backend()->GetURL(test_url, NULL));
// Just to be on the safe side, explicitly verify that we have deleted enough

Powered by Google App Engine
This is Rietveld 408576698