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 #include <set> | 5 #include <set> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } // namepace | 48 } // namepace |
49 | 49 |
50 namespace history { | 50 namespace history { |
51 | 51 |
52 class HistoryBackendTest; | 52 class HistoryBackendTest; |
53 | 53 |
54 // This must be a separate object since HistoryBackend manages its lifetime. | 54 // This must be a separate object since HistoryBackend manages its lifetime. |
55 // This just forwards the messages we're interested in to the test object. | 55 // This just forwards the messages we're interested in to the test object. |
56 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { | 56 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { |
57 public: | 57 public: |
58 explicit HistoryBackendTestDelegate(HistoryBackendTest* test); | 58 explicit HistoryBackendTestDelegate(HistoryBackendTest* test) : test_(test) {} |
59 | 59 |
60 virtual void NotifyProfileError(int backend_id, | 60 virtual void NotifyProfileError(int backend_id, |
61 sql::InitStatus init_status) OVERRIDE; | 61 sql::InitStatus init_status) OVERRIDE {} |
62 virtual void SetInMemoryBackend(int backend_id, | 62 virtual void SetInMemoryBackend(int backend_id, |
63 InMemoryHistoryBackend* backend) OVERRIDE; | 63 InMemoryHistoryBackend* backend) OVERRIDE; |
64 virtual void BroadcastNotifications(int type, | 64 virtual void BroadcastNotifications(int type, |
65 HistoryDetails* details) OVERRIDE; | 65 HistoryDetails* details) OVERRIDE; |
66 virtual void DBLoaded(int backend_id) OVERRIDE; | 66 virtual void DBLoaded(int backend_id) OVERRIDE; |
67 virtual void StartTopSitesMigration(int backend_id) OVERRIDE; | 67 virtual void StartTopSitesMigration(int backend_id) OVERRIDE; |
68 virtual void NotifyVisitDBObserversOnAddVisit( | 68 virtual void NotifyVisitDBObserversOnAddVisit( |
69 const BriefVisitInfo& info) OVERRIDE; | 69 const BriefVisitInfo& info) OVERRIDE {} |
70 | 70 |
71 private: | 71 private: |
72 // Not owned by us. | 72 // Not owned by us. |
73 HistoryBackendTest* test_; | 73 HistoryBackendTest* test_; |
74 | 74 |
75 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); | 75 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); |
76 }; | 76 }; |
77 | 77 |
78 class HistoryBackendCancelableRequest : public CancelableRequestProvider, | 78 class HistoryBackendCancelableRequest : public CancelableRequestProvider, |
79 public CancelableRequestConsumerBase { | 79 public CancelableRequestConsumerBase { |
80 public: | 80 public: |
81 HistoryBackendCancelableRequest(); | 81 HistoryBackendCancelableRequest() {} |
82 | 82 |
83 // CancelableRequestConsumerBase overrides: | 83 // CancelableRequestConsumerBase overrides: |
84 virtual void OnRequestAdded( | 84 virtual void OnRequestAdded( |
85 CancelableRequestProvider* provider, | 85 CancelableRequestProvider* provider, |
86 CancelableRequestProvider::Handle handle) OVERRIDE; | 86 CancelableRequestProvider::Handle handle) OVERRIDE {} |
87 virtual void OnRequestRemoved( | 87 virtual void OnRequestRemoved( |
88 CancelableRequestProvider* provider, | 88 CancelableRequestProvider* provider, |
89 CancelableRequestProvider::Handle handle) OVERRIDE; | 89 CancelableRequestProvider::Handle handle) OVERRIDE {} |
90 virtual void WillExecute( | 90 virtual void WillExecute( |
91 CancelableRequestProvider* provider, | 91 CancelableRequestProvider* provider, |
92 CancelableRequestProvider::Handle handle) OVERRIDE; | 92 CancelableRequestProvider::Handle handle) OVERRIDE {} |
93 virtual void DidExecute( | 93 virtual void DidExecute( |
94 CancelableRequestProvider* provider, | 94 CancelableRequestProvider* provider, |
95 CancelableRequestProvider::Handle handle) OVERRIDE; | 95 CancelableRequestProvider::Handle handle) OVERRIDE {} |
96 | 96 |
97 template<class RequestType> | 97 template<class RequestType> |
98 CancelableRequestProvider::Handle MockScheduleOfRequest( | 98 CancelableRequestProvider::Handle MockScheduleOfRequest( |
99 RequestType* request) { | 99 RequestType* request) { |
100 AddRequest(request, this); | 100 AddRequest(request, this); |
101 return request->handle(); | 101 return request->handle(); |
102 } | 102 } |
103 }; | 103 }; |
104 | 104 |
105 class HistoryBackendTest : public testing::Test { | 105 class HistoryBackendTest : public testing::Test { |
106 public: | 106 public: |
107 HistoryBackendTest(); | 107 HistoryBackendTest() : bookmark_model_(NULL), loaded_(false) {} |
108 virtual ~HistoryBackendTest(); | 108 virtual ~HistoryBackendTest() { |
| 109 } |
109 | 110 |
110 // Callback for QueryMostVisited. | 111 // Callback for QueryMostVisited. |
111 void OnQueryMostVisited(CancelableRequestProvider::Handle handle, | 112 void OnQueryMostVisited(CancelableRequestProvider::Handle handle, |
112 history::MostVisitedURLList data); | 113 history::MostVisitedURLList data) { |
| 114 most_visited_list_.swap(data); |
| 115 } |
113 | 116 |
114 // Callback for QueryFiltered. | 117 // Callback for QueryFiltered. |
115 void OnQueryFiltered(CancelableRequestProvider::Handle handle, | 118 void OnQueryFiltered(CancelableRequestProvider::Handle handle, |
116 const history::FilteredURLList& data); | 119 const history::FilteredURLList& data) { |
| 120 filtered_list_ = data; |
| 121 } |
117 | 122 |
118 const history::MostVisitedURLList& get_most_visited_list() const { | 123 const history::MostVisitedURLList& get_most_visited_list() const { |
119 return most_visited_list_; | 124 return most_visited_list_; |
120 } | 125 } |
121 | 126 |
122 const history::FilteredURLList& get_filtered_list() const { | 127 const history::FilteredURLList& get_filtered_list() const { |
123 return filtered_list_; | 128 return filtered_list_; |
124 } | 129 } |
125 | 130 |
126 protected: | 131 protected: |
127 void AddRedirectChain(const char* sequence[], int page_id); | 132 scoped_refptr<HistoryBackend> backend_; // Will be NULL on init failure. |
| 133 scoped_ptr<InMemoryHistoryBackend> mem_backend_; |
128 | 134 |
129 void AddRedirectChainWithTransitionAndTime(const char* sequence[], | 135 void AddRedirectChain(const char* sequence[], int page_id) { |
130 int page_id, | 136 AddRedirectChainWithTransitionAndTime(sequence, page_id, |
131 content::PageTransition transition, | 137 content::PAGE_TRANSITION_LINK, |
132 base::Time time); | 138 Time::Now()); |
| 139 } |
| 140 |
| 141 void AddRedirectChainWithTransitionAndTime( |
| 142 const char* sequence[], |
| 143 int page_id, |
| 144 content::PageTransition transition, |
| 145 base::Time time) { |
| 146 history::RedirectList redirects; |
| 147 for (int i = 0; sequence[i] != NULL; ++i) |
| 148 redirects.push_back(GURL(sequence[i])); |
| 149 |
| 150 int int_scope = 1; |
| 151 void* scope = 0; |
| 152 memcpy(&scope, &int_scope, sizeof(int_scope)); |
| 153 scoped_refptr<history::HistoryAddPageArgs> request( |
| 154 new history::HistoryAddPageArgs( |
| 155 redirects.back(), time, scope, page_id, GURL(), |
| 156 redirects, transition, history::SOURCE_BROWSED, |
| 157 true)); |
| 158 backend_->AddPage(request); |
| 159 } |
133 | 160 |
134 // Adds CLIENT_REDIRECT page transition. | 161 // Adds CLIENT_REDIRECT page transition. |
135 // |url1| is the source URL and |url2| is the destination. | 162 // |url1| is the source URL and |url2| is the destination. |
136 // |did_replace| is true if the transition is non-user initiated and the | 163 // |did_replace| is true if the transition is non-user initiated and the |
137 // navigation entry for |url2| has replaced that for |url1|. The possibly | 164 // navigation entry for |url2| has replaced that for |url1|. The possibly |
138 // updated transition code of the visit records for |url1| and |url2| is | 165 // updated transition code of the visit records for |url1| and |url2| is |
139 // returned by filling in |*transition1| and |*transition2|, respectively. | 166 // returned by filling in |*transition1| and |*transition2|, respectively. |
140 // |time| is a time of the redirect. | 167 // |time| is a time of the redirect. |
141 void AddClientRedirect(const GURL& url1, | 168 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace, |
142 const GURL& url2, | |
143 bool did_replace, | |
144 base::Time time, | 169 base::Time time, |
145 int* transition1, | 170 int* transition1, int* transition2) { |
146 int* transition2); | 171 void* const dummy_scope = reinterpret_cast<void*>(0x87654321); |
| 172 history::RedirectList redirects; |
| 173 if (url1.is_valid()) |
| 174 redirects.push_back(url1); |
| 175 if (url2.is_valid()) |
| 176 redirects.push_back(url2); |
| 177 scoped_refptr<HistoryAddPageArgs> request( |
| 178 new HistoryAddPageArgs(url2, time, dummy_scope, 0, url1, |
| 179 redirects, content::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 180 history::SOURCE_BROWSED, did_replace)); |
| 181 backend_->AddPage(request); |
147 | 182 |
148 int GetTransition(const GURL& url); | 183 *transition1 = getTransition(url1); |
| 184 *transition2 = getTransition(url2); |
| 185 } |
149 | 186 |
150 FilePath get_test_dir() { return test_dir_; } | 187 int getTransition(const GURL& url) { |
| 188 if (!url.is_valid()) |
| 189 return 0; |
| 190 URLRow row; |
| 191 URLID id = backend_->db()->GetRowForURL(url, &row); |
| 192 VisitVector visits; |
| 193 EXPECT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); |
| 194 return visits[0].transition; |
| 195 } |
151 | 196 |
152 FaviconID GetFavicon(const GURL& url, IconType icon_type); | 197 FilePath getTestDir() { |
| 198 return test_dir_; |
| 199 } |
153 | 200 |
154 scoped_refptr<HistoryBackend> backend_; // Will be NULL on init failure. | 201 FaviconID GetFavicon(const GURL& url, IconType icon_type) { |
155 scoped_ptr<InMemoryHistoryBackend> mem_backend_; | 202 IconMapping icon_mapping; |
| 203 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, |
| 204 &icon_mapping)) |
| 205 return icon_mapping.icon_id; |
| 206 else |
| 207 return 0; |
| 208 } |
| 209 |
156 BookmarkModel bookmark_model_; | 210 BookmarkModel bookmark_model_; |
| 211 |
| 212 protected: |
157 bool loaded_; | 213 bool loaded_; |
158 | 214 |
159 private: | 215 private: |
160 friend class HistoryBackendTestDelegate; | 216 friend class HistoryBackendTestDelegate; |
161 | 217 |
162 // testing::Test | 218 // testing::Test |
163 virtual void SetUp(); | 219 virtual void SetUp() { |
164 virtual void TearDown(); | 220 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), |
| 221 &test_dir_)) |
| 222 return; |
| 223 backend_ = new HistoryBackend(test_dir_, |
| 224 0, |
| 225 new HistoryBackendTestDelegate(this), |
| 226 &bookmark_model_); |
| 227 backend_->Init(std::string(), false); |
| 228 } |
| 229 virtual void TearDown() { |
| 230 if (backend_.get()) |
| 231 backend_->Closing(); |
| 232 backend_ = NULL; |
| 233 mem_backend_.reset(); |
| 234 file_util::Delete(test_dir_, true); |
| 235 } |
165 | 236 |
166 void SetInMemoryBackend(int backend_id, InMemoryHistoryBackend* backend); | 237 void SetInMemoryBackend(int backend_id, InMemoryHistoryBackend* backend) { |
| 238 mem_backend_.reset(backend); |
| 239 } |
167 | 240 |
168 void BroadcastNotifications(int type, HistoryDetails* details); | 241 void BroadcastNotifications(int type, |
| 242 HistoryDetails* details) { |
| 243 // Send the notifications directly to the in-memory database. |
| 244 content::Details<HistoryDetails> det(details); |
| 245 mem_backend_->Observe(type, content::Source<HistoryBackendTest>(NULL), det); |
| 246 |
| 247 // The backend passes ownership of the details pointer to us. |
| 248 delete details; |
| 249 } |
169 | 250 |
170 MessageLoop message_loop_; | 251 MessageLoop message_loop_; |
171 FilePath test_dir_; | 252 FilePath test_dir_; |
172 history::MostVisitedURLList most_visited_list_; | 253 history::MostVisitedURLList most_visited_list_; |
173 history::FilteredURLList filtered_list_; | 254 history::FilteredURLList filtered_list_; |
174 }; | 255 }; |
175 | 256 |
176 // HistoryBackendTestDelegate -------------------------------------------------- | |
177 | |
178 HistoryBackendTestDelegate::HistoryBackendTestDelegate(HistoryBackendTest* test) | |
179 : test_(test) { | |
180 } | |
181 | |
182 void HistoryBackendTestDelegate::NotifyProfileError(int backend_id, | |
183 sql::InitStatus init_status) { | |
184 } | |
185 | |
186 void HistoryBackendTestDelegate::NotifyVisitDBObserversOnAddVisit( | |
187 const BriefVisitInfo& info) { | |
188 } | |
189 | |
190 void HistoryBackendTestDelegate::SetInMemoryBackend(int backend_id, | 257 void HistoryBackendTestDelegate::SetInMemoryBackend(int backend_id, |
191 InMemoryHistoryBackend* backend) { | 258 InMemoryHistoryBackend* backend) { |
192 test_->SetInMemoryBackend(backend_id, backend); | 259 test_->SetInMemoryBackend(backend_id, backend); |
193 } | 260 } |
194 | 261 |
195 void HistoryBackendTestDelegate::BroadcastNotifications( | 262 void HistoryBackendTestDelegate::BroadcastNotifications( |
196 int type, | 263 int type, |
197 HistoryDetails* details) { | 264 HistoryDetails* details) { |
198 test_->BroadcastNotifications(type, details); | 265 test_->BroadcastNotifications(type, details); |
199 } | 266 } |
200 | 267 |
201 void HistoryBackendTestDelegate::DBLoaded(int backend_id) { | 268 void HistoryBackendTestDelegate::DBLoaded(int backend_id) { |
202 test_->loaded_ = true; | 269 test_->loaded_ = true; |
203 } | 270 } |
204 | 271 |
205 void HistoryBackendTestDelegate::StartTopSitesMigration(int backend_id) { | 272 void HistoryBackendTestDelegate::StartTopSitesMigration(int backend_id) { |
206 test_->backend_->MigrateThumbnailsDatabase(); | 273 test_->backend_->MigrateThumbnailsDatabase(); |
207 } | 274 } |
208 | 275 |
209 // HistoryBackendCancelableRequest --------------------------------------------- | |
210 | |
211 HistoryBackendCancelableRequest::HistoryBackendCancelableRequest() {} | |
212 | |
213 void HistoryBackendCancelableRequest::OnRequestAdded( | |
214 CancelableRequestProvider* provider, | |
215 CancelableRequestProvider::Handle handle) {} | |
216 void HistoryBackendCancelableRequest::OnRequestRemoved( | |
217 CancelableRequestProvider* provider, | |
218 CancelableRequestProvider::Handle handle) {} | |
219 void HistoryBackendCancelableRequest::WillExecute( | |
220 CancelableRequestProvider* provider, | |
221 CancelableRequestProvider::Handle handle) {} | |
222 void HistoryBackendCancelableRequest::DidExecute( | |
223 CancelableRequestProvider* provider, | |
224 CancelableRequestProvider::Handle handle) {} | |
225 | |
226 // HistoryBackendTest ---------------------------------------------------------- | |
227 | |
228 HistoryBackendTest::HistoryBackendTest() | |
229 : bookmark_model_(NULL), | |
230 loaded_(false) { | |
231 } | |
232 | |
233 HistoryBackendTest::~HistoryBackendTest() {} | |
234 | |
235 void HistoryBackendTest::OnQueryMostVisited( | |
236 CancelableRequestProvider::Handle handle, | |
237 history::MostVisitedURLList data) { | |
238 most_visited_list_.swap(data); | |
239 } | |
240 | |
241 void HistoryBackendTest::OnQueryFiltered( | |
242 CancelableRequestProvider::Handle handle, | |
243 const history::FilteredURLList& data) { | |
244 filtered_list_ = data; | |
245 } | |
246 | |
247 void HistoryBackendTest::AddRedirectChain(const char* sequence[], int page_id) { | |
248 AddRedirectChainWithTransitionAndTime(sequence, page_id, | |
249 content::PAGE_TRANSITION_LINK, | |
250 Time::Now()); | |
251 } | |
252 | |
253 void HistoryBackendTest::AddRedirectChainWithTransitionAndTime( | |
254 const char* sequence[], | |
255 int page_id, | |
256 content::PageTransition transition, | |
257 base::Time time) { | |
258 history::RedirectList redirects; | |
259 for (int i = 0; sequence[i] != NULL; ++i) | |
260 redirects.push_back(GURL(sequence[i])); | |
261 | |
262 int int_scope = 1; | |
263 void* scope = 0; | |
264 memcpy(&scope, &int_scope, sizeof(int_scope)); | |
265 scoped_refptr<history::HistoryAddPageArgs> request( | |
266 new history::HistoryAddPageArgs(redirects.back(), time, scope, page_id, | |
267 GURL(), redirects, transition, | |
268 history::SOURCE_BROWSED, true)); | |
269 backend_->AddPage(request); | |
270 } | |
271 | |
272 void HistoryBackendTest::AddClientRedirect(const GURL& url1, | |
273 const GURL& url2, | |
274 bool did_replace, | |
275 base::Time time, | |
276 int* transition1, | |
277 int* transition2) { | |
278 void* const dummy_scope = reinterpret_cast<void*>(0x87654321); | |
279 history::RedirectList redirects; | |
280 if (url1.is_valid()) | |
281 redirects.push_back(url1); | |
282 if (url2.is_valid()) | |
283 redirects.push_back(url2); | |
284 scoped_refptr<HistoryAddPageArgs> request( | |
285 new HistoryAddPageArgs(url2, time, dummy_scope, 0, url1, | |
286 redirects, content::PAGE_TRANSITION_CLIENT_REDIRECT, | |
287 history::SOURCE_BROWSED, did_replace)); | |
288 backend_->AddPage(request); | |
289 | |
290 *transition1 = GetTransition(url1); | |
291 *transition2 = GetTransition(url2); | |
292 } | |
293 | |
294 int HistoryBackendTest::GetTransition(const GURL& url) { | |
295 if (!url.is_valid()) | |
296 return 0; | |
297 URLRow row; | |
298 URLID id = backend_->db()->GetRowForURL(url, &row); | |
299 VisitVector visits; | |
300 EXPECT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); | |
301 return visits[0].transition; | |
302 } | |
303 | |
304 FaviconID HistoryBackendTest::GetFavicon(const GURL& url, IconType icon_type) { | |
305 IconMapping icon_mapping; | |
306 return backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, | |
307 &icon_mapping) ? icon_mapping.icon_id : 0; | |
308 } | |
309 | |
310 void HistoryBackendTest::SetUp() { | |
311 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), | |
312 &test_dir_)) | |
313 return; | |
314 backend_ = new HistoryBackend(test_dir_, | |
315 0, | |
316 new HistoryBackendTestDelegate(this), | |
317 &bookmark_model_); | |
318 backend_->Init(std::string(), false); | |
319 } | |
320 | |
321 void HistoryBackendTest::TearDown() { | |
322 if (backend_.get()) | |
323 backend_->Closing(); | |
324 backend_ = NULL; | |
325 mem_backend_.reset(); | |
326 file_util::Delete(test_dir_, true); | |
327 } | |
328 | |
329 void HistoryBackendTest::SetInMemoryBackend(int backend_id, | |
330 InMemoryHistoryBackend* backend) { | |
331 mem_backend_.reset(backend); | |
332 } | |
333 | |
334 void HistoryBackendTest::BroadcastNotifications(int type, | |
335 HistoryDetails* details) { | |
336 // Send the notifications directly to the in-memory database. | |
337 content::Details<HistoryDetails> det(details); | |
338 mem_backend_->Observe(type, content::Source<HistoryBackendTest>(NULL), det); | |
339 | |
340 // The backend passes ownership of the details pointer to us. | |
341 delete details; | |
342 } | |
343 | |
344 // http://crbug.com/114287 | 276 // http://crbug.com/114287 |
345 #if defined(OS_WIN) | 277 #if defined(OS_WIN) |
346 #define MAYBE_Loaded DISABLED_Loaded | 278 #define MAYBE_Loaded DISABLED_Loaded |
347 #else | 279 #else |
348 #define MAYBE_Loaded Loaded | 280 #define MAYBE_Loaded Loaded |
349 #endif // defined(OS_WIN) | 281 #endif // defined(OS_WIN) |
350 TEST_F(HistoryBackendTest, MAYBE_Loaded) { | 282 TEST_F(HistoryBackendTest, MAYBE_Loaded) { |
351 ASSERT_TRUE(backend_.get()); | 283 ASSERT_TRUE(backend_.get()); |
352 ASSERT_TRUE(loaded_); | 284 ASSERT_TRUE(loaded_); |
353 } | 285 } |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 backend_->Closing(); | 1019 backend_->Closing(); |
1088 backend_ = NULL; | 1020 backend_ = NULL; |
1089 | 1021 |
1090 FilePath old_history_path; | 1022 FilePath old_history_path; |
1091 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); | 1023 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); |
1092 old_history_path = old_history_path.AppendASCII("History"); | 1024 old_history_path = old_history_path.AppendASCII("History"); |
1093 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); | 1025 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); |
1094 | 1026 |
1095 // Copy history database file to current directory so that it will be deleted | 1027 // Copy history database file to current directory so that it will be deleted |
1096 // in Teardown. | 1028 // in Teardown. |
1097 FilePath new_history_path(get_test_dir()); | 1029 FilePath new_history_path(getTestDir()); |
1098 file_util::Delete(new_history_path, true); | 1030 file_util::Delete(new_history_path, true); |
1099 file_util::CreateDirectory(new_history_path); | 1031 file_util::CreateDirectory(new_history_path); |
1100 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); | 1032 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); |
1101 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); | 1033 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); |
1102 | 1034 |
1103 backend_ = new HistoryBackend(new_history_path, | 1035 backend_ = new HistoryBackend(new_history_path, |
1104 0, | 1036 0, |
1105 new HistoryBackendTestDelegate(this), | 1037 new HistoryBackendTestDelegate(this), |
1106 &bookmark_model_); | 1038 &bookmark_model_); |
1107 backend_->Init(std::string(), false); | 1039 backend_->Init(std::string(), false); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 backend_ = NULL; | 1492 backend_ = NULL; |
1561 | 1493 |
1562 FilePath old_history_path, old_history, old_archived; | 1494 FilePath old_history_path, old_history, old_archived; |
1563 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); | 1495 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); |
1564 old_history_path = old_history_path.AppendASCII("History"); | 1496 old_history_path = old_history_path.AppendASCII("History"); |
1565 old_history = old_history_path.AppendASCII("HistoryNoDuration"); | 1497 old_history = old_history_path.AppendASCII("HistoryNoDuration"); |
1566 old_archived = old_history_path.AppendASCII("ArchivedNoDuration"); | 1498 old_archived = old_history_path.AppendASCII("ArchivedNoDuration"); |
1567 | 1499 |
1568 // Copy history database file to current directory so that it will be deleted | 1500 // Copy history database file to current directory so that it will be deleted |
1569 // in Teardown. | 1501 // in Teardown. |
1570 FilePath new_history_path(get_test_dir()); | 1502 FilePath new_history_path(getTestDir()); |
1571 file_util::Delete(new_history_path, true); | 1503 file_util::Delete(new_history_path, true); |
1572 file_util::CreateDirectory(new_history_path); | 1504 file_util::CreateDirectory(new_history_path); |
1573 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); | 1505 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); |
1574 FilePath new_archived_file = | 1506 FilePath new_archived_file = |
1575 new_history_path.Append(chrome::kArchivedHistoryFilename); | 1507 new_history_path.Append(chrome::kArchivedHistoryFilename); |
1576 ASSERT_TRUE(file_util::CopyFile(old_history, new_history_file)); | 1508 ASSERT_TRUE(file_util::CopyFile(old_history, new_history_file)); |
1577 ASSERT_TRUE(file_util::CopyFile(old_archived, new_archived_file)); | 1509 ASSERT_TRUE(file_util::CopyFile(old_archived, new_archived_file)); |
1578 | 1510 |
1579 backend_ = new HistoryBackend(new_history_path, | 1511 backend_ = new HistoryBackend(new_history_path, |
1580 0, | 1512 0, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 | 1567 |
1636 backend_->DeleteURL(url); | 1568 backend_->DeleteURL(url); |
1637 backend_->AddPageNoVisitForBookmark(url, string16()); | 1569 backend_->AddPageNoVisitForBookmark(url, string16()); |
1638 backend_->GetURL(url, &row); | 1570 backend_->GetURL(url, &row); |
1639 EXPECT_EQ(url, row.url()); | 1571 EXPECT_EQ(url, row.url()); |
1640 EXPECT_EQ(UTF8ToUTF16(url.spec()), row.title()); | 1572 EXPECT_EQ(UTF8ToUTF16(url.spec()), row.title()); |
1641 EXPECT_EQ(0, row.visit_count()); | 1573 EXPECT_EQ(0, row.visit_count()); |
1642 } | 1574 } |
1643 | 1575 |
1644 } // namespace history | 1576 } // namespace history |
OLD | NEW |