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

Side by Side Diff: chrome/browser/history/history_querying_unittest.cc

Issue 849323002: Componentize HistoryDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android compilation Created 5 years, 11 months 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 unified diff | Download patch
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/task/cancelable_task_tracker.h" 13 #include "base/task/cancelable_task_tracker.h"
14 #include "chrome/browser/history/history_service.h" 14 #include "chrome/browser/history/history_service.h"
15 #include "components/history/core/browser/history_database_params.h"
16 #include "components/history/core/test/test_history_database.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 using base::Time; 19 using base::Time;
18 using base::TimeDelta; 20 using base::TimeDelta;
19 21
20 // Tests the history service for querying functionality. 22 // Tests the history service for querying functionality.
21 23
22 namespace history { 24 namespace history {
23 25
24 namespace { 26 namespace {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 history_->SetPageTitle(url, base::UTF8ToUTF16(entry.title)); 160 history_->SetPageTitle(url, base::UTF8ToUTF16(entry.title));
159 } 161 }
160 162
161 private: 163 private:
162 void SetUp() override { 164 void SetUp() override {
163 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 165 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
164 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); 166 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest");
165 ASSERT_TRUE(base::CreateDirectory(history_dir_)); 167 ASSERT_TRUE(base::CreateDirectory(history_dir_));
166 168
167 history_.reset(new HistoryService); 169 history_.reset(new HistoryService);
168 if (!history_->Init(history_dir_)) { 170 if (!history_->Init(TestHistoryDatabaseParamsForPath(history_dir_))) {
169 history_.reset(); // Tests should notice this NULL ptr & fail. 171 history_.reset(); // Tests should notice this NULL ptr & fail.
170 return; 172 return;
171 } 173 }
172 174
173 // Fill the test data. 175 // Fill the test data.
174 Time now = Time::Now().LocalMidnight(); 176 Time now = Time::Now().LocalMidnight();
175 for (size_t i = 0; i < arraysize(test_entries); i++) { 177 for (size_t i = 0; i < arraysize(test_entries); i++) {
176 test_entries[i].time = 178 test_entries[i].time =
177 now - (test_entries[i].days_ago * TimeDelta::FromDays(1)); 179 now - (test_entries[i].days_ago * TimeDelta::FromDays(1));
178 AddEntryToHistory(test_entries[i]); 180 AddEntryToHistory(test_entries[i]);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 423
422 TEST_F(HistoryQueryTest, TextSearchPaging) { 424 TEST_F(HistoryQueryTest, TextSearchPaging) {
423 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not 425 // Since results are fetched 1 and 2 at a time, entry #0 and #6 will not
424 // be de-duplicated. Entry #4 does not contain the text "title", so it 426 // be de-duplicated. Entry #4 does not contain the text "title", so it
425 // shouldn't appear. 427 // shouldn't appear.
426 int expected_results[] = { 2, 3, 1, 7, 6, 5 }; 428 int expected_results[] = { 2, 3, 1, 7, 6, 5 };
427 TestPaging("title", expected_results, arraysize(expected_results)); 429 TestPaging("title", expected_results, arraysize(expected_results));
428 } 430 }
429 431
430 } // namespace history 432 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_database_unittest.cc ('k') | chrome/browser/history/history_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698