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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 base::Time t3(t1 + base::TimeDelta::FromHours(1)); | 192 base::Time t3(t1 + base::TimeDelta::FromHours(1)); |
193 base::Time t4(t1 + base::TimeDelta::FromHours(1)); | 193 base::Time t4(t1 + base::TimeDelta::FromHours(1)); |
194 const BookmarkNode* f1 = model->AddFolder( | 194 const BookmarkNode* f1 = model->AddFolder( |
195 model->bookmark_bar_node(), 0, f1_title); | 195 model->bookmark_bar_node(), 0, f1_title); |
196 model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); | 196 model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); |
197 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)-> | 197 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)-> |
198 AddPage(url1, base::Time::Now(), history::SOURCE_BROWSED); | 198 AddPage(url1, base::Time::Now(), history::SOURCE_BROWSED); |
199 FaviconServiceFactory::GetForProfile( | 199 FaviconServiceFactory::GetForProfile( |
200 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( | 200 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( |
201 url1, url1_favicon, history::FAVICON, gfx::Image(bitmap)); | 201 url1, url1_favicon, history::FAVICON, gfx::Image(bitmap)); |
202 message_loop.RunAllPending(); | 202 message_loop.RunUntilIdle(); |
203 const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); | 203 const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); |
204 model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2); | 204 model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2); |
205 model->AddURLWithCreationTime(model->bookmark_bar_node(), | 205 model->AddURLWithCreationTime(model->bookmark_bar_node(), |
206 1, url3_title, url3, t3); | 206 1, url3_title, url3, t3); |
207 | 207 |
208 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1); | 208 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1); |
209 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2); | 209 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2); |
210 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title); | 210 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title); |
211 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title); | 211 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title); |
212 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1); | 212 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1); |
213 model->AddURLWithCreationTime(model->bookmark_bar_node(), 2, url4_title, | 213 model->AddURLWithCreationTime(model->bookmark_bar_node(), 2, url4_title, |
214 url4, t4); | 214 url4, t4); |
215 model->AddURLWithCreationTime(model->mobile_node(), 0, url1_title, url1, t1); | 215 model->AddURLWithCreationTime(model->mobile_node(), 0, url1_title, url1, t1); |
216 | 216 |
217 // Write to a temp file. | 217 // Write to a temp file. |
218 BookmarksObserver observer(&message_loop); | 218 BookmarksObserver observer(&message_loop); |
219 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); | 219 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); |
220 message_loop.Run(); | 220 message_loop.Run(); |
221 | 221 |
222 // Clear favicon so that it would be read from file. | 222 // Clear favicon so that it would be read from file. |
223 FaviconServiceFactory::GetForProfile( | 223 FaviconServiceFactory::GetForProfile( |
224 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( | 224 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( |
225 url1, url1_favicon, history::FAVICON, gfx::Image()); | 225 url1, url1_favicon, history::FAVICON, gfx::Image()); |
226 message_loop.RunAllPending(); | 226 message_loop.RunUntilIdle(); |
227 | 227 |
228 // Read the bookmarks back in. | 228 // Read the bookmarks back in. |
229 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; | 229 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; |
230 std::vector<history::ImportedFaviconUsage> favicons; | 230 std::vector<history::ImportedFaviconUsage> favicons; |
231 Firefox2Importer::ImportBookmarksFile(path_, | 231 Firefox2Importer::ImportBookmarksFile(path_, |
232 std::set<GURL>(), | 232 std::set<GURL>(), |
233 NULL, | 233 NULL, |
234 &parsed_bookmarks, | 234 &parsed_bookmarks, |
235 NULL, | 235 NULL, |
236 &favicons); | 236 &favicons); |
(...skipping 25 matching lines...) Expand all Loading... |
262 bookmark_folder_name, string16(), string16()); | 262 bookmark_folder_name, string16(), string16()); |
263 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 263 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
264 string16(), string16(), string16()); | 264 string16(), string16(), string16()); |
265 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 265 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
266 string16(), string16(), string16()); | 266 string16(), string16(), string16()); |
267 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 267 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
268 f3_title, f4_title, string16()); | 268 f3_title, f4_title, string16()); |
269 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, | 269 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, |
270 string16(), string16(), string16()); | 270 string16(), string16(), string16()); |
271 } | 271 } |
OLD | NEW |