| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // Wait for the backend class to terminate before deleting the files and | 183 // Wait for the backend class to terminate before deleting the files and |
| 184 // moving to the next test. Note: if this never terminates, somebody is | 184 // moving to the next test. Note: if this never terminates, somebody is |
| 185 // probably leaking a reference to the history backend, so it never calls | 185 // probably leaking a reference to the history backend, so it never calls |
| 186 // our destroy task. | 186 // our destroy task. |
| 187 MessageLoop::current()->Run(); | 187 MessageLoop::current()->Run(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 int64 AddDownload(int32 state, const Time& time) { | 190 int64 AddDownload(int32 state, const Time& time) { |
| 191 DownloadPersistentStoreInfo download( | 191 DownloadPersistentStoreInfo download( |
| 192 FilePath(FILE_PATH_LITERAL("foo-path")), | 192 FilePath(FILE_PATH_LITERAL("foo-path")), |
| 193 FilePath(), |
| 193 GURL("foo-url"), | 194 GURL("foo-url"), |
| 194 GURL(""), | 195 GURL(""), |
| 195 time, | 196 time, |
| 196 time, | 197 time, |
| 197 0, | 198 0, |
| 198 512, | 199 512, |
| 199 state, | 200 state, |
| 200 0, | 201 0, |
| 201 0); | 202 false, |
| 203 "", |
| 204 "", |
| 205 "", |
| 206 DOWNLOAD_INTERRUPT_REASON_NONE); |
| 202 return db_->CreateDownload(download); | 207 return db_->CreateDownload(download); |
| 203 } | 208 } |
| 204 | 209 |
| 205 // Fills the query_url_row_ and query_url_visits_ structures with the | 210 // Fills the query_url_row_ and query_url_visits_ structures with the |
| 206 // information about the given URL and returns true. If the URL was not | 211 // information about the given URL and returns true. If the URL was not |
| 207 // found, this will return false and those structures will not be changed. | 212 // found, this will return false and those structures will not be changed. |
| 208 bool QueryURL(HistoryService* history, const GURL& url) { | 213 bool QueryURL(HistoryService* history, const GURL& url) { |
| 209 history->QueryURL(url, true, &consumer_, | 214 history->QueryURL(url, true, &consumer_, |
| 210 base::Bind(&HistoryTest::SaveURLAndQuit, | 215 base::Bind(&HistoryTest::SaveURLAndQuit, |
| 211 base::Unretained(this))); | 216 base::Unretained(this))); |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 history_service_ = history; | 963 history_service_ = history; |
| 959 history->ScheduleDBTask(task.get(), &request_consumer); | 964 history->ScheduleDBTask(task.get(), &request_consumer); |
| 960 request_consumer.CancelAllRequests(); | 965 request_consumer.CancelAllRequests(); |
| 961 CleanupHistoryService(); | 966 CleanupHistoryService(); |
| 962 // WARNING: history has now been deleted. | 967 // WARNING: history has now been deleted. |
| 963 history = NULL; | 968 history = NULL; |
| 964 ASSERT_FALSE(task->done_invoked); | 969 ASSERT_FALSE(task->done_invoked); |
| 965 } | 970 } |
| 966 | 971 |
| 967 } // namespace history | 972 } // namespace history |
| OLD | NEW |