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

Side by Side Diff: chrome/browser/history/history_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 // History unit tests come in two flavors: 5 // History unit tests come in two flavors:
6 // 6 //
7 // 1. The more complicated style is that the unit test creates a full history 7 // 1. The more complicated style is that the unit test creates a full history
8 // service. This spawns a background thread for the history backend, and 8 // service. This spawns a background thread for the history backend, and
9 // all communication is asynchronous. This is useful for testing more 9 // all communication is asynchronous. This is useful for testing more
10 // complicated things or end-to-end behavior. 10 // complicated things or end-to-end behavior.
(...skipping 25 matching lines...) Expand all
36 #include "base/memory/scoped_vector.h" 36 #include "base/memory/scoped_vector.h"
37 #include "base/message_loop/message_loop.h" 37 #include "base/message_loop/message_loop.h"
38 #include "base/path_service.h" 38 #include "base/path_service.h"
39 #include "base/strings/string_util.h" 39 #include "base/strings/string_util.h"
40 #include "base/strings/stringprintf.h" 40 #include "base/strings/stringprintf.h"
41 #include "base/strings/utf_string_conversions.h" 41 #include "base/strings/utf_string_conversions.h"
42 #include "base/task/cancelable_task_tracker.h" 42 #include "base/task/cancelable_task_tracker.h"
43 #include "base/threading/platform_thread.h" 43 #include "base/threading/platform_thread.h"
44 #include "base/time/time.h" 44 #include "base/time/time.h"
45 #include "chrome/browser/history/history_backend.h" 45 #include "chrome/browser/history/history_backend.h"
46 #include "chrome/browser/history/history_database.h"
47 #include "chrome/browser/history/history_notifications.h" 46 #include "chrome/browser/history/history_notifications.h"
48 #include "chrome/browser/history/history_service.h" 47 #include "chrome/browser/history/history_service.h"
49 #include "chrome/browser/history/in_memory_history_backend.h" 48 #include "chrome/browser/history/in_memory_history_backend.h"
50 #include "chrome/common/chrome_constants.h" 49 #include "chrome/common/chrome_constants.h"
51 #include "chrome/common/chrome_paths.h" 50 #include "chrome/common/chrome_paths.h"
52 #include "chrome/tools/profiles/thumbnail-inl.h" 51 #include "chrome/tools/profiles/thumbnail-inl.h"
53 #include "components/history/content/browser/download_constants_utils.h" 52 #include "components/history/content/browser/download_constants_utils.h"
53 #include "components/history/content/browser/history_database_helper.h"
54 #include "components/history/core/browser/download_constants.h" 54 #include "components/history/core/browser/download_constants.h"
55 #include "components/history/core/browser/download_row.h" 55 #include "components/history/core/browser/download_row.h"
56 #include "components/history/core/browser/history_constants.h" 56 #include "components/history/core/browser/history_constants.h"
57 #include "components/history/core/browser/history_database.h"
58 #include "components/history/core/browser/history_database_params.h"
57 #include "components/history/core/browser/history_db_task.h" 59 #include "components/history/core/browser/history_db_task.h"
58 #include "components/history/core/browser/in_memory_database.h" 60 #include "components/history/core/browser/in_memory_database.h"
59 #include "components/history/core/browser/page_usage_data.h" 61 #include "components/history/core/browser/page_usage_data.h"
60 #include "components/history/core/common/thumbnail_score.h" 62 #include "components/history/core/common/thumbnail_score.h"
61 #include "components/history/core/test/history_unittest_base.h" 63 #include "components/history/core/test/history_unittest_base.h"
64 #include "components/history/core/test/test_history_database.h"
62 #include "content/public/browser/download_item.h" 65 #include "content/public/browser/download_item.h"
63 #include "content/public/browser/notification_details.h" 66 #include "content/public/browser/notification_details.h"
64 #include "content/public/browser/notification_source.h" 67 #include "content/public/browser/notification_source.h"
65 #include "sql/connection.h" 68 #include "sql/connection.h"
66 #include "sql/statement.h" 69 #include "sql/statement.h"
67 #include "sync/api/attachments/attachment_id.h" 70 #include "sync/api/attachments/attachment_id.h"
68 #include "sync/api/fake_sync_change_processor.h" 71 #include "sync/api/fake_sync_change_processor.h"
69 #include "sync/api/sync_change.h" 72 #include "sync/api/sync_change.h"
70 #include "sync/api/sync_change_processor.h" 73 #include "sync/api/sync_change_processor.h"
71 #include "sync/api/sync_change_processor_wrapper_for_test.h" 74 #include "sync/api/sync_change_processor_wrapper_for_test.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 ~HistoryBackendDBTest() override {} 129 ~HistoryBackendDBTest() override {}
127 130
128 protected: 131 protected:
129 friend class BackendDelegate; 132 friend class BackendDelegate;
130 133
131 // Creates the HistoryBackend and HistoryDatabase on the current thread, 134 // Creates the HistoryBackend and HistoryDatabase on the current thread,
132 // assigning the values to backend_ and db_. 135 // assigning the values to backend_ and db_.
133 void CreateBackendAndDatabase() { 136 void CreateBackendAndDatabase() {
134 backend_ = 137 backend_ =
135 new HistoryBackend(history_dir_, new BackendDelegate(this), NULL); 138 new HistoryBackend(history_dir_, new BackendDelegate(this), NULL);
136 backend_->Init(std::string(), false); 139 backend_->Init(std::string(), false,
140 HistoryDatabaseParamsForPath(history_dir_));
137 db_ = backend_->db_.get(); 141 db_ = backend_->db_.get();
138 DCHECK(in_mem_backend_) << "Mem backend should have been set by " 142 DCHECK(in_mem_backend_) << "Mem backend should have been set by "
139 "HistoryBackend::Init"; 143 "HistoryBackend::Init";
140 } 144 }
141 145
142 void CreateDBVersion(int version) { 146 void CreateDBVersion(int version) {
143 base::FilePath data_path; 147 base::FilePath data_path;
144 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); 148 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path));
145 data_path = data_path.AppendASCII("History"); 149 data_path = data_path.AppendASCII("History");
146 data_path = 150 data_path =
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 1001
998 protected: 1002 protected:
999 friend class BackendDelegate; 1003 friend class BackendDelegate;
1000 1004
1001 // testing::Test 1005 // testing::Test
1002 void SetUp() override { 1006 void SetUp() override {
1003 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 1007 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
1004 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); 1008 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest");
1005 ASSERT_TRUE(base::CreateDirectory(history_dir_)); 1009 ASSERT_TRUE(base::CreateDirectory(history_dir_));
1006 history_service_.reset(new HistoryService); 1010 history_service_.reset(new HistoryService);
1007 if (!history_service_->Init(history_dir_)) { 1011 if (!history_service_->Init(HistoryDatabaseParamsForPath(history_dir_))) {
1008 history_service_.reset(); 1012 history_service_.reset();
1009 ADD_FAILURE(); 1013 ADD_FAILURE();
1010 } 1014 }
1011 } 1015 }
1012 1016
1013 void TearDown() override { 1017 void TearDown() override {
1014 if (history_service_) 1018 if (history_service_)
1015 CleanupHistoryService(); 1019 CleanupHistoryService();
1016 1020
1017 // Make sure we don't have any event pending that could disrupt the next 1021 // Make sure we don't have any event pending that could disrupt the next
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 std::vector<PageUsageData*> results; 1873 std::vector<PageUsageData*> results;
1870 db_->QuerySegmentUsage(segment_time, 10, &results); 1874 db_->QuerySegmentUsage(segment_time, 10, &results);
1871 ASSERT_EQ(1u, results.size()); 1875 ASSERT_EQ(1u, results.size());
1872 EXPECT_EQ(url, results[0]->GetURL()); 1876 EXPECT_EQ(url, results[0]->GetURL());
1873 EXPECT_EQ(segment_id, results[0]->GetID()); 1877 EXPECT_EQ(segment_id, results[0]->GetID());
1874 EXPECT_EQ(title, results[0]->GetTitle()); 1878 EXPECT_EQ(title, results[0]->GetTitle());
1875 STLDeleteElements(&results); 1879 STLDeleteElements(&results);
1876 } 1880 }
1877 1881
1878 } // namespace history 1882 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_service_factory.cc ('k') | chrome/browser/history/in_memory_url_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698