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

Unified Diff: chrome/browser/history/history_backend_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/history/history_backend_unittest.cc
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index cbbcac4260dd0f54948363db0946dc46a7fe4bac..472ee1224381f9d0f612ef7b834265737f2c4c32 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -32,6 +32,7 @@
#include "chrome/common/importer/imported_favicon_usage.h"
#include "chrome/test/base/testing_profile.h"
#include "components/history/core/browser/history_constants.h"
+#include "components/history/core/browser/history_service_observer.h"
#include "components/history/core/browser/in_memory_database.h"
#include "components/history/core/browser/keyword_search_term.h"
#include "components/history/core/test/history_client_fake_bookmarks.h"
@@ -126,6 +127,8 @@ class HistoryBackendTestDelegate : public HistoryBackend::Delegate {
const RedirectList& redirects,
base::Time visit_time) override;
void NotifyURLsModified(const URLRows& changed_urls) override;
+ void NotifyURLsDeleted(
+ const history::URLsDeletedDetails& deleted_details) override;
void BroadcastNotifications(int type,
scoped_ptr<HistoryDetails> details) override;
void DBLoaded() override;
@@ -142,6 +145,7 @@ class HistoryBackendTestBase : public testing::Test {
typedef std::vector<std::pair<int, HistoryDetails*> > NotificationList;
sdefresne 2014/12/04 17:21:13 This is no longer used, remove.
nshaik 2014/12/07 09:34:49 Done.
typedef std::vector<std::pair<ui::PageTransition, URLRow>> URLVisitedList;
typedef std::vector<URLRows> URLsModifiedList;
+ typedef std::vector<history::URLsDeletedDetails> URLsDeletedList;
HistoryBackendTestBase()
: loaded_(false),
@@ -177,6 +181,10 @@ class HistoryBackendTestBase : public testing::Test {
return urls_modified_notifications_;
}
+ const URLsDeletedList& urls_deleted_notifications() const {
+ return urls_deleted_notifications_;
+ }
+
int num_broadcasted_notifications() const {
sdefresne 2014/12/04 17:21:12 This is no longer used, remove.
nshaik 2014/12/07 09:34:49 Done.
return broadcasted_notifications_.size();
}
@@ -214,6 +222,11 @@ class HistoryBackendTestBase : public testing::Test {
urls_modified_notifications_.push_back(changed_urls);
}
+ void NotifyURLsDeleted(const history::URLsDeletedDetails& deleted_details) {
+ mem_backend_->OnURLsDeleted(nullptr, deleted_details);
+ urls_deleted_notifications_.push_back(deleted_details);
+ }
+
void BroadcastNotifications(int type, scoped_ptr<HistoryDetails> details) {
// Send the notifications directly to the in-memory database.
content::Details<HistoryDetails> det(details.get());
sdefresne 2014/12/04 17:21:12 This method should not longer be called, please de
nshaik 2014/12/07 09:34:50 I think this is still needed for chrome::NOTIFICAT
@@ -263,6 +276,7 @@ class HistoryBackendTestBase : public testing::Test {
int favicon_changed_notifications_;
URLVisitedList url_visited_notifications_;
URLsModifiedList urls_modified_notifications_;
+ URLsDeletedList urls_deleted_notifications_;
base::MessageLoop message_loop_;
base::FilePath test_dir_;
@@ -293,6 +307,11 @@ void HistoryBackendTestDelegate::NotifyURLsModified(
test_->NotifyURLsModified(changed_urls);
}
+void HistoryBackendTestDelegate::NotifyURLsDeleted(
+ const history::URLsDeletedDetails& deleted_details) {
+ test_->NotifyURLsDeleted(deleted_details);
+}
+
void HistoryBackendTestDelegate::BroadcastNotifications(
int type,
scoped_ptr<HistoryDetails> details) {
@@ -466,20 +485,17 @@ class InMemoryHistoryBackendTest : public HistoryBackendTestBase {
~InMemoryHistoryBackendTest() override {}
protected:
- void SimulateNotification(int type,
- const URLRow* row1,
- const URLRow* row2 = NULL,
- const URLRow* row3 = NULL) {
- DCHECK(type == chrome::NOTIFICATION_HISTORY_URLS_DELETED);
-
+ void SimulateNotificationURLsDeleted(const URLRow* row1,
+ const URLRow* row2 = NULL,
+ const URLRow* row3 = NULL) {
URLRows rows;
rows.push_back(*row1);
if (row2) rows.push_back(*row2);
if (row3) rows.push_back(*row3);
- scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails());
- details->rows = rows;
- BroadcastNotifications(type, details.Pass());
+ URLsDeletedDetails details;
+ details.rows = rows;
+ NotifyURLsDeleted(details);
}
size_t GetNumberOfMatchingSearchTerms(const int keyword_id,
@@ -682,13 +698,10 @@ TEST_F(HistoryBackendTest, DeleteAll) {
EXPECT_TRUE(history_client_.IsBookmarked(row1.url()));
// Check that we fire the notification about all history having been deleted.
- ASSERT_EQ(1u, broadcasted_notifications().size());
- ASSERT_EQ(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- broadcasted_notifications()[0].first);
- const URLsDeletedDetails* details = static_cast<const URLsDeletedDetails*>(
- broadcasted_notifications()[0].second);
- EXPECT_TRUE(details->all_history);
- EXPECT_FALSE(details->expired);
+ ASSERT_EQ(1u, urls_deleted_notifications().size());
+ const URLsDeletedDetails& details = urls_deleted_notifications()[0];
+ EXPECT_TRUE(details.all_history);
+ EXPECT_FALSE(details.expired);
}
// Checks that adding a visit, then calling DeleteAll, and then trying to add
@@ -3135,8 +3148,7 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedPiecewise) {
// Notify the in-memory database that the second typed URL and the non-typed
// URL has been deleted.
- SimulateNotification(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- &row2, &row3);
+ SimulateNotificationURLsDeleted(&row2, &row3);
// Expect that the first typed URL remains intact, the second typed URL is
// correctly removed, and the non-typed URL does not magically appear.
@@ -3155,10 +3167,9 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedEnMasse) {
SimulateNotificationURLsModified(mem_backend_.get(), &row1, &row2, &row3);
// Now notify the in-memory database that all history has been deleted.
- scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails());
- details->all_history = true;
- BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- details.Pass());
+ URLsDeletedDetails details;
+ details.all_history = true;
+ mem_backend_->OnURLsDeleted(nullptr, details);
// Expect that everything goes away.
EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row1.url(), NULL));
@@ -3268,7 +3279,7 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedWithSearchTerms) {
PopulateTestURLsAndSearchTerms(&row1, &row2, term1, term2);
// Notify the in-memory database that the second typed URL has been deleted.
- SimulateNotification(chrome::NOTIFICATION_HISTORY_URLS_DELETED, &row2);
+ SimulateNotificationURLsDeleted(&row2);
// Verify that the second term is no longer returned as result, and also check
// at the low level that it is gone for good. The term corresponding to the

Powered by Google App Engine
This is Rietveld 408576698