OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 23 matching lines...) Expand all Loading... |
34 #include "base/logging.h" | 34 #include "base/logging.h" |
35 #include "base/memory/scoped_ptr.h" | 35 #include "base/memory/scoped_ptr.h" |
36 #include "base/memory/scoped_vector.h" | 36 #include "base/memory/scoped_vector.h" |
37 #include "base/message_loop.h" | 37 #include "base/message_loop.h" |
38 #include "base/path_service.h" | 38 #include "base/path_service.h" |
39 #include "base/string_util.h" | 39 #include "base/string_util.h" |
40 #include "base/stringprintf.h" | 40 #include "base/stringprintf.h" |
41 #include "base/threading/platform_thread.h" | 41 #include "base/threading/platform_thread.h" |
42 #include "base/time.h" | 42 #include "base/time.h" |
43 #include "base/utf_string_conversions.h" | 43 #include "base/utf_string_conversions.h" |
| 44 #include "chrome/browser/favicon/favicon_changed_details.h" |
44 #include "chrome/browser/history/download_row.h" | 45 #include "chrome/browser/history/download_row.h" |
45 #include "chrome/browser/history/history_backend.h" | 46 #include "chrome/browser/history/history_backend.h" |
46 #include "chrome/browser/history/history_database.h" | 47 #include "chrome/browser/history/history_database.h" |
47 #include "chrome/browser/history/history_db_task.h" | 48 #include "chrome/browser/history/history_db_task.h" |
48 #include "chrome/browser/history/history_notifications.h" | 49 #include "chrome/browser/history/history_notifications.h" |
49 #include "chrome/browser/history/history_service.h" | 50 #include "chrome/browser/history/history_service.h" |
50 #include "chrome/browser/history/history_unittest_base.h" | 51 #include "chrome/browser/history/history_unittest_base.h" |
51 #include "chrome/browser/history/in_memory_database.h" | 52 #include "chrome/browser/history/in_memory_database.h" |
52 #include "chrome/browser/history/in_memory_history_backend.h" | 53 #include "chrome/browser/history/in_memory_history_backend.h" |
53 #include "chrome/browser/history/page_usage_data.h" | 54 #include "chrome/browser/history/page_usage_data.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 class BackendDelegate : public HistoryBackend::Delegate { | 86 class BackendDelegate : public HistoryBackend::Delegate { |
86 public: | 87 public: |
87 explicit BackendDelegate(HistoryBackendDBTest* history_test) | 88 explicit BackendDelegate(HistoryBackendDBTest* history_test) |
88 : history_test_(history_test) { | 89 : history_test_(history_test) { |
89 } | 90 } |
90 | 91 |
91 virtual void NotifyProfileError(int backend_id, | 92 virtual void NotifyProfileError(int backend_id, |
92 sql::InitStatus init_status) OVERRIDE {} | 93 sql::InitStatus init_status) OVERRIDE {} |
93 virtual void SetInMemoryBackend(int backend_id, | 94 virtual void SetInMemoryBackend(int backend_id, |
94 InMemoryHistoryBackend* backend) OVERRIDE; | 95 InMemoryHistoryBackend* backend) OVERRIDE; |
| 96 virtual void SendFaviconChangedNotification( |
| 97 chrome::FaviconChangedDetails* details) OVERRIDE; |
95 virtual void BroadcastNotifications(int type, | 98 virtual void BroadcastNotifications(int type, |
96 HistoryDetails* details) OVERRIDE; | 99 HistoryDetails* details) OVERRIDE; |
97 virtual void DBLoaded(int backend_id) OVERRIDE {} | 100 virtual void DBLoaded(int backend_id) OVERRIDE {} |
98 virtual void StartTopSitesMigration(int backend_id) OVERRIDE {} | 101 virtual void StartTopSitesMigration(int backend_id) OVERRIDE {} |
99 virtual void NotifyVisitDBObserversOnAddVisit( | 102 virtual void NotifyVisitDBObserversOnAddVisit( |
100 const BriefVisitInfo& info) OVERRIDE {} | 103 const BriefVisitInfo& info) OVERRIDE {} |
101 private: | 104 private: |
102 HistoryBackendDBTest* history_test_; | 105 HistoryBackendDBTest* history_test_; |
103 }; | 106 }; |
104 | 107 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 HistoryDatabase* db_; // Cached reference to the backend's database. | 196 HistoryDatabase* db_; // Cached reference to the backend's database. |
194 }; | 197 }; |
195 | 198 |
196 void BackendDelegate::SetInMemoryBackend(int backend_id, | 199 void BackendDelegate::SetInMemoryBackend(int backend_id, |
197 InMemoryHistoryBackend* backend) { | 200 InMemoryHistoryBackend* backend) { |
198 // Save the in-memory backend to the history test object, this happens | 201 // Save the in-memory backend to the history test object, this happens |
199 // synchronously, so we don't have to do anything fancy. | 202 // synchronously, so we don't have to do anything fancy. |
200 history_test_->in_mem_backend_.reset(backend); | 203 history_test_->in_mem_backend_.reset(backend); |
201 } | 204 } |
202 | 205 |
| 206 void BackendDelegate::SendFaviconChangedNotification( |
| 207 chrome::FaviconChangedDetails* details) { |
| 208 // The backend passes ownership of the details pointer to us. |
| 209 delete details; |
| 210 } |
| 211 |
203 void BackendDelegate::BroadcastNotifications(int type, | 212 void BackendDelegate::BroadcastNotifications(int type, |
204 HistoryDetails* details) { | 213 HistoryDetails* details) { |
205 // Currently, just send the notifications directly to the in-memory database. | 214 // Currently, just send the notifications directly to the in-memory database. |
206 // We may want do do something more fancy in the future. | 215 // We may want do do something more fancy in the future. |
207 content::Details<HistoryDetails> det(details); | 216 content::Details<HistoryDetails> det(details); |
208 history_test_->in_mem_backend_->Observe(type, | 217 history_test_->in_mem_backend_->Observe(type, |
209 content::Source<HistoryBackendDBTest>(NULL), det); | 218 content::Source<HistoryBackendDBTest>(NULL), det); |
210 | 219 |
211 // The backend passes ownership of the details pointer to us. | 220 // The backend passes ownership of the details pointer to us. |
212 delete details; | 221 delete details; |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 std::vector<PageUsageData*> results; | 1665 std::vector<PageUsageData*> results; |
1657 db_->QuerySegmentUsage(segment_time, 10, &results); | 1666 db_->QuerySegmentUsage(segment_time, 10, &results); |
1658 ASSERT_EQ(1u, results.size()); | 1667 ASSERT_EQ(1u, results.size()); |
1659 EXPECT_EQ(url, results[0]->GetURL()); | 1668 EXPECT_EQ(url, results[0]->GetURL()); |
1660 EXPECT_EQ(segment_id, results[0]->GetID()); | 1669 EXPECT_EQ(segment_id, results[0]->GetID()); |
1661 EXPECT_EQ(title, results[0]->GetTitle()); | 1670 EXPECT_EQ(title, results[0]->GetTitle()); |
1662 STLDeleteElements(&results); | 1671 STLDeleteElements(&results); |
1663 } | 1672 } |
1664 | 1673 |
1665 } // namespace history | 1674 } // namespace history |
OLD | NEW |