| 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 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 void HistoryBackendTestDelegate::DBLoaded() { | 214 void HistoryBackendTestDelegate::DBLoaded() { |
| 215 test_->loaded_ = true; | 215 test_->loaded_ = true; |
| 216 } | 216 } |
| 217 | 217 |
| 218 class HistoryBackendTest : public HistoryBackendTestBase { | 218 class HistoryBackendTest : public HistoryBackendTestBase { |
| 219 public: | 219 public: |
| 220 HistoryBackendTest() {} | 220 HistoryBackendTest() {} |
| 221 virtual ~HistoryBackendTest() {} | 221 virtual ~HistoryBackendTest() {} |
| 222 | 222 |
| 223 // Callback for QueryMostVisited. | |
| 224 void OnQueryMostVisited(CancelableRequestProvider::Handle handle, | |
| 225 history::MostVisitedURLList data) { | |
| 226 most_visited_list_.swap(data); | |
| 227 } | |
| 228 | |
| 229 // Callback for QueryFiltered. | 223 // Callback for QueryFiltered. |
| 230 void OnQueryFiltered(CancelableRequestProvider::Handle handle, | 224 void OnQueryFiltered(CancelableRequestProvider::Handle handle, |
| 231 const history::FilteredURLList& data) { | 225 const history::FilteredURLList& data) { |
| 232 filtered_list_ = data; | 226 filtered_list_ = data; |
| 233 } | 227 } |
| 234 | 228 |
| 235 protected: | 229 protected: |
| 236 const history::MostVisitedURLList& get_most_visited_list() const { | |
| 237 return most_visited_list_; | |
| 238 } | |
| 239 | |
| 240 const history::FilteredURLList& get_filtered_list() const { | 230 const history::FilteredURLList& get_filtered_list() const { |
| 241 return filtered_list_; | 231 return filtered_list_; |
| 242 } | 232 } |
| 243 | 233 |
| 244 void AddRedirectChain(const char* sequence[], int page_id) { | 234 void AddRedirectChain(const char* sequence[], int page_id) { |
| 245 AddRedirectChainWithTransitionAndTime(sequence, page_id, | 235 AddRedirectChainWithTransitionAndTime(sequence, page_id, |
| 246 content::PAGE_TRANSITION_LINK, | 236 content::PAGE_TRANSITION_LINK, |
| 247 Time::Now()); | 237 Time::Now()); |
| 248 } | 238 } |
| 249 | 239 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 420 |
| 431 // Returns true if |bitmap_data| is equal to |expected_data|. | 421 // Returns true if |bitmap_data| is equal to |expected_data|. |
| 432 bool BitmapDataEqual(char expected_data, | 422 bool BitmapDataEqual(char expected_data, |
| 433 scoped_refptr<base::RefCountedMemory> bitmap_data) { | 423 scoped_refptr<base::RefCountedMemory> bitmap_data) { |
| 434 return bitmap_data.get() && | 424 return bitmap_data.get() && |
| 435 bitmap_data->size() == 1u && | 425 bitmap_data->size() == 1u && |
| 436 *bitmap_data->front() == expected_data; | 426 *bitmap_data->front() == expected_data; |
| 437 } | 427 } |
| 438 | 428 |
| 439 private: | 429 private: |
| 440 history::MostVisitedURLList most_visited_list_; | |
| 441 history::FilteredURLList filtered_list_; | 430 history::FilteredURLList filtered_list_; |
| 442 | 431 |
| 443 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTest); | 432 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTest); |
| 444 }; | 433 }; |
| 445 | 434 |
| 446 class InMemoryHistoryBackendTest : public HistoryBackendTestBase { | 435 class InMemoryHistoryBackendTest : public HistoryBackendTestBase { |
| 447 public: | 436 public: |
| 448 InMemoryHistoryBackendTest() {} | 437 InMemoryHistoryBackendTest() {} |
| 449 virtual ~InMemoryHistoryBackendTest() {} | 438 virtual ~InMemoryHistoryBackendTest() {} |
| 450 | 439 |
| (...skipping 2965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3416 // Verify that the second term is no longer returned as result, and also check | 3405 // Verify that the second term is no longer returned as result, and also check |
| 3417 // at the low level that it is gone for good. The term corresponding to the | 3406 // at the low level that it is gone for good. The term corresponding to the |
| 3418 // first URLRow should not be affected. | 3407 // first URLRow should not be affected. |
| 3419 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3408 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
| 3420 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3409 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
| 3421 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3410 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
| 3422 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3411 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
| 3423 } | 3412 } |
| 3424 | 3413 |
| 3425 } // namespace history | 3414 } // namespace history |
| OLD | NEW |