| 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 "chrome/browser/bookmarks/bookmark_html_writer.h" | 5 #include "chrome/browser/bookmarks/bookmark_html_writer.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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.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_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 18 #include "chrome/browser/favicon/favicon_service.h" | 18 #include "chrome/browser/favicon/favicon_service.h" |
| 19 #include "chrome/browser/favicon/favicon_service_factory.h" | 19 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 20 #include "chrome/browser/history/history_service.h" | 20 #include "chrome/browser/history/history_service.h" |
| 21 #include "chrome/browser/history/history_service_factory.h" | 21 #include "chrome/browser/history/history_service_factory.h" |
| 22 #include "chrome/browser/importer/firefox2_importer.h" | 22 #include "chrome/browser/importer/bookmarks_file_importer.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "content/public/test/test_browser_thread.h" | 25 #include "content/public/test/test_browser_thread.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/gfx/codec/png_codec.h" | 30 #include "ui/gfx/codec/png_codec.h" |
| 31 | 31 |
| 32 using content::BrowserThread; | 32 using content::BrowserThread; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 // Clear favicon so that it would be read from file. | 232 // Clear favicon so that it would be read from file. |
| 233 FaviconServiceFactory::GetForProfile( | 233 FaviconServiceFactory::GetForProfile( |
| 234 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( | 234 &profile, Profile::EXPLICIT_ACCESS)->SetFavicons( |
| 235 url1, url1_favicon, history::FAVICON, gfx::Image()); | 235 url1, url1_favicon, history::FAVICON, gfx::Image()); |
| 236 message_loop.RunUntilIdle(); | 236 message_loop.RunUntilIdle(); |
| 237 | 237 |
| 238 // Read the bookmarks back in. | 238 // Read the bookmarks back in. |
| 239 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; | 239 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; |
| 240 std::vector<history::ImportedFaviconUsage> favicons; | 240 std::vector<history::ImportedFaviconUsage> favicons; |
| 241 Firefox2Importer::ImportBookmarksFile(path_, | 241 BookmarksFileImporter::ImportBookmarksFile(path_, |
| 242 std::set<GURL>(), | 242 NULL, |
| 243 NULL, | 243 &parsed_bookmarks, |
| 244 &parsed_bookmarks, | 244 &favicons); |
| 245 NULL, | |
| 246 &favicons); | |
| 247 | 245 |
| 248 // Check loaded favicon (url1 is represented by 4 separate bookmarks). | 246 // Check loaded favicon (url1 is represented by 4 separate bookmarks). |
| 249 EXPECT_EQ(4U, favicons.size()); | 247 EXPECT_EQ(4U, favicons.size()); |
| 250 for (size_t i = 0; i < favicons.size(); i++) { | 248 for (size_t i = 0; i < favicons.size(); i++) { |
| 251 if (url1_favicon == favicons[i].favicon_url) { | 249 if (url1_favicon == favicons[i].favicon_url) { |
| 252 EXPECT_EQ(1U, favicons[i].urls.size()); | 250 EXPECT_EQ(1U, favicons[i].urls.size()); |
| 253 std::set<GURL>::const_iterator iter = favicons[i].urls.find(url1); | 251 std::set<GURL>::const_iterator iter = favicons[i].urls.find(url1); |
| 254 ASSERT_TRUE(iter != favicons[i].urls.end()); | 252 ASSERT_TRUE(iter != favicons[i].urls.end()); |
| 255 ASSERT_TRUE(*iter == url1); | 253 ASSERT_TRUE(*iter == url1); |
| 256 ASSERT_TRUE(favicons[i].png_data == icon_data); | 254 ASSERT_TRUE(favicons[i].png_data == icon_data); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 272 bookmark_folder_name, string16(), string16()); | 270 bookmark_folder_name, string16(), string16()); |
| 273 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, | 271 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, |
| 274 string16(), string16(), string16()); | 272 string16(), string16(), string16()); |
| 275 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, | 273 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, |
| 276 string16(), string16(), string16()); | 274 string16(), string16(), string16()); |
| 277 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 275 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
| 278 f3_title, f4_title, string16()); | 276 f3_title, f4_title, string16()); |
| 279 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, | 277 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, |
| 280 string16(), string16(), string16()); | 278 string16(), string16(), string16()); |
| 281 } | 279 } |
| OLD | NEW |