| 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/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 base::Time t1(base::Time::Now()); | 190 base::Time t1(base::Time::Now()); |
| 191 base::Time t2(t1 + base::TimeDelta::FromHours(1)); | 191 base::Time t2(t1 + base::TimeDelta::FromHours(1)); |
| 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, history::SOURCE_BROWSED); | 198 AddPage(url1, history::SOURCE_BROWSED); |
| 199 FaviconServiceFactory::GetForProfile( | 199 FaviconServiceFactory::GetForProfile( |
| 200 &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( | 200 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( |
| 201 url1, url1_favicon, icon_data, history::FAVICON); | 201 url1, url1_favicon, history::FAVICON, gfx::Image(bitmap)); |
| 202 message_loop.RunAllPending(); | 202 message_loop.RunAllPending(); |
| 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 std::vector<unsigned char> empty_data; | |
| 224 FaviconServiceFactory::GetForProfile( | 223 FaviconServiceFactory::GetForProfile( |
| 225 &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( | 224 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( |
| 226 url1, url1_favicon, empty_data, history::FAVICON); | 225 url1, url1_favicon, history::FAVICON, gfx::Image()); |
| 227 message_loop.RunAllPending(); | 226 message_loop.RunAllPending(); |
| 228 | 227 |
| 229 // Read the bookmarks back in. | 228 // Read the bookmarks back in. |
| 230 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; | 229 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; |
| 231 std::vector<history::ImportedFaviconUsage> favicons; | 230 std::vector<history::ImportedFaviconUsage> favicons; |
| 232 Firefox2Importer::ImportBookmarksFile(path_, | 231 Firefox2Importer::ImportBookmarksFile(path_, |
| 233 std::set<GURL>(), | 232 std::set<GURL>(), |
| 234 NULL, | 233 NULL, |
| 235 &parsed_bookmarks, | 234 &parsed_bookmarks, |
| 236 NULL, | 235 NULL, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 263 bookmark_folder_name, string16(), string16()); | 262 bookmark_folder_name, string16(), string16()); |
| 264 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 263 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
| 265 string16(), string16(), string16()); | 264 string16(), string16(), string16()); |
| 266 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 265 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
| 267 string16(), string16(), string16()); | 266 string16(), string16(), string16()); |
| 268 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 267 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
| 269 f3_title, f4_title, string16()); | 268 f3_title, f4_title, string16()); |
| 270 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, | 269 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, |
| 271 string16(), string16(), string16()); | 270 string16(), string16(), string16()); |
| 272 } | 271 } |
| OLD | NEW |