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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 virtual void TearDown() { | 163 virtual void TearDown() { |
164 DeleteBackend(); | 164 DeleteBackend(); |
165 | 165 |
166 if (history_service_) | 166 if (history_service_) |
167 CleanupHistoryService(); | 167 CleanupHistoryService(); |
168 | 168 |
169 // Make sure we don't have any event pending that could disrupt the next | 169 // Make sure we don't have any event pending that could disrupt the next |
170 // test. | 170 // test. |
171 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 171 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
172 MessageLoop::current()->Run(); | 172 MessageLoop::current()->Run(); |
173 } | 173 } |
174 | 174 |
175 void CleanupHistoryService() { | 175 void CleanupHistoryService() { |
176 DCHECK(history_service_.get()); | 176 DCHECK(history_service_.get()); |
177 | 177 |
178 history_service_->NotifyRenderProcessHostDestruction(0); | 178 history_service_->NotifyRenderProcessHostDestruction(0); |
179 history_service_->SetOnBackendDestroyTask(new MessageLoop::QuitTask); | 179 history_service_->SetOnBackendDestroyTask(MessageLoop::QuitClosure()); |
180 history_service_->Cleanup(); | 180 history_service_->Cleanup(); |
181 history_service_ = NULL; | 181 history_service_ = NULL; |
182 | 182 |
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 |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 history_service_ = history; | 958 history_service_ = history; |
959 history->ScheduleDBTask(task.get(), &request_consumer); | 959 history->ScheduleDBTask(task.get(), &request_consumer); |
960 request_consumer.CancelAllRequests(); | 960 request_consumer.CancelAllRequests(); |
961 CleanupHistoryService(); | 961 CleanupHistoryService(); |
962 // WARNING: history has now been deleted. | 962 // WARNING: history has now been deleted. |
963 history = NULL; | 963 history = NULL; |
964 ASSERT_FALSE(task->done_invoked); | 964 ASSERT_FALSE(task->done_invoked); |
965 } | 965 } |
966 | 966 |
967 } // namespace history | 967 } // namespace history |
OLD | NEW |