| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 19 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 20 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 21 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 namespace { | 53 namespace { |
| 53 | 54 |
| 54 const int kTinyEdgeSize = 10; | 55 const int kTinyEdgeSize = 10; |
| 55 const int kSmallEdgeSize = 16; | 56 const int kSmallEdgeSize = 16; |
| 56 const int kLargeEdgeSize = 32; | 57 const int kLargeEdgeSize = 32; |
| 57 | 58 |
| 58 const gfx::Size kTinySize = gfx::Size(kTinyEdgeSize, kTinyEdgeSize); | 59 const gfx::Size kTinySize = gfx::Size(kTinyEdgeSize, kTinyEdgeSize); |
| 59 const gfx::Size kSmallSize = gfx::Size(kSmallEdgeSize, kSmallEdgeSize); | 60 const gfx::Size kSmallSize = gfx::Size(kSmallEdgeSize, kSmallEdgeSize); |
| 60 const gfx::Size kLargeSize = gfx::Size(kLargeEdgeSize, kLargeEdgeSize); | 61 const gfx::Size kLargeSize = gfx::Size(kLargeEdgeSize, kLargeEdgeSize); |
| 61 | 62 |
| 63 typedef base::Callback<void(const history::URLRow*, |
| 64 const history::URLRow*, |
| 65 const history::URLRow*)> |
| 66 SimulateNotificationCallback; |
| 67 |
| 62 // Comparison functions as to make it easier to check results of | 68 // Comparison functions as to make it easier to check results of |
| 63 // GetFaviconBitmaps() and GetIconMappingsForPageURL(). | 69 // GetFaviconBitmaps() and GetIconMappingsForPageURL(). |
| 64 bool IconMappingLessThan(const history::IconMapping& a, | 70 bool IconMappingLessThan(const history::IconMapping& a, |
| 65 const history::IconMapping& b) { | 71 const history::IconMapping& b) { |
| 66 return a.icon_url < b.icon_url; | 72 return a.icon_url < b.icon_url; |
| 67 } | 73 } |
| 68 | 74 |
| 69 bool FaviconBitmapLessThan(const history::FaviconBitmap& a, | 75 bool FaviconBitmapLessThan(const history::FaviconBitmap& a, |
| 70 const history::FaviconBitmap& b) { | 76 const history::FaviconBitmap& b) { |
| 71 return a.pixel_size.GetArea() < b.pixel_size.GetArea(); | 77 return a.pixel_size.GetArea() < b.pixel_size.GetArea(); |
| 72 } | 78 } |
| 73 | 79 |
| 74 class HistoryClientMock : public history::HistoryClientFakeBookmarks { | 80 class HistoryClientMock : public history::HistoryClientFakeBookmarks { |
| 75 public: | 81 public: |
| 76 MOCK_METHOD0(BlockUntilBookmarksLoaded, void()); | 82 MOCK_METHOD0(BlockUntilBookmarksLoaded, void()); |
| 77 }; | 83 }; |
| 78 | 84 |
| 85 void SimulateNotificationURLVisited(history::HistoryServiceObserver* observer, |
| 86 const history::URLRow* row1, |
| 87 const history::URLRow* row2, |
| 88 const history::URLRow* row3) { |
| 89 history::URLRows rows; |
| 90 rows.push_back(*row1); |
| 91 if (row2) |
| 92 rows.push_back(*row2); |
| 93 if (row3) |
| 94 rows.push_back(*row3); |
| 95 |
| 96 base::Time visit_time; |
| 97 history::RedirectList redirects; |
| 98 for (const auto& row : rows) { |
| 99 observer->OnURLVisited( |
| 100 nullptr, ui::PAGE_TRANSITION_LINK, row, redirects, visit_time); |
| 101 } |
| 102 } |
| 103 |
| 79 } // namespace | 104 } // namespace |
| 80 | 105 |
| 81 namespace history { | 106 namespace history { |
| 82 | 107 |
| 83 class HistoryBackendTestBase; | 108 class HistoryBackendTestBase; |
| 84 | 109 |
| 85 // This must be a separate object since HistoryBackend manages its lifetime. | 110 // This must be a separate object since HistoryBackend manages its lifetime. |
| 86 // This just forwards the messages we're interested in to the test object. | 111 // This just forwards the messages we're interested in to the test object. |
| 87 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { | 112 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { |
| 88 public: | 113 public: |
| 89 explicit HistoryBackendTestDelegate(HistoryBackendTestBase* test) | 114 explicit HistoryBackendTestDelegate(HistoryBackendTestBase* test) |
| 90 : test_(test) {} | 115 : test_(test) {} |
| 91 | 116 |
| 92 virtual void NotifyProfileError(sql::InitStatus init_status) override {} | 117 virtual void NotifyProfileError(sql::InitStatus init_status) override {} |
| 93 virtual void SetInMemoryBackend( | 118 virtual void SetInMemoryBackend( |
| 94 scoped_ptr<InMemoryHistoryBackend> backend) override; | 119 scoped_ptr<InMemoryHistoryBackend> backend) override; |
| 95 virtual void NotifyAddVisit(const BriefVisitInfo& info) override {} | 120 virtual void NotifyAddVisit(const BriefVisitInfo& info) override {} |
| 96 virtual void NotifyFaviconChanged(const std::set<GURL>& urls) override; | 121 virtual void NotifyFaviconChanged(const std::set<GURL>& urls) override; |
| 122 virtual void NotifyURLVisited(ui::PageTransition transition, |
| 123 const URLRow& row, |
| 124 const RedirectList& redirects, |
| 125 base::Time visit_time) override; |
| 97 virtual void BroadcastNotifications( | 126 virtual void BroadcastNotifications( |
| 98 int type, | 127 int type, |
| 99 scoped_ptr<HistoryDetails> details) override; | 128 scoped_ptr<HistoryDetails> details) override; |
| 100 virtual void DBLoaded() override; | 129 virtual void DBLoaded() override; |
| 101 | 130 |
| 102 private: | 131 private: |
| 103 // Not owned by us. | 132 // Not owned by us. |
| 104 HistoryBackendTestBase* test_; | 133 HistoryBackendTestBase* test_; |
| 105 | 134 |
| 106 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); | 135 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 void HistoryBackendTestDelegate::SetInMemoryBackend( | 235 void HistoryBackendTestDelegate::SetInMemoryBackend( |
| 207 scoped_ptr<InMemoryHistoryBackend> backend) { | 236 scoped_ptr<InMemoryHistoryBackend> backend) { |
| 208 test_->SetInMemoryBackend(backend.Pass()); | 237 test_->SetInMemoryBackend(backend.Pass()); |
| 209 } | 238 } |
| 210 | 239 |
| 211 void HistoryBackendTestDelegate::NotifyFaviconChanged( | 240 void HistoryBackendTestDelegate::NotifyFaviconChanged( |
| 212 const std::set<GURL>& changed_favicons) { | 241 const std::set<GURL>& changed_favicons) { |
| 213 test_->NotifyFaviconChanged(changed_favicons); | 242 test_->NotifyFaviconChanged(changed_favicons); |
| 214 } | 243 } |
| 215 | 244 |
| 245 void HistoryBackendTestDelegate::NotifyURLVisited(ui::PageTransition transition, |
| 246 const URLRow& row, |
| 247 const RedirectList& redirects, |
| 248 base::Time visit_time) { |
| 249 scoped_ptr<URLVisitedDetails> details(new URLVisitedDetails()); |
| 250 details->transition = transition; |
| 251 details->row = row; |
| 252 details->redirects = redirects; |
| 253 details->visit_time = visit_time; |
| 254 test_->BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URL_VISITED, |
| 255 details.Pass()); |
| 256 } |
| 257 |
| 216 void HistoryBackendTestDelegate::BroadcastNotifications( | 258 void HistoryBackendTestDelegate::BroadcastNotifications( |
| 217 int type, | 259 int type, |
| 218 scoped_ptr<HistoryDetails> details) { | 260 scoped_ptr<HistoryDetails> details) { |
| 219 test_->BroadcastNotifications(type, details.Pass()); | 261 test_->BroadcastNotifications(type, details.Pass()); |
| 220 } | 262 } |
| 221 | 263 |
| 222 void HistoryBackendTestDelegate::DBLoaded() { | 264 void HistoryBackendTestDelegate::DBLoaded() { |
| 223 test_->loaded_ = true; | 265 test_->loaded_ = true; |
| 224 } | 266 } |
| 225 | 267 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 415 |
| 374 private: | 416 private: |
| 375 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTest); | 417 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTest); |
| 376 }; | 418 }; |
| 377 | 419 |
| 378 class InMemoryHistoryBackendTest : public HistoryBackendTestBase { | 420 class InMemoryHistoryBackendTest : public HistoryBackendTestBase { |
| 379 public: | 421 public: |
| 380 InMemoryHistoryBackendTest() {} | 422 InMemoryHistoryBackendTest() {} |
| 381 virtual ~InMemoryHistoryBackendTest() {} | 423 virtual ~InMemoryHistoryBackendTest() {} |
| 382 | 424 |
| 383 protected: | 425 // Public so that the method can be bound in test fixture using |
| 426 // base::Bind(&InMemoryHistoryBackendTest::SimulateNotification, ...). |
| 384 void SimulateNotification(int type, | 427 void SimulateNotification(int type, |
| 385 const URLRow* row1, | 428 const URLRow* row1, |
| 386 const URLRow* row2 = NULL, | 429 const URLRow* row2 = NULL, |
| 387 const URLRow* row3 = NULL) { | 430 const URLRow* row3 = NULL) { |
| 388 URLRows rows; | 431 URLRows rows; |
| 389 rows.push_back(*row1); | 432 rows.push_back(*row1); |
| 390 if (row2) rows.push_back(*row2); | 433 if (row2) rows.push_back(*row2); |
| 391 if (row3) rows.push_back(*row3); | 434 if (row3) rows.push_back(*row3); |
| 392 | 435 |
| 393 if (type == chrome::NOTIFICATION_HISTORY_URLS_MODIFIED) { | 436 if (type == chrome::NOTIFICATION_HISTORY_URLS_MODIFIED) { |
| 394 scoped_ptr<URLsModifiedDetails> details(new URLsModifiedDetails()); | 437 scoped_ptr<URLsModifiedDetails> details(new URLsModifiedDetails()); |
| 395 details->changed_urls.swap(rows); | 438 details->changed_urls.swap(rows); |
| 396 BroadcastNotifications(type, details.PassAs<HistoryDetails>()); | 439 BroadcastNotifications(type, details.PassAs<HistoryDetails>()); |
| 397 } else if (type == chrome::NOTIFICATION_HISTORY_URL_VISITED) { | 440 } else if (type == chrome::NOTIFICATION_HISTORY_URL_VISITED) { |
| 398 for (URLRows::const_iterator it = rows.begin(); it != rows.end(); ++it) { | 441 for (URLRows::const_iterator it = rows.begin(); it != rows.end(); ++it) { |
| 399 scoped_ptr<URLVisitedDetails> details(new URLVisitedDetails()); | 442 scoped_ptr<URLVisitedDetails> details(new URLVisitedDetails()); |
| 400 details->row = *it; | 443 details->row = *it; |
| 401 BroadcastNotifications(type, details.PassAs<HistoryDetails>()); | 444 BroadcastNotifications(type, details.PassAs<HistoryDetails>()); |
| 402 } | 445 } |
| 403 } else if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { | 446 } else if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { |
| 404 scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails()); | 447 scoped_ptr<URLsDeletedDetails> details(new URLsDeletedDetails()); |
| 405 details->rows = rows; | 448 details->rows = rows; |
| 406 BroadcastNotifications(type, details.PassAs<HistoryDetails>()); | 449 BroadcastNotifications(type, details.PassAs<HistoryDetails>()); |
| 407 } else { | 450 } else { |
| 408 NOTREACHED(); | 451 NOTREACHED(); |
| 409 } | 452 } |
| 410 } | 453 } |
| 411 | 454 |
| 455 protected: |
| 412 size_t GetNumberOfMatchingSearchTerms(const int keyword_id, | 456 size_t GetNumberOfMatchingSearchTerms(const int keyword_id, |
| 413 const base::string16& prefix) { | 457 const base::string16& prefix) { |
| 414 std::vector<KeywordSearchTermVisit> matching_terms; | 458 std::vector<KeywordSearchTermVisit> matching_terms; |
| 415 mem_backend_->db()->GetMostRecentKeywordSearchTerms( | 459 mem_backend_->db()->GetMostRecentKeywordSearchTerms( |
| 416 keyword_id, prefix, 1, &matching_terms); | 460 keyword_id, prefix, 1, &matching_terms); |
| 417 return matching_terms.size(); | 461 return matching_terms.size(); |
| 418 } | 462 } |
| 419 | 463 |
| 420 static URLRow CreateTestTypedURL() { | 464 static URLRow CreateTestTypedURL() { |
| 421 URLRow url_row(GURL("https://www.google.com/")); | 465 URLRow url_row(GURL("https://www.google.com/")); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 444 url_row.set_visit_count(5); | 488 url_row.set_visit_count(5); |
| 445 url_row.set_last_visit(Time::Now() - base::TimeDelta::FromHours(3)); | 489 url_row.set_last_visit(Time::Now() - base::TimeDelta::FromHours(3)); |
| 446 return url_row; | 490 return url_row; |
| 447 } | 491 } |
| 448 | 492 |
| 449 void PopulateTestURLsAndSearchTerms(URLRow* row1, | 493 void PopulateTestURLsAndSearchTerms(URLRow* row1, |
| 450 URLRow* row2, | 494 URLRow* row2, |
| 451 const base::string16& term1, | 495 const base::string16& term1, |
| 452 const base::string16& term2); | 496 const base::string16& term2); |
| 453 | 497 |
| 454 void TestAddingAndChangingURLRows(int notification_type); | 498 void TestAddingAndChangingURLRows( |
| 499 const SimulateNotificationCallback& callback); |
| 455 | 500 |
| 456 static const KeywordID kTestKeywordId; | 501 static const KeywordID kTestKeywordId; |
| 457 static const char kTestSearchTerm1[]; | 502 static const char kTestSearchTerm1[]; |
| 458 static const char kTestSearchTerm2[]; | 503 static const char kTestSearchTerm2[]; |
| 459 | 504 |
| 460 private: | 505 private: |
| 461 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackendTest); | 506 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackendTest); |
| 462 }; | 507 }; |
| 463 | 508 |
| 464 const KeywordID InMemoryHistoryBackendTest::kTestKeywordId = 42; | 509 const KeywordID InMemoryHistoryBackendTest::kTestKeywordId = 42; |
| (...skipping 2541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 EXPECT_FALSE(base::PathExists(db1)); | 3051 EXPECT_FALSE(base::PathExists(db1)); |
| 3007 EXPECT_FALSE(base::PathExists(db1_wal)); | 3052 EXPECT_FALSE(base::PathExists(db1_wal)); |
| 3008 EXPECT_FALSE(base::PathExists(db1_journal)); | 3053 EXPECT_FALSE(base::PathExists(db1_journal)); |
| 3009 EXPECT_FALSE(base::PathExists(db2_symlink)); | 3054 EXPECT_FALSE(base::PathExists(db2_symlink)); |
| 3010 EXPECT_TRUE(base::PathExists(db2_actual)); // Symlinks shouldn't be followed. | 3055 EXPECT_TRUE(base::PathExists(db2_actual)); // Symlinks shouldn't be followed. |
| 3011 } | 3056 } |
| 3012 | 3057 |
| 3013 // Common implementation for the two tests below, given that the only difference | 3058 // Common implementation for the two tests below, given that the only difference |
| 3014 // between them is the type of the notification sent out. | 3059 // between them is the type of the notification sent out. |
| 3015 void InMemoryHistoryBackendTest::TestAddingAndChangingURLRows( | 3060 void InMemoryHistoryBackendTest::TestAddingAndChangingURLRows( |
| 3016 int notification_type) { | 3061 const SimulateNotificationCallback& callback) { |
| 3017 const char kTestTypedURLAlternativeTitle[] = "Google Search Again"; | 3062 const char kTestTypedURLAlternativeTitle[] = "Google Search Again"; |
| 3018 const char kTestNonTypedURLAlternativeTitle[] = "Google News Again"; | 3063 const char kTestNonTypedURLAlternativeTitle[] = "Google News Again"; |
| 3019 | 3064 |
| 3020 // Notify the in-memory database that a typed and non-typed URLRow (which were | 3065 // Notify the in-memory database that a typed and non-typed URLRow (which were |
| 3021 // never before seen by the cache) have been modified. | 3066 // never before seen by the cache) have been modified. |
| 3022 URLRow row1(CreateTestTypedURL()); | 3067 URLRow row1(CreateTestTypedURL()); |
| 3023 URLRow row2(CreateTestNonTypedURL()); | 3068 URLRow row2(CreateTestNonTypedURL()); |
| 3024 SimulateNotification(notification_type, &row1, &row2); | 3069 callback.Run(&row1, &row2, nullptr); |
| 3025 | 3070 |
| 3026 // The in-memory database should only pick up the typed URL, and should ignore | 3071 // The in-memory database should only pick up the typed URL, and should ignore |
| 3027 // the non-typed one. The typed URL should retain the ID that was present in | 3072 // the non-typed one. The typed URL should retain the ID that was present in |
| 3028 // the notification. | 3073 // the notification. |
| 3029 URLRow cached_row1, cached_row2; | 3074 URLRow cached_row1, cached_row2; |
| 3030 EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1)); | 3075 EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1)); |
| 3031 EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2)); | 3076 EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2)); |
| 3032 EXPECT_EQ(row1.id(), cached_row1.id()); | 3077 EXPECT_EQ(row1.id(), cached_row1.id()); |
| 3033 | 3078 |
| 3034 // Try changing attributes (other than typed_count) for existing URLRows. | 3079 // Try changing attributes (other than typed_count) for existing URLRows. |
| 3035 row1.set_title(base::UTF8ToUTF16(kTestTypedURLAlternativeTitle)); | 3080 row1.set_title(base::UTF8ToUTF16(kTestTypedURLAlternativeTitle)); |
| 3036 row2.set_title(base::UTF8ToUTF16(kTestNonTypedURLAlternativeTitle)); | 3081 row2.set_title(base::UTF8ToUTF16(kTestNonTypedURLAlternativeTitle)); |
| 3037 SimulateNotification(notification_type, &row1, &row2); | 3082 callback.Run(&row1, &row2, nullptr); |
| 3038 | 3083 |
| 3039 // URLRows that are cached by the in-memory database should be updated. | 3084 // URLRows that are cached by the in-memory database should be updated. |
| 3040 EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1)); | 3085 EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1)); |
| 3041 EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2)); | 3086 EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2)); |
| 3042 EXPECT_EQ(base::UTF8ToUTF16(kTestTypedURLAlternativeTitle), | 3087 EXPECT_EQ(base::UTF8ToUTF16(kTestTypedURLAlternativeTitle), |
| 3043 cached_row1.title()); | 3088 cached_row1.title()); |
| 3044 | 3089 |
| 3045 // Now decrease the typed count for the typed URLRow, and increase it for the | 3090 // Now decrease the typed count for the typed URLRow, and increase it for the |
| 3046 // previously non-typed URLRow. | 3091 // previously non-typed URLRow. |
| 3047 row1.set_typed_count(0); | 3092 row1.set_typed_count(0); |
| 3048 row2.set_typed_count(2); | 3093 row2.set_typed_count(2); |
| 3049 SimulateNotification(notification_type, &row1, &row2); | 3094 callback.Run(&row1, &row2, nullptr); |
| 3050 | 3095 |
| 3051 // The in-memory database should stop caching the first URLRow, and start | 3096 // The in-memory database should stop caching the first URLRow, and start |
| 3052 // caching the second URLRow. | 3097 // caching the second URLRow. |
| 3053 EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1)); | 3098 EXPECT_EQ(0, mem_backend_->db()->GetRowForURL(row1.url(), &cached_row1)); |
| 3054 EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2)); | 3099 EXPECT_NE(0, mem_backend_->db()->GetRowForURL(row2.url(), &cached_row2)); |
| 3055 EXPECT_EQ(row2.id(), cached_row2.id()); | 3100 EXPECT_EQ(row2.id(), cached_row2.id()); |
| 3056 EXPECT_EQ(base::UTF8ToUTF16(kTestNonTypedURLAlternativeTitle), | 3101 EXPECT_EQ(base::UTF8ToUTF16(kTestNonTypedURLAlternativeTitle), |
| 3057 cached_row2.title()); | 3102 cached_row2.title()); |
| 3058 } | 3103 } |
| 3059 | 3104 |
| 3060 TEST_F(InMemoryHistoryBackendTest, OnURLsModified) { | 3105 TEST_F(InMemoryHistoryBackendTest, OnURLsModified) { |
| 3061 TestAddingAndChangingURLRows(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED); | 3106 TestAddingAndChangingURLRows( |
| 3107 base::Bind(&InMemoryHistoryBackendTest::SimulateNotification, |
| 3108 base::Unretained(this), |
| 3109 chrome::NOTIFICATION_HISTORY_URLS_MODIFIED)); |
| 3062 } | 3110 } |
| 3063 | 3111 |
| 3064 TEST_F(InMemoryHistoryBackendTest, OnURLsVisisted) { | 3112 TEST_F(InMemoryHistoryBackendTest, OnURLsVisisted) { |
| 3065 TestAddingAndChangingURLRows(chrome::NOTIFICATION_HISTORY_URL_VISITED); | 3113 TestAddingAndChangingURLRows(base::Bind( |
| 3114 &SimulateNotificationURLVisited, base::Unretained(mem_backend_.get()))); |
| 3066 } | 3115 } |
| 3067 | 3116 |
| 3068 TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedPiecewise) { | 3117 TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedPiecewise) { |
| 3069 // Add two typed and one non-typed URLRow to the in-memory database. | 3118 // Add two typed and one non-typed URLRow to the in-memory database. |
| 3070 URLRow row1(CreateTestTypedURL()); | 3119 URLRow row1(CreateTestTypedURL()); |
| 3071 URLRow row2(CreateAnotherTestTypedURL()); | 3120 URLRow row2(CreateAnotherTestTypedURL()); |
| 3072 URLRow row3(CreateTestNonTypedURL()); | 3121 URLRow row3(CreateTestNonTypedURL()); |
| 3073 SimulateNotification(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, | 3122 SimulateNotification(chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
| 3074 &row1, &row2, &row3); | 3123 &row1, &row2, &row3); |
| 3075 | 3124 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3214 // Verify that the second term is no longer returned as result, and also check | 3263 // Verify that the second term is no longer returned as result, and also check |
| 3215 // at the low level that it is gone for good. The term corresponding to the | 3264 // at the low level that it is gone for good. The term corresponding to the |
| 3216 // first URLRow should not be affected. | 3265 // first URLRow should not be affected. |
| 3217 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3266 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
| 3218 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3267 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
| 3219 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3268 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
| 3220 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3269 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
| 3221 } | 3270 } |
| 3222 | 3271 |
| 3223 } // namespace history | 3272 } // namespace history |
| OLD | NEW |