Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome/browser/history/history_backend_unittest.cc

Issue 10837244: Replace HistoryQuickProvider protobuf-based caching with an SQLite-based database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Tweak suppression. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) : test_(test) {} 58 explicit HistoryBackendTestDelegate(HistoryBackendTest* 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() : bookmark_model_(NULL), loaded_(false) {} 107 HistoryBackendTest();
108 virtual ~HistoryBackendTest() { 108 virtual ~HistoryBackendTest();
109 }
110 109
111 // Callback for QueryMostVisited. 110 // Callback for QueryMostVisited.
112 void OnQueryMostVisited(CancelableRequestProvider::Handle handle, 111 void OnQueryMostVisited(CancelableRequestProvider::Handle handle,
113 history::MostVisitedURLList data) { 112 history::MostVisitedURLList data);
114 most_visited_list_.swap(data);
115 }
116 113
117 // Callback for QueryFiltered. 114 // Callback for QueryFiltered.
118 void OnQueryFiltered(CancelableRequestProvider::Handle handle, 115 void OnQueryFiltered(CancelableRequestProvider::Handle handle,
119 const history::FilteredURLList& data) { 116 const history::FilteredURLList& data);
120 filtered_list_ = data;
121 }
122 117
123 const history::MostVisitedURLList& get_most_visited_list() const { 118 const history::MostVisitedURLList& get_most_visited_list() const {
124 return most_visited_list_; 119 return most_visited_list_;
125 } 120 }
126 121
127 const history::FilteredURLList& get_filtered_list() const { 122 const history::FilteredURLList& get_filtered_list() const {
128 return filtered_list_; 123 return filtered_list_;
129 } 124 }
130 125
131 protected: 126 protected:
132 scoped_refptr<HistoryBackend> backend_; // Will be NULL on init failure. 127 void AddRedirectChain(const char* sequence[], int page_id);
133 scoped_ptr<InMemoryHistoryBackend> mem_backend_;
134 128
135 void AddRedirectChain(const char* sequence[], int page_id) { 129 void AddRedirectChainWithTransitionAndTime(const char* sequence[],
136 AddRedirectChainWithTransitionAndTime(sequence, page_id, 130 int page_id,
137 content::PAGE_TRANSITION_LINK, 131 content::PageTransition transition,
138 Time::Now()); 132 base::Time time);
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 }
160 133
161 // Adds CLIENT_REDIRECT page transition. 134 // Adds CLIENT_REDIRECT page transition.
162 // |url1| is the source URL and |url2| is the destination. 135 // |url1| is the source URL and |url2| is the destination.
163 // |did_replace| is true if the transition is non-user initiated and the 136 // |did_replace| is true if the transition is non-user initiated and the
164 // navigation entry for |url2| has replaced that for |url1|. The possibly 137 // navigation entry for |url2| has replaced that for |url1|. The possibly
165 // updated transition code of the visit records for |url1| and |url2| is 138 // updated transition code of the visit records for |url1| and |url2| is
166 // returned by filling in |*transition1| and |*transition2|, respectively. 139 // returned by filling in |*transition1| and |*transition2|, respectively.
167 // |time| is a time of the redirect. 140 // |time| is a time of the redirect.
168 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace, 141 void AddClientRedirect(const GURL& url1,
142 const GURL& url2,
143 bool did_replace,
169 base::Time time, 144 base::Time time,
170 int* transition1, int* transition2) { 145 int* transition1,
171 void* const dummy_scope = reinterpret_cast<void*>(0x87654321); 146 int* transition2);
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);
182 147
183 *transition1 = getTransition(url1); 148 int GetTransition(const GURL& url);
184 *transition2 = getTransition(url2);
185 }
186 149
187 int getTransition(const GURL& url) { 150 FilePath get_test_dir() { return test_dir_; }
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 }
196 151
197 FilePath getTestDir() { 152 FaviconID GetFavicon(const GURL& url, IconType icon_type);
198 return test_dir_;
199 }
200 153
201 FaviconID GetFavicon(const GURL& url, IconType icon_type) { 154 scoped_refptr<HistoryBackend> backend_; // Will be NULL on init failure.
202 IconMapping icon_mapping; 155 scoped_ptr<InMemoryHistoryBackend> mem_backend_;
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
210 BookmarkModel bookmark_model_; 156 BookmarkModel bookmark_model_;
211
212 protected:
213 bool loaded_; 157 bool loaded_;
214 158
215 private: 159 private:
216 friend class HistoryBackendTestDelegate; 160 friend class HistoryBackendTestDelegate;
217 161
218 // testing::Test 162 // testing::Test
219 virtual void SetUp() { 163 virtual void SetUp();
220 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), 164 virtual void TearDown();
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 }
236 165
237 void SetInMemoryBackend(int backend_id, InMemoryHistoryBackend* backend) { 166 void SetInMemoryBackend(int backend_id, InMemoryHistoryBackend* backend);
238 mem_backend_.reset(backend);
239 }
240 167
241 void BroadcastNotifications(int type, 168 void BroadcastNotifications(int type, HistoryDetails* details);
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 }
250 169
251 MessageLoop message_loop_; 170 MessageLoop message_loop_;
252 FilePath test_dir_; 171 FilePath test_dir_;
253 history::MostVisitedURLList most_visited_list_; 172 history::MostVisitedURLList most_visited_list_;
254 history::FilteredURLList filtered_list_; 173 history::FilteredURLList filtered_list_;
255 }; 174 };
256 175
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
257 void HistoryBackendTestDelegate::SetInMemoryBackend(int backend_id, 190 void HistoryBackendTestDelegate::SetInMemoryBackend(int backend_id,
258 InMemoryHistoryBackend* backend) { 191 InMemoryHistoryBackend* backend) {
259 test_->SetInMemoryBackend(backend_id, backend); 192 test_->SetInMemoryBackend(backend_id, backend);
260 } 193 }
261 194
262 void HistoryBackendTestDelegate::BroadcastNotifications( 195 void HistoryBackendTestDelegate::BroadcastNotifications(
263 int type, 196 int type,
264 HistoryDetails* details) { 197 HistoryDetails* details) {
265 test_->BroadcastNotifications(type, details); 198 test_->BroadcastNotifications(type, details);
266 } 199 }
267 200
268 void HistoryBackendTestDelegate::DBLoaded(int backend_id) { 201 void HistoryBackendTestDelegate::DBLoaded(int backend_id) {
269 test_->loaded_ = true; 202 test_->loaded_ = true;
270 } 203 }
271 204
272 void HistoryBackendTestDelegate::StartTopSitesMigration(int backend_id) { 205 void HistoryBackendTestDelegate::StartTopSitesMigration(int backend_id) {
273 test_->backend_->MigrateThumbnailsDatabase(); 206 test_->backend_->MigrateThumbnailsDatabase();
274 } 207 }
275 208
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
276 // http://crbug.com/114287 344 // http://crbug.com/114287
277 #if defined(OS_WIN) 345 #if defined(OS_WIN)
278 #define MAYBE_Loaded DISABLED_Loaded 346 #define MAYBE_Loaded DISABLED_Loaded
279 #else 347 #else
280 #define MAYBE_Loaded Loaded 348 #define MAYBE_Loaded Loaded
281 #endif // defined(OS_WIN) 349 #endif // defined(OS_WIN)
282 TEST_F(HistoryBackendTest, MAYBE_Loaded) { 350 TEST_F(HistoryBackendTest, MAYBE_Loaded) {
283 ASSERT_TRUE(backend_.get()); 351 ASSERT_TRUE(backend_.get());
284 ASSERT_TRUE(loaded_); 352 ASSERT_TRUE(loaded_);
285 } 353 }
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 backend_->Closing(); 1087 backend_->Closing();
1020 backend_ = NULL; 1088 backend_ = NULL;
1021 1089
1022 FilePath old_history_path; 1090 FilePath old_history_path;
1023 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); 1091 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path));
1024 old_history_path = old_history_path.AppendASCII("History"); 1092 old_history_path = old_history_path.AppendASCII("History");
1025 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); 1093 old_history_path = old_history_path.AppendASCII("HistoryNoSource");
1026 1094
1027 // Copy history database file to current directory so that it will be deleted 1095 // Copy history database file to current directory so that it will be deleted
1028 // in Teardown. 1096 // in Teardown.
1029 FilePath new_history_path(getTestDir()); 1097 FilePath new_history_path(get_test_dir());
1030 file_util::Delete(new_history_path, true); 1098 file_util::Delete(new_history_path, true);
1031 file_util::CreateDirectory(new_history_path); 1099 file_util::CreateDirectory(new_history_path);
1032 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); 1100 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename);
1033 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); 1101 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file));
1034 1102
1035 backend_ = new HistoryBackend(new_history_path, 1103 backend_ = new HistoryBackend(new_history_path,
1036 0, 1104 0,
1037 new HistoryBackendTestDelegate(this), 1105 new HistoryBackendTestDelegate(this),
1038 &bookmark_model_); 1106 &bookmark_model_);
1039 backend_->Init(std::string(), false); 1107 backend_->Init(std::string(), false);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 backend_ = NULL; 1560 backend_ = NULL;
1493 1561
1494 FilePath old_history_path, old_history, old_archived; 1562 FilePath old_history_path, old_history, old_archived;
1495 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); 1563 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path));
1496 old_history_path = old_history_path.AppendASCII("History"); 1564 old_history_path = old_history_path.AppendASCII("History");
1497 old_history = old_history_path.AppendASCII("HistoryNoDuration"); 1565 old_history = old_history_path.AppendASCII("HistoryNoDuration");
1498 old_archived = old_history_path.AppendASCII("ArchivedNoDuration"); 1566 old_archived = old_history_path.AppendASCII("ArchivedNoDuration");
1499 1567
1500 // Copy history database file to current directory so that it will be deleted 1568 // Copy history database file to current directory so that it will be deleted
1501 // in Teardown. 1569 // in Teardown.
1502 FilePath new_history_path(getTestDir()); 1570 FilePath new_history_path(get_test_dir());
1503 file_util::Delete(new_history_path, true); 1571 file_util::Delete(new_history_path, true);
1504 file_util::CreateDirectory(new_history_path); 1572 file_util::CreateDirectory(new_history_path);
1505 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); 1573 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename);
1506 FilePath new_archived_file = 1574 FilePath new_archived_file =
1507 new_history_path.Append(chrome::kArchivedHistoryFilename); 1575 new_history_path.Append(chrome::kArchivedHistoryFilename);
1508 ASSERT_TRUE(file_util::CopyFile(old_history, new_history_file)); 1576 ASSERT_TRUE(file_util::CopyFile(old_history, new_history_file));
1509 ASSERT_TRUE(file_util::CopyFile(old_archived, new_archived_file)); 1577 ASSERT_TRUE(file_util::CopyFile(old_archived, new_archived_file));
1510 1578
1511 backend_ = new HistoryBackend(new_history_path, 1579 backend_ = new HistoryBackend(new_history_path,
1512 0, 1580 0,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 1635
1568 backend_->DeleteURL(url); 1636 backend_->DeleteURL(url);
1569 backend_->AddPageNoVisitForBookmark(url, string16()); 1637 backend_->AddPageNoVisitForBookmark(url, string16());
1570 backend_->GetURL(url, &row); 1638 backend_->GetURL(url, &row);
1571 EXPECT_EQ(url, row.url()); 1639 EXPECT_EQ(url, row.url());
1572 EXPECT_EQ(UTF8ToUTF16(url.spec()), row.title()); 1640 EXPECT_EQ(UTF8ToUTF16(url.spec()), row.title());
1573 EXPECT_EQ(0, row.visit_count()); 1641 EXPECT_EQ(0, row.visit_count());
1574 } 1642 }
1575 1643
1576 } // namespace history 1644 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698