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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 redirect_query_success_(false), | 112 redirect_query_success_(false), |
113 query_url_success_(false), | 113 query_url_success_(false), |
114 db_(NULL) { | 114 db_(NULL) { |
115 } | 115 } |
116 ~HistoryTest() { | 116 ~HistoryTest() { |
117 } | 117 } |
118 | 118 |
119 // Creates the HistoryBackend and HistoryDatabase on the current thread, | 119 // Creates the HistoryBackend and HistoryDatabase on the current thread, |
120 // assigning the values to backend_ and db_. | 120 // assigning the values to backend_ and db_. |
121 void CreateBackendAndDatabase() { | 121 void CreateBackendAndDatabase() { |
122 backend_ = | 122 backend_ = new HistoryBackend(NULL, history_dir_, 0, |
123 new HistoryBackend(history_dir_, 0, new BackendDelegate(this), NULL); | 123 new BackendDelegate(this), NULL); |
124 backend_->Init(std::string(), false); | 124 backend_->Init(std::string(), false); |
125 db_ = backend_->db_.get(); | 125 db_ = backend_->db_.get(); |
126 DCHECK(in_mem_backend_.get()) << "Mem backend should have been set by " | 126 DCHECK(in_mem_backend_.get()) << "Mem backend should have been set by " |
127 "HistoryBackend::Init"; | 127 "HistoryBackend::Init"; |
128 } | 128 } |
129 | 129 |
130 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, | 130 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, |
131 std::vector<PageUsageData*>* data) { | 131 std::vector<PageUsageData*>* data) { |
132 page_usage_data_->swap(*data); | 132 page_usage_data_->swap(*data); |
133 MessageLoop::current()->Quit(); | 133 MessageLoop::current()->Quit(); |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 history_service_ = history; | 871 history_service_ = history; |
872 history->ScheduleDBTask(task.get(), &request_consumer); | 872 history->ScheduleDBTask(task.get(), &request_consumer); |
873 request_consumer.CancelAllRequests(); | 873 request_consumer.CancelAllRequests(); |
874 CleanupHistoryService(); | 874 CleanupHistoryService(); |
875 // WARNING: history has now been deleted. | 875 // WARNING: history has now been deleted. |
876 history = NULL; | 876 history = NULL; |
877 ASSERT_FALSE(task->done_invoked); | 877 ASSERT_FALSE(task->done_invoked); |
878 } | 878 } |
879 | 879 |
880 } // namespace history | 880 } // namespace history |
OLD | NEW |