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