| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 redirect_query_success_(false), | 107 redirect_query_success_(false), |
| 108 query_url_success_(false), | 108 query_url_success_(false), |
| 109 db_(NULL) { | 109 db_(NULL) { |
| 110 } | 110 } |
| 111 ~HistoryTest() { | 111 ~HistoryTest() { |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Creates the HistoryBackend and HistoryDatabase on the current thread, | 114 // Creates the HistoryBackend and HistoryDatabase on the current thread, |
| 115 // assigning the values to backend_ and db_. | 115 // assigning the values to backend_ and db_. |
| 116 void CreateBackendAndDatabase() { | 116 void CreateBackendAndDatabase() { |
| 117 backend_ = | 117 backend_ = new HistoryBackend(NULL, history_dir_, 0, |
| 118 new HistoryBackend(history_dir_, 0, new BackendDelegate(this), NULL); | 118 new BackendDelegate(this), NULL); |
| 119 backend_->Init(std::string(), false); | 119 backend_->Init(std::string(), false); |
| 120 db_ = backend_->db_.get(); | 120 db_ = backend_->db_.get(); |
| 121 DCHECK(in_mem_backend_.get()) << "Mem backend should have been set by " | 121 DCHECK(in_mem_backend_.get()) << "Mem backend should have been set by " |
| 122 "HistoryBackend::Init"; | 122 "HistoryBackend::Init"; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, | 125 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, |
| 126 std::vector<PageUsageData*>* data) { | 126 std::vector<PageUsageData*>* data) { |
| 127 page_usage_data_->swap(*data); | 127 page_usage_data_->swap(*data); |
| 128 MessageLoop::current()->Quit(); | 128 MessageLoop::current()->Quit(); |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 history_service_ = history; | 953 history_service_ = history; |
| 954 history->ScheduleDBTask(task.get(), &request_consumer); | 954 history->ScheduleDBTask(task.get(), &request_consumer); |
| 955 request_consumer.CancelAllRequests(); | 955 request_consumer.CancelAllRequests(); |
| 956 CleanupHistoryService(); | 956 CleanupHistoryService(); |
| 957 // WARNING: history has now been deleted. | 957 // WARNING: history has now been deleted. |
| 958 history = NULL; | 958 history = NULL; |
| 959 ASSERT_FALSE(task->done_invoked); | 959 ASSERT_FALSE(task->done_invoked); |
| 960 } | 960 } |
| 961 | 961 |
| 962 } // namespace history | 962 } // namespace history |
| OLD | NEW |