summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer/importer_unittest.cc
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 18:38:05 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 18:38:05 +0000
commit7fc7241105ea8e5532005611b374736a4e0bcba2 (patch)
tree3f0e3a2d0e70d6241c376815e71b1273b72ef461 /chrome/browser/importer/importer_unittest.cc
parentb6f8e3831bc67964a85de79a62ab6d680e89a2b8 (diff)
downloadchromium_src-7fc7241105ea8e5532005611b374736a4e0bcba2.zip
chromium_src-7fc7241105ea8e5532005611b374736a4e0bcba2.tar.gz
chromium_src-7fc7241105ea8e5532005611b374736a4e0bcba2.tar.bz2
Many fixes to bookmark importing.
In particular: * All bookmarks are imported to the toolbar -- nothing goes to Other Bookmarks. If there are initially no bookmarks on the toolbar, we try to reduce nesting of the imported bookmarks as much as possible. If there are already bookmarks on the toolbar, all the imported bookmarks end up in a new folder -- e.g. "Imported from Safari" -- on the toolbar. * All importers explicitly include a containing folder for bookmarks in the toolbar. o The ProfileWriter is responsible for stripping this folder off when the bookmarks should be imported directly to the toolbar. * All importers do *not* include a containing folder for the remaining bookmarks. o The ProfileWriter is responsible for creating this folder as appropriate. In fact, this is how things used to work previously, too, since the folder name needed to be uniquified. This CL makes the logic much clearer though (I hope). * All importers should now be able to handle importing empty folders. * The ProfileWriter no longer takes in a bitset of options for importing bookmarks. These options were all either set identically by all clients, or could be more accurately computed locally. * Some implementation details for ProfileWriter have been removed from the header file. Others have just been completely nuked from orbit, and replaced by simpler code (again, I hope). BUG=79427,79433,71351 TEST=unit_tests --gtest_filter=*Import* Review URL: http://codereview.chromium.org/6979007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86861 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer/importer_unittest.cc')
-rw-r--r--chrome/browser/importer/importer_unittest.cc37
1 files changed, 17 insertions, 20 deletions
diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc
index 424f21e..066c5ba 100644
--- a/chrome/browser/importer/importer_unittest.cc
+++ b/chrome/browser/importer/importer_unittest.cc
@@ -153,10 +153,10 @@ bool FindBookmarkEntry(const ProfileWriter::BookmarkEntry& entry,
#if defined(OS_WIN)
static const BookmarkList kIEBookmarks[] = {
- {true, 0, {},
+ {true, 1, {L"Links"},
L"TheLink",
"http://www.links-thelink.com/"},
- {true, 1, {L"SubFolderOfLinks"},
+ {true, 2, {L"Links", L"SubFolderOfLinks"},
L"SubLink",
"http://www.links-sublink.com/"},
{false, 0, {},
@@ -238,12 +238,11 @@ class TestObserver : public ProfileWriter,
EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source);
}
- virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmark,
- const string16& first_folder_name,
- int options) OVERRIDE {
+ virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
+ const string16& top_level_folder_name) OVERRIDE {
// Importer should import the IE Favorites folder the same as the list.
- for (size_t i = 0; i < bookmark.size(); ++i) {
- if (FindBookmarkEntry(bookmark[i], kIEBookmarks,
+ for (size_t i = 0; i < bookmarks.size(); ++i) {
+ if (FindBookmarkEntry(bookmarks[i], kIEBookmarks,
arraysize(kIEBookmarks)))
++bookmark_count_;
}
@@ -465,10 +464,10 @@ TEST_F(ImporterTest, IE7Importer) {
#endif // defined(OS_WIN)
static const BookmarkList kFirefox2Bookmarks[] = {
- {true, 1, {L"Folder"},
+ {true, 2, {L"Bookmarks Toolbar Folder", L"Folder"},
L"On Toolbar's Subfolder",
"http://on.toolbar/bookmark/folder"},
- {true, 0, {},
+ {true, 1, {L"Bookmarks Toolbar Folder"},
L"On Bookmark Toolbar",
"http://on.toolbar/bookmark"},
{false, 1, {L"Folder"},
@@ -604,11 +603,10 @@ class FirefoxObserver : public ProfileWriter,
++history_count_;
}
- virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmark,
- const string16& first_folder_name,
- int options) OVERRIDE {
- for (size_t i = 0; i < bookmark.size(); ++i) {
- if (FindBookmarkEntry(bookmark[i], kFirefox2Bookmarks,
+ virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
+ const string16& top_level_folder_name) OVERRIDE {
+ for (size_t i = 0; i < bookmarks.size(); ++i) {
+ if (FindBookmarkEntry(bookmarks[i], kFirefox2Bookmarks,
arraysize(kFirefox2Bookmarks)))
++bookmark_count_;
}
@@ -701,7 +699,7 @@ TEST_F(ImporterTest, MAYBE(Firefox2Importer)) {
}
static const BookmarkList kFirefox3Bookmarks[] = {
- {true, 0, {},
+ {true, 1, {L"Bookmarks Toolbar"},
L"Toolbar",
"http://site/"},
{false, 0, {},
@@ -814,11 +812,10 @@ class Firefox3Observer : public ProfileWriter,
++history_count_;
}
- virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmark,
- const string16& first_folder_name,
- int options) OVERRIDE {
- for (size_t i = 0; i < bookmark.size(); ++i) {
- if (FindBookmarkEntry(bookmark[i], kFirefox3Bookmarks,
+ virtual void AddBookmarks(const std::vector<BookmarkEntry>& bookmarks,
+ const string16& top_level_folder_name) OVERRIDE {
+ for (size_t i = 0; i < bookmarks.size(); ++i) {
+ if (FindBookmarkEntry(bookmarks[i], kFirefox3Bookmarks,
arraysize(kFirefox3Bookmarks)))
++bookmark_count_;
}