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. |
11 // | 11 // |
12 // 2. The simpler style is to create a history backend on this thread and | 12 // 2. The simpler style is to create a history backend on this thread and |
13 // access it directly without a HistoryService object. This is much simpler | 13 // access it directly without a HistoryService object. This is much simpler |
14 // because communication is synchronous. Generally, sets should go through | 14 // because communication is synchronous. Generally, sets should go through |
15 // the history backend (since there is a lot of logic) but gets can come | 15 // the history backend (since there is a lot of logic) but gets can come |
16 // directly from the HistoryDatabase. This is because the backend generally | 16 // directly from the HistoryDatabase. This is because the backend generally |
17 // has no logic in the getter except threading stuff, which we don't want | 17 // has no logic in the getter except threading stuff, which we don't want |
18 // to run. | 18 // to run. |
19 | 19 |
20 #include <time.h> | 20 #include <time.h> |
21 | 21 |
22 #include <algorithm> | 22 #include <algorithm> |
23 #include <string> | 23 #include <string> |
24 | 24 |
25 #include "app/sql/connection.h" | |
26 #include "app/sql/statement.h" | |
27 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
28 #include "base/callback.h" | 26 #include "base/callback.h" |
29 #include "base/command_line.h" | 27 #include "base/command_line.h" |
30 #include "base/file_path.h" | 28 #include "base/file_path.h" |
31 #include "base/file_util.h" | 29 #include "base/file_util.h" |
32 #include "base/memory/scoped_vector.h" | 30 #include "base/memory/scoped_vector.h" |
33 #include "base/message_loop.h" | 31 #include "base/message_loop.h" |
34 #include "base/path_service.h" | 32 #include "base/path_service.h" |
35 #include "base/scoped_temp_dir.h" | 33 #include "base/scoped_temp_dir.h" |
36 #include "base/string_util.h" | 34 #include "base/string_util.h" |
37 #include "base/task.h" | 35 #include "base/task.h" |
38 #include "base/utf_string_conversions.h" | 36 #include "base/utf_string_conversions.h" |
39 #include "chrome/browser/download/download_item.h" | 37 #include "chrome/browser/download/download_item.h" |
40 #include "chrome/browser/history/download_history_info.h" | 38 #include "chrome/browser/history/download_history_info.h" |
41 #include "chrome/browser/history/history.h" | 39 #include "chrome/browser/history/history.h" |
42 #include "chrome/browser/history/history_backend.h" | 40 #include "chrome/browser/history/history_backend.h" |
43 #include "chrome/browser/history/history_database.h" | 41 #include "chrome/browser/history/history_database.h" |
44 #include "chrome/browser/history/history_notifications.h" | 42 #include "chrome/browser/history/history_notifications.h" |
45 #include "chrome/browser/history/in_memory_database.h" | 43 #include "chrome/browser/history/in_memory_database.h" |
46 #include "chrome/browser/history/in_memory_history_backend.h" | 44 #include "chrome/browser/history/in_memory_history_backend.h" |
47 #include "chrome/browser/history/page_usage_data.h" | 45 #include "chrome/browser/history/page_usage_data.h" |
48 #include "chrome/common/chrome_paths.h" | 46 #include "chrome/common/chrome_paths.h" |
49 #include "chrome/common/thumbnail_score.h" | 47 #include "chrome/common/thumbnail_score.h" |
50 #include "chrome/tools/profiles/thumbnail-inl.h" | 48 #include "chrome/tools/profiles/thumbnail-inl.h" |
51 #include "content/common/notification_details.h" | 49 #include "content/common/notification_details.h" |
52 #include "content/common/notification_source.h" | 50 #include "content/common/notification_source.h" |
| 51 #include "sql/connection.h" |
| 52 #include "sql/statement.h" |
53 #include "testing/gtest/include/gtest/gtest.h" | 53 #include "testing/gtest/include/gtest/gtest.h" |
54 #include "third_party/skia/include/core/SkBitmap.h" | 54 #include "third_party/skia/include/core/SkBitmap.h" |
55 #include "ui/gfx/codec/jpeg_codec.h" | 55 #include "ui/gfx/codec/jpeg_codec.h" |
56 | 56 |
57 using base::Time; | 57 using base::Time; |
58 using base::TimeDelta; | 58 using base::TimeDelta; |
59 | 59 |
60 namespace history { | 60 namespace history { |
61 class HistoryTest; | 61 class HistoryTest; |
62 } | 62 } |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 history_service_ = history; | 855 history_service_ = history; |
856 history->ScheduleDBTask(task.get(), &request_consumer); | 856 history->ScheduleDBTask(task.get(), &request_consumer); |
857 request_consumer.CancelAllRequests(); | 857 request_consumer.CancelAllRequests(); |
858 CleanupHistoryService(); | 858 CleanupHistoryService(); |
859 // WARNING: history has now been deleted. | 859 // WARNING: history has now been deleted. |
860 history = NULL; | 860 history = NULL; |
861 ASSERT_FALSE(task->done_invoked); | 861 ASSERT_FALSE(task->done_invoked); |
862 } | 862 } |
863 | 863 |
864 } // namespace history | 864 } // namespace history |
OLD | NEW |