Chromium Code Reviews| 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/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/favicon/favicon_service.h" | 16 #include "chrome/browser/favicon/favicon_service.h" |
| 17 #include "chrome/browser/favicon/favicon_service_factory.h" | 17 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 18 #include "chrome/browser/history/history_service.h" | 18 #include "chrome/browser/history/history_service.h" |
| 19 #include "chrome/browser/history/history_service_factory.h" | 19 #include "chrome/browser/history/history_service_factory.h" |
| 20 #include "chrome/common/importer/imported_bookmark_entry.h" | 20 #include "chrome/common/importer/imported_bookmark_entry.h" |
| 21 #include "chrome/common/importer/importer_data_types.h" | |
| 21 #include "chrome/common/importer/imported_favicon_usage.h" | 22 #include "chrome/common/importer/imported_favicon_usage.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 23 #include "chrome/utility/importer/bookmark_html_reader.h" | 24 #include "chrome/utility/importer/bookmark_html_reader.h" |
| 24 #include "components/bookmarks/browser/bookmark_model.h" | 25 #include "components/bookmarks/browser/bookmark_model.h" |
| 25 #include "components/bookmarks/test/bookmark_test_helpers.h" | 26 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 26 #include "content/public/test/test_browser_thread_bundle.h" | 27 #include "content/public/test/test_browser_thread_bundle.h" |
| 27 #include "grit/components_strings.h" | 28 #include "grit/components_strings.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 BookmarksObserver observer(&run_loop); | 236 BookmarksObserver observer(&run_loop); |
| 236 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); | 237 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); |
| 237 run_loop.Run(); | 238 run_loop.Run(); |
| 238 | 239 |
| 239 // Clear favicon so that it would be read from file. | 240 // Clear favicon so that it would be read from file. |
| 240 FaviconServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS) | 241 FaviconServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS) |
| 241 ->SetFavicons(url1, url1_favicon, favicon_base::FAVICON, gfx::Image()); | 242 ->SetFavicons(url1, url1_favicon, favicon_base::FAVICON, gfx::Image()); |
| 242 | 243 |
| 243 // Read the bookmarks back in. | 244 // Read the bookmarks back in. |
| 244 std::vector<ImportedBookmarkEntry> parsed_bookmarks; | 245 std::vector<ImportedBookmarkEntry> parsed_bookmarks; |
| 246 std::vector<importer::URLKeywordInfo> parsed_url_keywords; | |
|
Peter Kasting
2014/10/07 23:17:38
Nit: parsed_search_engines?
Tapu Ghose
2014/10/12 00:58:20
Done.
| |
| 245 std::vector<ImportedFaviconUsage> favicons; | 247 std::vector<ImportedFaviconUsage> favicons; |
| 246 bookmark_html_reader::ImportBookmarksFile(base::Callback<bool(void)>(), | 248 bookmark_html_reader::ImportBookmarksFile(base::Callback<bool(void)>(), |
| 247 base::Callback<bool(const GURL&)>(), | 249 base::Callback<bool(const GURL&)>(), |
| 248 path_, | 250 path_, |
| 249 &parsed_bookmarks, | 251 &parsed_bookmarks, |
| 252 &parsed_url_keywords, | |
|
Peter Kasting
2014/10/07 23:17:38
Should we at least be testing that this is empty?
Tapu Ghose
2014/10/12 00:58:20
Since there is no entry in the BookmarkModel that
| |
| 250 &favicons); | 253 &favicons); |
| 251 | 254 |
| 252 // Check loaded favicon (url1 is represented by 4 separate bookmarks). | 255 // Check loaded favicon (url1 is represented by 4 separate bookmarks). |
| 253 EXPECT_EQ(4U, favicons.size()); | 256 EXPECT_EQ(4U, favicons.size()); |
| 254 for (size_t i = 0; i < favicons.size(); i++) { | 257 for (size_t i = 0; i < favicons.size(); i++) { |
| 255 if (url1_favicon == favicons[i].favicon_url) { | 258 if (url1_favicon == favicons[i].favicon_url) { |
| 256 EXPECT_EQ(1U, favicons[i].urls.size()); | 259 EXPECT_EQ(1U, favicons[i].urls.size()); |
| 257 std::set<GURL>::const_iterator iter = favicons[i].urls.find(url1); | 260 std::set<GURL>::const_iterator iter = favicons[i].urls.find(url1); |
| 258 ASSERT_TRUE(iter != favicons[i].urls.end()); | 261 ASSERT_TRUE(iter != favicons[i].urls.end()); |
| 259 ASSERT_TRUE(*iter == url1); | 262 ASSERT_TRUE(*iter == url1); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 285 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, | 288 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, |
| 286 f3_title, f4_title, base::string16()); | 289 f3_title, f4_title, base::string16()); |
| 287 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, | 290 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, |
| 288 base::string16(), base::string16(), | 291 base::string16(), base::string16(), |
| 289 base::string16()); | 292 base::string16()); |
| 290 AssertBookmarkEntryEquals(parsed_bookmarks[8], false, unnamed_bookmark_url, | 293 AssertBookmarkEntryEquals(parsed_bookmarks[8], false, unnamed_bookmark_url, |
| 291 unnamed_bookmark_title, t2, | 294 unnamed_bookmark_title, t2, |
| 292 base::string16(), base::string16(), | 295 base::string16(), base::string16(), |
| 293 base::string16()); | 296 base::string16()); |
| 294 } | 297 } |
| OLD | NEW |