| 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" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_html_writer.h" | 16 #include "chrome/browser/bookmarks/bookmark_html_writer.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_model.h" | 17 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 19 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 19 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
| 20 #include "chrome/browser/importer/firefox2_importer.h" | 21 #include "chrome/browser/importer/firefox2_importer.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 22 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
| 23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/gfx/codec/png_codec.h" | 27 #include "ui/gfx/codec/png_codec.h" |
| 27 | 28 |
| 28 using content::BrowserThread; | 29 using content::BrowserThread; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 GURL url4("javascript:alert(\"Hello!\");"); | 189 GURL url4("javascript:alert(\"Hello!\");"); |
| 189 base::Time t1(base::Time::Now()); | 190 base::Time t1(base::Time::Now()); |
| 190 base::Time t2(t1 + base::TimeDelta::FromHours(1)); | 191 base::Time t2(t1 + base::TimeDelta::FromHours(1)); |
| 191 base::Time t3(t1 + base::TimeDelta::FromHours(1)); | 192 base::Time t3(t1 + base::TimeDelta::FromHours(1)); |
| 192 base::Time t4(t1 + base::TimeDelta::FromHours(1)); | 193 base::Time t4(t1 + base::TimeDelta::FromHours(1)); |
| 193 const BookmarkNode* f1 = model->AddFolder( | 194 const BookmarkNode* f1 = model->AddFolder( |
| 194 model->bookmark_bar_node(), 0, f1_title); | 195 model->bookmark_bar_node(), 0, f1_title); |
| 195 model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); | 196 model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); |
| 196 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)-> | 197 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)-> |
| 197 AddPage(url1, history::SOURCE_BROWSED); | 198 AddPage(url1, history::SOURCE_BROWSED); |
| 198 profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, | 199 FaviconServiceFactory::GetForProfile( |
| 199 url1_favicon, icon_data, history::FAVICON); | 200 &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( |
| 201 url1, url1_favicon, icon_data, history::FAVICON); |
| 200 message_loop.RunAllPending(); | 202 message_loop.RunAllPending(); |
| 201 const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); | 203 const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); |
| 202 model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2); | 204 model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2); |
| 203 model->AddURLWithCreationTime(model->bookmark_bar_node(), | 205 model->AddURLWithCreationTime(model->bookmark_bar_node(), |
| 204 1, url3_title, url3, t3); | 206 1, url3_title, url3, t3); |
| 205 | 207 |
| 206 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1); | 208 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1); |
| 207 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2); | 209 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2); |
| 208 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title); | 210 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title); |
| 209 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title); | 211 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title); |
| 210 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1); | 212 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1); |
| 211 model->AddURLWithCreationTime(model->bookmark_bar_node(), 2, url4_title, | 213 model->AddURLWithCreationTime(model->bookmark_bar_node(), 2, url4_title, |
| 212 url4, t4); | 214 url4, t4); |
| 213 model->AddURLWithCreationTime(model->mobile_node(), 0, url1_title, url1, t1); | 215 model->AddURLWithCreationTime(model->mobile_node(), 0, url1_title, url1, t1); |
| 214 | 216 |
| 215 // Write to a temp file. | 217 // Write to a temp file. |
| 216 BookmarksObserver observer(&message_loop); | 218 BookmarksObserver observer(&message_loop); |
| 217 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); | 219 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); |
| 218 message_loop.Run(); | 220 message_loop.Run(); |
| 219 | 221 |
| 220 // Clear favicon so that it would be read from file. | 222 // Clear favicon so that it would be read from file. |
| 221 std::vector<unsigned char> empty_data; | 223 std::vector<unsigned char> empty_data; |
| 222 profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, | 224 FaviconServiceFactory::GetForProfile( |
| 223 url1_favicon, empty_data, history::FAVICON); | 225 &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( |
| 226 url1, url1_favicon, empty_data, history::FAVICON); |
| 224 message_loop.RunAllPending(); | 227 message_loop.RunAllPending(); |
| 225 | 228 |
| 226 // Read the bookmarks back in. | 229 // Read the bookmarks back in. |
| 227 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; | 230 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; |
| 228 std::vector<history::ImportedFaviconUsage> favicons; | 231 std::vector<history::ImportedFaviconUsage> favicons; |
| 229 Firefox2Importer::ImportBookmarksFile(path_, | 232 Firefox2Importer::ImportBookmarksFile(path_, |
| 230 std::set<GURL>(), | 233 std::set<GURL>(), |
| 231 NULL, | 234 NULL, |
| 232 &parsed_bookmarks, | 235 &parsed_bookmarks, |
| 233 NULL, | 236 NULL, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 260 bookmark_folder_name, string16(), string16()); | 263 bookmark_folder_name, string16(), string16()); |
| 261 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 264 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
| 262 string16(), string16(), string16()); | 265 string16(), string16(), string16()); |
| 263 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 266 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
| 264 string16(), string16(), string16()); | 267 string16(), string16(), string16()); |
| 265 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 268 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
| 266 f3_title, f4_title, string16()); | 269 f3_title, f4_title, string16()); |
| 267 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, | 270 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, |
| 268 string16(), string16(), string16()); | 271 string16(), string16(), string16()); |
| 269 } | 272 } |
| OLD | NEW |