Chromium Code Reviews| 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..477bdfa3e51dbf89af7cbaf56be39ae5f01ee4fb 100644 |
| --- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc |
| +++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc |
| @@ -19,7 +19,6 @@ |
| #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| #include "chrome/browser/autocomplete/history_url_provider.h" |
| #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| -#include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/history/history_backend.h" |
| #include "chrome/browser/history/history_database.h" |
| #include "chrome/browser/history/history_service.h" |
| @@ -31,6 +30,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" |
| @@ -38,7 +38,6 @@ |
| #include "components/search_engines/search_terms_data.h" |
| #include "components/search_engines/template_url.h" |
| #include "components/search_engines/template_url_service.h" |
| -#include "content/public/browser/notification_service.h" |
| #include "content/public/test/test_browser_thread.h" |
| #include "content/public/test/test_utils.h" |
| #include "sql/transaction.h" |
| @@ -104,6 +103,50 @@ struct TestURLInfo { |
| "83.A6.E4.BD.93.E5.88.B6", "Title Unimportant", 2, 2, 0} |
| }; |
| +// Wait for OnURLsDeletedNotification. |
|
sky
2014/12/11 15:59:54
Waits for OnOURSDeletedNotification and when run q
nshaik
2014/12/12 05:40:55
Done.
|
| +class WaitForURLsDeletedObserver : public history::HistoryServiceObserver { |
| + public: |
| + explicit WaitForURLsDeletedObserver(content::MessageLoopRunner* runner); |
| + ~WaitForURLsDeletedObserver() override; |
| + |
| + private: |
| + // history::HistoryServiceObserver: |
| + void OnURLsDeleted(HistoryService* service, |
| + bool all_history, |
| + bool expired, |
| + const history::URLRows& deleted_rows, |
| + const std::set<GURL>& favicon_urls) override; |
| + // weak |
|
Peter Kasting
2014/12/11 19:59:34
Nit: Blank line above this; also, comments should
nshaik
2014/12/12 05:40:56
Done.
|
| + content::MessageLoopRunner* runner_; |
| +}; |
|
sky
2014/12/11 15:59:54
DISALLOW_...
nshaik
2014/12/12 05:40:56
Done.
|
| + |
| +WaitForURLsDeletedObserver::WaitForURLsDeletedObserver( |
| + content::MessageLoopRunner* runner) |
| + : runner_(runner) { |
| +} |
| + |
| +WaitForURLsDeletedObserver::~WaitForURLsDeletedObserver() { |
| +} |
| + |
| +void WaitForURLsDeletedObserver::OnURLsDeleted( |
| + HistoryService* service, |
| + bool all_history, |
| + bool expired, |
| + const history::URLRows& deleted_rows, |
| + const std::set<GURL>& favicon_urls) { |
| + runner_->Quit(); |
| +} |
| + |
| +void WaitForURLsDeletedNotification(HistoryService* history_service) { |
| + scoped_refptr<content::MessageLoopRunner> runner = |
|
sky
2014/12/11 15:59:54
Why not use a RunLoop on the stack here? Seems sim
sdefresne
2014/12/11 16:04:08
content::MessageLoopRunner is a base::RefCounted a
sky
2014/12/11 17:02:04
I'm suggesting you change this line to:
base::Run
nshaik
2014/12/12 05:40:55
Done.
|
| + 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 +619,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 |