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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "ui/gfx/codec/jpeg_codec.h" | 57 #include "ui/gfx/codec/jpeg_codec.h" |
58 | 58 |
59 using base::Time; | 59 using base::Time; |
60 using base::TimeDelta; | 60 using base::TimeDelta; |
61 using content::DownloadItem; | 61 using content::DownloadItem; |
62 | 62 |
63 namespace history { | 63 namespace history { |
64 class HistoryTest; | 64 class HistoryTest; |
65 } | 65 } |
66 | 66 |
67 // Specialize RunnableMethodTraits for HistoryTest so we can create callbacks. | |
68 // None of these callbacks can outlast the test, so there is not need to retain | |
69 // the HistoryTest object. | |
70 DISABLE_RUNNABLE_METHOD_REFCOUNT(history::HistoryTest); | |
71 | |
72 namespace history { | 67 namespace history { |
73 | 68 |
74 namespace { | 69 namespace { |
75 | 70 |
76 // The tracker uses RenderProcessHost pointers for scoping but never | 71 // The tracker uses RenderProcessHost pointers for scoping but never |
77 // dereferences them. We use ints because it's easier. This function converts | 72 // dereferences them. We use ints because it's easier. This function converts |
78 // between the two. | 73 // between the two. |
79 static void* MakeFakeHost(int id) { | 74 static void* MakeFakeHost(int id) { |
80 void* host = 0; | 75 void* host = 0; |
81 memcpy(&host, &id, sizeof(id)); | 76 memcpy(&host, &id, sizeof(id)); |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 history_service_ = history; | 954 history_service_ = history; |
960 history->ScheduleDBTask(task.get(), &request_consumer); | 955 history->ScheduleDBTask(task.get(), &request_consumer); |
961 request_consumer.CancelAllRequests(); | 956 request_consumer.CancelAllRequests(); |
962 CleanupHistoryService(); | 957 CleanupHistoryService(); |
963 // WARNING: history has now been deleted. | 958 // WARNING: history has now been deleted. |
964 history = NULL; | 959 history = NULL; |
965 ASSERT_FALSE(task->done_invoked); | 960 ASSERT_FALSE(task->done_invoked); |
966 } | 961 } |
967 | 962 |
968 } // namespace history | 963 } // namespace history |
OLD | NEW |