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 // 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 24 matching lines...) Expand all Loading... |
35 #include "base/memory/scoped_ptr.h" | 35 #include "base/memory/scoped_ptr.h" |
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/common/chrome_constants.h" | |
46 #include "chrome/common/chrome_paths.h" | |
47 #include "components/history/content/browser/download_constants_utils.h" | |
48 #include "components/history/content/browser/history_database_helper.h" | |
49 #include "components/history/core/browser/download_constants.h" | 45 #include "components/history/core/browser/download_constants.h" |
50 #include "components/history/core/browser/download_row.h" | 46 #include "components/history/core/browser/download_row.h" |
51 #include "components/history/core/browser/history_backend.h" | 47 #include "components/history/core/browser/history_backend.h" |
52 #include "components/history/core/browser/history_constants.h" | 48 #include "components/history/core/browser/history_constants.h" |
53 #include "components/history/core/browser/history_database.h" | 49 #include "components/history/core/browser/history_database.h" |
54 #include "components/history/core/browser/history_database_params.h" | 50 #include "components/history/core/browser/history_database_params.h" |
55 #include "components/history/core/browser/history_db_task.h" | 51 #include "components/history/core/browser/history_db_task.h" |
56 #include "components/history/core/browser/history_service.h" | 52 #include "components/history/core/browser/history_service.h" |
57 #include "components/history/core/browser/in_memory_database.h" | 53 #include "components/history/core/browser/in_memory_database.h" |
58 #include "components/history/core/browser/in_memory_history_backend.h" | 54 #include "components/history/core/browser/in_memory_history_backend.h" |
59 #include "components/history/core/browser/page_usage_data.h" | 55 #include "components/history/core/browser/page_usage_data.h" |
60 #include "components/history/core/common/thumbnail_score.h" | 56 #include "components/history/core/common/thumbnail_score.h" |
| 57 #include "components/history/core/test/database_test_utils.h" |
61 #include "components/history/core/test/history_unittest_base.h" | 58 #include "components/history/core/test/history_unittest_base.h" |
62 #include "components/history/core/test/test_history_database.h" | 59 #include "components/history/core/test/test_history_database.h" |
63 #include "components/history/core/test/thumbnail-inl.h" | 60 #include "components/history/core/test/thumbnail-inl.h" |
64 #include "content/public/browser/download_item.h" | |
65 #include "content/public/browser/notification_details.h" | |
66 #include "content/public/browser/notification_source.h" | |
67 #include "sql/connection.h" | 61 #include "sql/connection.h" |
68 #include "sql/statement.h" | 62 #include "sql/statement.h" |
69 #include "sync/api/attachments/attachment_id.h" | 63 #include "sync/api/attachments/attachment_id.h" |
70 #include "sync/api/fake_sync_change_processor.h" | 64 #include "sync/api/fake_sync_change_processor.h" |
71 #include "sync/api/sync_change.h" | 65 #include "sync/api/sync_change.h" |
72 #include "sync/api/sync_change_processor.h" | 66 #include "sync/api/sync_change_processor.h" |
73 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 67 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
74 #include "sync/api/sync_error.h" | 68 #include "sync/api/sync_error.h" |
75 #include "sync/api/sync_error_factory.h" | 69 #include "sync/api/sync_error_factory.h" |
76 #include "sync/api/sync_merge_result.h" | 70 #include "sync/api/sync_merge_result.h" |
77 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" | 71 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" |
78 #include "sync/protocol/history_delete_directive_specifics.pb.h" | 72 #include "sync/protocol/history_delete_directive_specifics.pb.h" |
79 #include "sync/protocol/sync.pb.h" | 73 #include "sync/protocol/sync.pb.h" |
80 #include "testing/gtest/include/gtest/gtest.h" | 74 #include "testing/gtest/include/gtest/gtest.h" |
81 #include "third_party/skia/include/core/SkBitmap.h" | 75 #include "third_party/skia/include/core/SkBitmap.h" |
82 #include "ui/gfx/codec/jpeg_codec.h" | 76 #include "ui/gfx/codec/jpeg_codec.h" |
83 | 77 |
84 using base::Time; | 78 using base::Time; |
85 using base::TimeDelta; | 79 using base::TimeDelta; |
86 using content::DownloadItem; | |
87 | 80 |
88 namespace history { | 81 namespace history { |
89 class HistoryBackendDBTest; | 82 class HistoryBackendDBTest; |
90 | 83 |
91 // Delegate class for when we create a backend without a HistoryService. | 84 // Delegate class for when we create a backend without a HistoryService. |
92 // | 85 // |
93 // This must be outside the anonymous namespace for the friend statement in | 86 // This must be outside the anonymous namespace for the friend statement in |
94 // HistoryBackendDBTest to work. | 87 // HistoryBackendDBTest to work. |
95 class BackendDelegate : public HistoryBackend::Delegate { | 88 class BackendDelegate : public HistoryBackend::Delegate { |
96 public: | 89 public: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ~HistoryBackendDBTest() override {} | 123 ~HistoryBackendDBTest() override {} |
131 | 124 |
132 protected: | 125 protected: |
133 friend class BackendDelegate; | 126 friend class BackendDelegate; |
134 | 127 |
135 // Creates the HistoryBackend and HistoryDatabase on the current thread, | 128 // Creates the HistoryBackend and HistoryDatabase on the current thread, |
136 // assigning the values to backend_ and db_. | 129 // assigning the values to backend_ and db_. |
137 void CreateBackendAndDatabase() { | 130 void CreateBackendAndDatabase() { |
138 backend_ = new HistoryBackend(new BackendDelegate(this), nullptr); | 131 backend_ = new HistoryBackend(new BackendDelegate(this), nullptr); |
139 backend_->Init(std::string(), false, | 132 backend_->Init(std::string(), false, |
140 HistoryDatabaseParamsForPath(history_dir_)); | 133 TestHistoryDatabaseParamsForPath(history_dir_)); |
141 db_ = backend_->db_.get(); | 134 db_ = backend_->db_.get(); |
142 DCHECK(in_mem_backend_) << "Mem backend should have been set by " | 135 DCHECK(in_mem_backend_) << "Mem backend should have been set by " |
143 "HistoryBackend::Init"; | 136 "HistoryBackend::Init"; |
144 } | 137 } |
145 | 138 |
146 void CreateDBVersion(int version) { | 139 void CreateDBVersion(int version) { |
147 base::FilePath data_path; | 140 base::FilePath data_path; |
148 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 141 ASSERT_TRUE(GetTestDataHistoryDir(&data_path)); |
149 data_path = data_path.AppendASCII("History"); | |
150 data_path = | 142 data_path = |
151 data_path.AppendASCII(base::StringPrintf("history.%d.sql", version)); | 143 data_path.AppendASCII(base::StringPrintf("history.%d.sql", version)); |
152 ASSERT_NO_FATAL_FAILURE( | 144 ASSERT_NO_FATAL_FAILURE( |
153 ExecuteSQLScript(data_path, history_dir_.Append(kHistoryFilename))); | 145 ExecuteSQLScript(data_path, history_dir_.Append(kHistoryFilename))); |
154 } | 146 } |
155 | 147 |
156 void CreateArchivedDB() { | 148 void CreateArchivedDB() { |
157 base::FilePath data_path; | 149 base::FilePath data_path; |
158 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 150 ASSERT_TRUE(GetTestDataHistoryDir(&data_path)); |
159 data_path = data_path.AppendASCII("History"); | |
160 data_path = data_path.AppendASCII("archived_history.4.sql"); | 151 data_path = data_path.AppendASCII("archived_history.4.sql"); |
161 ASSERT_NO_FATAL_FAILURE(ExecuteSQLScript( | 152 ASSERT_NO_FATAL_FAILURE(ExecuteSQLScript( |
162 data_path, history_dir_.Append(kArchivedHistoryFilename))); | 153 data_path, history_dir_.Append(kArchivedHistoryFilename))); |
163 } | 154 } |
164 | 155 |
165 // testing::Test | 156 // testing::Test |
166 void SetUp() override { | 157 void SetUp() override { |
167 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 158 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
168 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest"); | 159 history_dir_ = temp_dir_.path().AppendASCII("HistoryBackendDBTest"); |
169 ASSERT_TRUE(base::CreateDirectory(history_dir_)); | 160 ASSERT_TRUE(base::CreateDirectory(history_dir_)); |
(...skipping 27 matching lines...) Expand all Loading... |
197 "application/vnd.oasis.opendocument.text", | 188 "application/vnd.oasis.opendocument.text", |
198 "application/octet-stream", | 189 "application/octet-stream", |
199 time, | 190 time, |
200 time, | 191 time, |
201 std::string(), | 192 std::string(), |
202 std::string(), | 193 std::string(), |
203 0, | 194 0, |
204 512, | 195 512, |
205 state, | 196 state, |
206 DownloadDangerType::NOT_DANGEROUS, | 197 DownloadDangerType::NOT_DANGEROUS, |
207 ToHistoryDownloadInterruptReason( | 198 kTestDownloadInterruptReasonNone, |
208 content::DOWNLOAD_INTERRUPT_REASON_NONE), | |
209 id, | 199 id, |
210 false, | 200 false, |
211 "by_ext_id", | 201 "by_ext_id", |
212 "by_ext_name"); | 202 "by_ext_name"); |
213 return db_->CreateDownload(download); | 203 return db_->CreateDownload(download); |
214 } | 204 } |
215 | 205 |
216 base::ScopedTempDir temp_dir_; | 206 base::ScopedTempDir temp_dir_; |
217 | 207 |
218 base::MessageLoopForUI message_loop_; | 208 base::MessageLoopForUI message_loop_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 EXPECT_EQ(1UL, downloads[0].url_chain.size()); | 246 EXPECT_EQ(1UL, downloads[0].url_chain.size()); |
257 EXPECT_EQ(GURL("foo-url"), downloads[0].url_chain[0]); | 247 EXPECT_EQ(GURL("foo-url"), downloads[0].url_chain[0]); |
258 EXPECT_EQ(std::string("http://referrer.com/"), | 248 EXPECT_EQ(std::string("http://referrer.com/"), |
259 std::string(downloads[0].referrer_url.spec())); | 249 std::string(downloads[0].referrer_url.spec())); |
260 EXPECT_EQ(now, downloads[0].start_time); | 250 EXPECT_EQ(now, downloads[0].start_time); |
261 EXPECT_EQ(now, downloads[0].end_time); | 251 EXPECT_EQ(now, downloads[0].end_time); |
262 EXPECT_EQ(0, downloads[0].received_bytes); | 252 EXPECT_EQ(0, downloads[0].received_bytes); |
263 EXPECT_EQ(512, downloads[0].total_bytes); | 253 EXPECT_EQ(512, downloads[0].total_bytes); |
264 EXPECT_EQ(DownloadState::COMPLETE, downloads[0].state); | 254 EXPECT_EQ(DownloadState::COMPLETE, downloads[0].state); |
265 EXPECT_EQ(DownloadDangerType::NOT_DANGEROUS, downloads[0].danger_type); | 255 EXPECT_EQ(DownloadDangerType::NOT_DANGEROUS, downloads[0].danger_type); |
266 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, | 256 EXPECT_EQ(kTestDownloadInterruptReasonNone, downloads[0].interrupt_reason); |
267 downloads[0].interrupt_reason); | |
268 EXPECT_FALSE(downloads[0].opened); | 257 EXPECT_FALSE(downloads[0].opened); |
269 EXPECT_EQ("by_ext_id", downloads[0].by_ext_id); | 258 EXPECT_EQ("by_ext_id", downloads[0].by_ext_id); |
270 EXPECT_EQ("by_ext_name", downloads[0].by_ext_name); | 259 EXPECT_EQ("by_ext_name", downloads[0].by_ext_name); |
271 EXPECT_EQ("application/vnd.oasis.opendocument.text", downloads[0].mime_type); | 260 EXPECT_EQ("application/vnd.oasis.opendocument.text", downloads[0].mime_type); |
272 EXPECT_EQ("application/octet-stream", downloads[0].original_mime_type); | 261 EXPECT_EQ("application/octet-stream", downloads[0].original_mime_type); |
273 | 262 |
274 db_->QueryDownloads(&downloads); | 263 db_->QueryDownloads(&downloads); |
275 EXPECT_EQ(1U, downloads.size()); | 264 EXPECT_EQ(1U, downloads.size()); |
276 db_->RemoveDownload(id); | 265 db_->RemoveDownload(id); |
277 db_->QueryDownloads(&downloads); | 266 db_->QueryDownloads(&downloads); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 { | 397 { |
409 base::Time nowish(base::Time::FromTimeT(now.ToTimeT())); | 398 base::Time nowish(base::Time::FromTimeT(now.ToTimeT())); |
410 | 399 |
411 // Confirm downloads table is valid. | 400 // Confirm downloads table is valid. |
412 sql::Statement statement(db.GetUniqueStatement( | 401 sql::Statement statement(db.GetUniqueStatement( |
413 "SELECT id, interrupt_reason, current_path, target_path, " | 402 "SELECT id, interrupt_reason, current_path, target_path, " |
414 " danger_type, start_time, end_time " | 403 " danger_type, start_time, end_time " |
415 "FROM downloads ORDER BY id")); | 404 "FROM downloads ORDER BY id")); |
416 EXPECT_TRUE(statement.Step()); | 405 EXPECT_TRUE(statement.Step()); |
417 EXPECT_EQ(1, statement.ColumnInt64(0)); | 406 EXPECT_EQ(1, statement.ColumnInt64(0)); |
418 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, | 407 EXPECT_EQ(DownloadInterruptReasonToInt(kTestDownloadInterruptReasonNone), |
419 statement.ColumnInt(1)); | 408 statement.ColumnInt(1)); |
420 EXPECT_EQ("", statement.ColumnString(2)); | 409 EXPECT_EQ("", statement.ColumnString(2)); |
421 EXPECT_EQ("", statement.ColumnString(3)); | 410 EXPECT_EQ("", statement.ColumnString(3)); |
422 // Implicit dependence on value of kDangerTypeNotDangerous from | 411 // Implicit dependence on value of kDangerTypeNotDangerous from |
423 // download_database.cc. | 412 // download_database.cc. |
424 EXPECT_EQ(0, statement.ColumnInt(4)); | 413 EXPECT_EQ(0, statement.ColumnInt(4)); |
425 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(5)); | 414 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(5)); |
426 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(6)); | 415 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(6)); |
427 | 416 |
428 EXPECT_TRUE(statement.Step()); | 417 EXPECT_TRUE(statement.Step()); |
429 EXPECT_EQ(2, statement.ColumnInt64(0)); | 418 EXPECT_EQ(2, statement.ColumnInt64(0)); |
430 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, | 419 EXPECT_EQ(DownloadInterruptReasonToInt(kTestDownloadInterruptReasonNone), |
431 statement.ColumnInt(1)); | 420 statement.ColumnInt(1)); |
432 EXPECT_EQ("/path/to/some/file", statement.ColumnString(2)); | 421 EXPECT_EQ("/path/to/some/file", statement.ColumnString(2)); |
433 EXPECT_EQ("/path/to/some/file", statement.ColumnString(3)); | 422 EXPECT_EQ("/path/to/some/file", statement.ColumnString(3)); |
434 EXPECT_EQ(0, statement.ColumnInt(4)); | 423 EXPECT_EQ(0, statement.ColumnInt(4)); |
435 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(5)); | 424 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(5)); |
436 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(6)); | 425 EXPECT_EQ(nowish.ToInternalValue(), statement.ColumnInt64(6)); |
437 | 426 |
438 EXPECT_FALSE(statement.Step()); | 427 EXPECT_FALSE(statement.Step()); |
439 } | 428 } |
440 { | 429 { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 "application/octet-stream", | 763 "application/octet-stream", |
775 "application/octet-stream", | 764 "application/octet-stream", |
776 now, | 765 now, |
777 now, | 766 now, |
778 std::string(), | 767 std::string(), |
779 std::string(), | 768 std::string(), |
780 0, | 769 0, |
781 512, | 770 512, |
782 DownloadState::COMPLETE, | 771 DownloadState::COMPLETE, |
783 DownloadDangerType::NOT_DANGEROUS, | 772 DownloadDangerType::NOT_DANGEROUS, |
784 ToHistoryDownloadInterruptReason( | 773 kTestDownloadInterruptReasonNone, |
785 content::DOWNLOAD_INTERRUPT_REASON_NONE), | |
786 1, | 774 1, |
787 0, | 775 0, |
788 "by_ext_id", | 776 "by_ext_id", |
789 "by_ext_name"); | 777 "by_ext_name"); |
790 | 778 |
791 // Creating records without any urls should fail. | 779 // Creating records without any urls should fail. |
792 EXPECT_FALSE(db_->CreateDownload(download)); | 780 EXPECT_FALSE(db_->CreateDownload(download)); |
793 | 781 |
794 download.url_chain.push_back(GURL("foo-url")); | 782 download.url_chain.push_back(GURL("foo-url")); |
795 EXPECT_TRUE(db_->CreateDownload(download)); | 783 EXPECT_TRUE(db_->CreateDownload(download)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 sql::Statement statement(db.GetUniqueStatement( | 827 sql::Statement statement(db.GetUniqueStatement( |
840 "Select Count(*) from downloads")); | 828 "Select Count(*) from downloads")); |
841 EXPECT_TRUE(statement.Step()); | 829 EXPECT_TRUE(statement.Step()); |
842 EXPECT_EQ(1, statement.ColumnInt(0)); | 830 EXPECT_EQ(1, statement.ColumnInt(0)); |
843 | 831 |
844 sql::Statement statement1(db.GetUniqueStatement( | 832 sql::Statement statement1(db.GetUniqueStatement( |
845 "Select state, interrupt_reason from downloads")); | 833 "Select state, interrupt_reason from downloads")); |
846 EXPECT_TRUE(statement1.Step()); | 834 EXPECT_TRUE(statement1.Step()); |
847 EXPECT_EQ(DownloadStateToInt(DownloadState::IN_PROGRESS), | 835 EXPECT_EQ(DownloadStateToInt(DownloadState::IN_PROGRESS), |
848 statement1.ColumnInt(0)); | 836 statement1.ColumnInt(0)); |
849 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, statement1.ColumnInt(1)); | 837 EXPECT_EQ(DownloadInterruptReasonToInt(kTestDownloadInterruptReasonNone), |
| 838 statement1.ColumnInt(1)); |
850 EXPECT_FALSE(statement1.Step()); | 839 EXPECT_FALSE(statement1.Step()); |
851 } | 840 } |
852 | 841 |
853 // Read in the DB through query downloads, then test that the | 842 // Read in the DB through query downloads, then test that the |
854 // right transformation was returned. | 843 // right transformation was returned. |
855 CreateBackendAndDatabase(); | 844 CreateBackendAndDatabase(); |
856 std::vector<DownloadRow> results; | 845 std::vector<DownloadRow> results; |
857 db_->QueryDownloads(&results); | 846 db_->QueryDownloads(&results); |
858 ASSERT_EQ(1u, results.size()); | 847 ASSERT_EQ(1u, results.size()); |
859 EXPECT_EQ(DownloadState::INTERRUPTED, results[0].state); | 848 EXPECT_EQ(DownloadState::INTERRUPTED, results[0].state); |
860 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_CRASH, | 849 EXPECT_EQ(kTestDownloadInterruptReasonCrash, results[0].interrupt_reason); |
861 results[0].interrupt_reason); | |
862 | 850 |
863 // Allow the update to propagate, shut down the DB, and confirm that | 851 // Allow the update to propagate, shut down the DB, and confirm that |
864 // the query updated the on disk database as well. | 852 // the query updated the on disk database as well. |
865 base::MessageLoop::current()->RunUntilIdle(); | 853 base::MessageLoop::current()->RunUntilIdle(); |
866 DeleteBackend(); | 854 DeleteBackend(); |
867 { | 855 { |
868 sql::Connection db; | 856 sql::Connection db; |
869 ASSERT_TRUE(db.Open(history_dir_.Append(kHistoryFilename))); | 857 ASSERT_TRUE(db.Open(history_dir_.Append(kHistoryFilename))); |
870 sql::Statement statement(db.GetUniqueStatement( | 858 sql::Statement statement(db.GetUniqueStatement( |
871 "Select Count(*) from downloads")); | 859 "Select Count(*) from downloads")); |
872 EXPECT_TRUE(statement.Step()); | 860 EXPECT_TRUE(statement.Step()); |
873 EXPECT_EQ(1, statement.ColumnInt(0)); | 861 EXPECT_EQ(1, statement.ColumnInt(0)); |
874 | 862 |
875 sql::Statement statement1(db.GetUniqueStatement( | 863 sql::Statement statement1(db.GetUniqueStatement( |
876 "Select state, interrupt_reason from downloads")); | 864 "Select state, interrupt_reason from downloads")); |
877 EXPECT_TRUE(statement1.Step()); | 865 EXPECT_TRUE(statement1.Step()); |
878 EXPECT_EQ(DownloadStateToInt(DownloadState::INTERRUPTED), | 866 EXPECT_EQ(DownloadStateToInt(DownloadState::INTERRUPTED), |
879 statement1.ColumnInt(0)); | 867 statement1.ColumnInt(0)); |
880 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_CRASH, | 868 EXPECT_EQ(DownloadInterruptReasonToInt(kTestDownloadInterruptReasonCrash), |
881 statement1.ColumnInt(1)); | 869 statement1.ColumnInt(1)); |
882 EXPECT_FALSE(statement1.Step()); | 870 EXPECT_FALSE(statement1.Step()); |
883 } | 871 } |
884 } | 872 } |
885 | 873 |
886 struct InterruptReasonAssociation { | 874 struct InterruptReasonAssociation { |
887 std::string name; | 875 std::string name; |
888 int value; | 876 int value; |
889 }; | 877 }; |
890 | 878 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 | 977 |
990 protected: | 978 protected: |
991 friend class BackendDelegate; | 979 friend class BackendDelegate; |
992 | 980 |
993 // testing::Test | 981 // testing::Test |
994 void SetUp() override { | 982 void SetUp() override { |
995 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 983 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
996 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); | 984 history_dir_ = temp_dir_.path().AppendASCII("HistoryTest"); |
997 ASSERT_TRUE(base::CreateDirectory(history_dir_)); | 985 ASSERT_TRUE(base::CreateDirectory(history_dir_)); |
998 history_service_.reset(new history::HistoryService); | 986 history_service_.reset(new history::HistoryService); |
999 if (!history_service_->Init(std::string(), | 987 if (!history_service_->Init( |
1000 HistoryDatabaseParamsForPath(history_dir_))) { | 988 std::string(), TestHistoryDatabaseParamsForPath(history_dir_))) { |
1001 history_service_.reset(); | 989 history_service_.reset(); |
1002 ADD_FAILURE(); | 990 ADD_FAILURE(); |
1003 } | 991 } |
1004 } | 992 } |
1005 | 993 |
1006 void TearDown() override { | 994 void TearDown() override { |
1007 if (history_service_) | 995 if (history_service_) |
1008 CleanupHistoryService(); | 996 CleanupHistoryService(); |
1009 | 997 |
1010 // Make sure we don't have any event pending that could disrupt the next | 998 // Make sure we don't have any event pending that could disrupt the next |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 std::vector<PageUsageData*> results; | 1845 std::vector<PageUsageData*> results; |
1858 db_->QuerySegmentUsage(segment_time, 10, &results); | 1846 db_->QuerySegmentUsage(segment_time, 10, &results); |
1859 ASSERT_EQ(1u, results.size()); | 1847 ASSERT_EQ(1u, results.size()); |
1860 EXPECT_EQ(url, results[0]->GetURL()); | 1848 EXPECT_EQ(url, results[0]->GetURL()); |
1861 EXPECT_EQ(segment_id, results[0]->GetID()); | 1849 EXPECT_EQ(segment_id, results[0]->GetID()); |
1862 EXPECT_EQ(title, results[0]->GetTitle()); | 1850 EXPECT_EQ(title, results[0]->GetTitle()); |
1863 STLDeleteElements(&results); | 1851 STLDeleteElements(&results); |
1864 } | 1852 } |
1865 | 1853 |
1866 } // namespace history | 1854 } // namespace history |
OLD | NEW |