| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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" | |
| 6 | |
| 7 #include "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 8 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 9 #include "base/string16.h" | 7 #include "base/string16.h" |
| 10 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/history/history_types.h" | 10 #include "chrome/browser/importer/bookmarks_file_importer.h" |
| 13 #include "chrome/browser/importer/firefox2_importer.h" | |
| 14 #include "chrome/browser/importer/firefox_importer_unittest_utils.h" | |
| 15 #include "chrome/browser/importer/nss_decryptor.h" | |
| 16 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 13 |
| 18 // TODO(jschuh): Disabled on Win64 build. http://crbug.com/179688 | 14 TEST(BookmarksFileImporterTest, ParseTests) { |
| 19 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) | |
| 20 #define MAYBE_NSS(x) DISABLED_##x | |
| 21 #else | |
| 22 #define MAYBE_NSS(x) x | |
| 23 #endif | |
| 24 | |
| 25 // The following 2 tests require the use of the NSSDecryptor, on OSX this needs | |
| 26 // to run in a separate process, so we use a proxy object so we can share the | |
| 27 // same test between platforms. | |
| 28 TEST(FirefoxImporterTest, MAYBE_NSS(Firefox2NSS3Decryptor)) { | |
| 29 base::FilePath nss_path; | |
| 30 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); | |
| 31 #if defined(OS_MACOSX) | |
| 32 nss_path = nss_path.AppendASCII("firefox2_nss_mac"); | |
| 33 #else | |
| 34 nss_path = nss_path.AppendASCII("firefox2_nss"); | |
| 35 #endif // !OS_MACOSX | |
| 36 base::FilePath db_path; | |
| 37 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | |
| 38 db_path = db_path.AppendASCII("firefox2_profile"); | |
| 39 | |
| 40 FFUnitTestDecryptorProxy decryptor_proxy; | |
| 41 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); | |
| 42 | |
| 43 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); | |
| 44 EXPECT_EQ(ASCIIToUTF16("hello"), | |
| 45 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECBJ" | |
| 46 "M63MpT9rtBAjMCm7qo/EhlA==")); | |
| 47 // Test UTF-16 encoding. | |
| 48 EXPECT_EQ(WideToUTF16(L"\x4E2D"), | |
| 49 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECN9" | |
| 50 "OQ5ZFmhb8BAiFo1Z+fUvaIQ==")); | |
| 51 } | |
| 52 | |
| 53 TEST(FirefoxImporterTest, MAYBE_NSS(Firefox3NSS3Decryptor)) { | |
| 54 base::FilePath nss_path; | |
| 55 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); | |
| 56 #if defined(OS_MACOSX) | |
| 57 nss_path = nss_path.AppendASCII("firefox3_nss_mac"); | |
| 58 #else | |
| 59 nss_path = nss_path.AppendASCII("firefox3_nss"); | |
| 60 #endif // !OS_MACOSX | |
| 61 base::FilePath db_path; | |
| 62 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | |
| 63 db_path = db_path.AppendASCII("firefox3_profile"); | |
| 64 | |
| 65 FFUnitTestDecryptorProxy decryptor_proxy; | |
| 66 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); | |
| 67 | |
| 68 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); | |
| 69 EXPECT_EQ(ASCIIToUTF16("hello"), | |
| 70 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa" | |
| 71 "jtRg4qFSHBAhv9luFkXgDJA==")); | |
| 72 // Test UTF-16 encoding. | |
| 73 EXPECT_EQ(WideToUTF16(L"\x4E2D"), | |
| 74 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW" | |
| 75 "qqiccfQHWBAie74hxnULxlw==")); | |
| 76 } | |
| 77 | |
| 78 TEST(FirefoxImporterTest, Firefox2BookmarkParse) { | |
| 79 bool result; | 15 bool result; |
| 80 | 16 |
| 81 // Tests charset. | 17 // Tests charset. |
| 82 std::string charset; | 18 std::string charset; |
| 83 result = Firefox2Importer::ParseCharsetFromLine( | 19 result = BookmarksFileImporter::ParseCharsetFromLine( |
| 84 "<META HTTP-EQUIV=\"Content-Type\" " | 20 "<META HTTP-EQUIV=\"Content-Type\" " |
| 85 "CONTENT=\"text/html; charset=UTF-8\">", | 21 "CONTENT=\"text/html; charset=UTF-8\">", |
| 86 &charset); | 22 &charset); |
| 87 EXPECT_TRUE(result); | 23 EXPECT_TRUE(result); |
| 88 EXPECT_EQ("UTF-8", charset); | 24 EXPECT_EQ("UTF-8", charset); |
| 89 | 25 |
| 90 // Escaped characters in name. | 26 // Escaped characters in name. |
| 91 string16 folder_name; | 27 string16 folder_name; |
| 92 bool is_toolbar_folder; | 28 bool is_toolbar_folder; |
| 93 base::Time folder_add_date; | 29 base::Time folder_add_date; |
| 94 result = Firefox2Importer::ParseFolderNameFromLine( | 30 result = BookmarksFileImporter::ParseFolderNameFromLine( |
| 95 "<DT><H3 ADD_DATE=\"1207558707\" >< >" | 31 "<DT><H3 ADD_DATE=\"1207558707\" >< >" |
| 96 " & " ' \\ /</H3>", | 32 " & " ' \\ /</H3>", |
| 97 charset, &folder_name, &is_toolbar_folder, &folder_add_date); | 33 charset, &folder_name, &is_toolbar_folder, &folder_add_date); |
| 98 EXPECT_TRUE(result); | 34 EXPECT_TRUE(result); |
| 99 EXPECT_EQ(ASCIIToUTF16("< > & \" ' \\ /"), folder_name); | 35 EXPECT_EQ(ASCIIToUTF16("< > & \" ' \\ /"), folder_name); |
| 100 EXPECT_FALSE(is_toolbar_folder); | 36 EXPECT_FALSE(is_toolbar_folder); |
| 101 EXPECT_TRUE(base::Time::FromTimeT(1207558707) == folder_add_date); | 37 EXPECT_TRUE(base::Time::FromTimeT(1207558707) == folder_add_date); |
| 102 | 38 |
| 103 // Empty name and toolbar folder attribute. | 39 // Empty name and toolbar folder attribute. |
| 104 result = Firefox2Importer::ParseFolderNameFromLine( | 40 result = BookmarksFileImporter::ParseFolderNameFromLine( |
| 105 "<DT><H3 PERSONAL_TOOLBAR_FOLDER=\"true\"></H3>", | 41 "<DT><H3 PERSONAL_TOOLBAR_FOLDER=\"true\"></H3>", |
| 106 charset, &folder_name, &is_toolbar_folder, &folder_add_date); | 42 charset, &folder_name, &is_toolbar_folder, &folder_add_date); |
| 107 EXPECT_TRUE(result); | 43 EXPECT_TRUE(result); |
| 108 EXPECT_EQ(string16(), folder_name); | 44 EXPECT_EQ(string16(), folder_name); |
| 109 EXPECT_TRUE(is_toolbar_folder); | 45 EXPECT_TRUE(is_toolbar_folder); |
| 110 | 46 |
| 111 // Unicode characters in title and shortcut. | 47 // Unicode characters in title and shortcut. |
| 112 string16 title; | 48 string16 title; |
| 113 GURL url, favicon; | 49 GURL url, favicon; |
| 114 string16 shortcut; | 50 string16 shortcut; |
| 115 string16 post_data; | 51 string16 post_data; |
| 116 base::Time add_date; | 52 base::Time add_date; |
| 117 result = Firefox2Importer::ParseBookmarkFromLine( | 53 result = BookmarksFileImporter::ParseBookmarkFromLine( |
| 118 "<DT><A HREF=\"http://chinese.site.cn/path?query=1#ref\" " | 54 "<DT><A HREF=\"http://chinese.site.cn/path?query=1#ref\" " |
| 119 "SHORTCUTURL=\"\xE4\xB8\xAD\">\xE4\xB8\xAD\xE6\x96\x87</A>", | 55 "SHORTCUTURL=\"\xE4\xB8\xAD\">\xE4\xB8\xAD\xE6\x96\x87</A>", |
| 120 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); | 56 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); |
| 121 EXPECT_TRUE(result); | 57 EXPECT_TRUE(result); |
| 122 EXPECT_EQ(L"\x4E2D\x6587", UTF16ToWide(title)); | 58 EXPECT_EQ(L"\x4E2D\x6587", UTF16ToWide(title)); |
| 123 EXPECT_EQ("http://chinese.site.cn/path?query=1#ref", url.spec()); | 59 EXPECT_EQ("http://chinese.site.cn/path?query=1#ref", url.spec()); |
| 124 EXPECT_EQ(L"\x4E2D", UTF16ToWide(shortcut)); | 60 EXPECT_EQ(L"\x4E2D", UTF16ToWide(shortcut)); |
| 125 EXPECT_EQ(string16(), post_data); | 61 EXPECT_EQ(string16(), post_data); |
| 126 EXPECT_TRUE(base::Time() == add_date); | 62 EXPECT_TRUE(base::Time() == add_date); |
| 127 | 63 |
| 128 // No shortcut, and url contains %22 ('"' character). | 64 // No shortcut, and url contains %22 ('"' character). |
| 129 result = Firefox2Importer::ParseBookmarkFromLine( | 65 result = BookmarksFileImporter::ParseBookmarkFromLine( |
| 130 "<DT><A HREF=\"http://domain.com/?q=%22<>%22\">name</A>", | 66 "<DT><A HREF=\"http://domain.com/?q=%22<>%22\">name</A>", |
| 131 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); | 67 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); |
| 132 EXPECT_TRUE(result); | 68 EXPECT_TRUE(result); |
| 133 EXPECT_EQ(ASCIIToUTF16("name"), title); | 69 EXPECT_EQ(ASCIIToUTF16("name"), title); |
| 134 EXPECT_EQ("http://domain.com/?q=%22%3C%3E%22", url.spec()); | 70 EXPECT_EQ("http://domain.com/?q=%22%3C%3E%22", url.spec()); |
| 135 EXPECT_EQ(string16(), shortcut); | 71 EXPECT_EQ(string16(), shortcut); |
| 136 EXPECT_EQ(string16(), post_data); | 72 EXPECT_EQ(string16(), post_data); |
| 137 EXPECT_TRUE(base::Time() == add_date); | 73 EXPECT_TRUE(base::Time() == add_date); |
| 138 | 74 |
| 139 result = Firefox2Importer::ParseBookmarkFromLine( | 75 result = BookmarksFileImporter::ParseBookmarkFromLine( |
| 140 "<DT><A HREF=\"http://domain.com/?g="\"\">name</A>", | 76 "<DT><A HREF=\"http://domain.com/?g="\"\">name</A>", |
| 141 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); | 77 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); |
| 142 EXPECT_TRUE(result); | 78 EXPECT_TRUE(result); |
| 143 EXPECT_EQ(ASCIIToUTF16("name"), title); | 79 EXPECT_EQ(ASCIIToUTF16("name"), title); |
| 144 EXPECT_EQ("http://domain.com/?g=%22", url.spec()); | 80 EXPECT_EQ("http://domain.com/?g=%22", url.spec()); |
| 145 EXPECT_EQ(string16(), shortcut); | 81 EXPECT_EQ(string16(), shortcut); |
| 146 EXPECT_EQ(string16(), post_data); | 82 EXPECT_EQ(string16(), post_data); |
| 147 EXPECT_TRUE(base::Time() == add_date); | 83 EXPECT_TRUE(base::Time() == add_date); |
| 148 | 84 |
| 149 // Creation date. | 85 // Creation date. |
| 150 result = Firefox2Importer::ParseBookmarkFromLine( | 86 result = BookmarksFileImporter::ParseBookmarkFromLine( |
| 151 "<DT><A HREF=\"http://site/\" ADD_DATE=\"1121301154\">name</A>", | 87 "<DT><A HREF=\"http://site/\" ADD_DATE=\"1121301154\">name</A>", |
| 152 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); | 88 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); |
| 153 EXPECT_TRUE(result); | 89 EXPECT_TRUE(result); |
| 154 EXPECT_EQ(ASCIIToUTF16("name"), title); | 90 EXPECT_EQ(ASCIIToUTF16("name"), title); |
| 155 EXPECT_EQ(GURL("http://site/"), url); | 91 EXPECT_EQ(GURL("http://site/"), url); |
| 156 EXPECT_EQ(string16(), shortcut); | 92 EXPECT_EQ(string16(), shortcut); |
| 157 EXPECT_EQ(string16(), post_data); | 93 EXPECT_EQ(string16(), post_data); |
| 158 EXPECT_TRUE(base::Time::FromTimeT(1121301154) == add_date); | 94 EXPECT_TRUE(base::Time::FromTimeT(1121301154) == add_date); |
| 159 | 95 |
| 160 // Post-data | 96 // Post-data |
| 161 result = Firefox2Importer::ParseBookmarkFromLine( | 97 result = BookmarksFileImporter::ParseBookmarkFromLine( |
| 162 "<DT><A HREF=\"http://localhost:8080/test/hello.html\" ADD_DATE=\"" | 98 "<DT><A HREF=\"http://localhost:8080/test/hello.html\" ADD_DATE=\"" |
| 163 "1212447159\" LAST_VISIT=\"1212447251\" LAST_MODIFIED=\"1212447248\"" | 99 "1212447159\" LAST_VISIT=\"1212447251\" LAST_MODIFIED=\"1212447248\"" |
| 164 "SHORTCUTURL=\"post\" ICON=\"data:\" POST_DATA=\"lname%3D%25s\"" | 100 "SHORTCUTURL=\"post\" ICON=\"data:\" POST_DATA=\"lname%3D%25s\"" |
| 165 "LAST_CHARSET=\"UTF-8\" ID=\"rdf:#$weKaR3\">Test Post keyword</A>", | 101 "LAST_CHARSET=\"UTF-8\" ID=\"rdf:#$weKaR3\">Test Post keyword</A>", |
| 166 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); | 102 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); |
| 167 EXPECT_TRUE(result); | 103 EXPECT_TRUE(result); |
| 168 EXPECT_EQ(ASCIIToUTF16("Test Post keyword"), title); | 104 EXPECT_EQ(ASCIIToUTF16("Test Post keyword"), title); |
| 169 EXPECT_EQ("http://localhost:8080/test/hello.html", url.spec()); | 105 EXPECT_EQ("http://localhost:8080/test/hello.html", url.spec()); |
| 170 EXPECT_EQ(ASCIIToUTF16("post"), shortcut); | 106 EXPECT_EQ(ASCIIToUTF16("post"), shortcut); |
| 171 EXPECT_EQ(ASCIIToUTF16("lname%3D%25s"), post_data); | 107 EXPECT_EQ(ASCIIToUTF16("lname%3D%25s"), post_data); |
| 172 EXPECT_TRUE(base::Time::FromTimeT(1212447159) == add_date); | 108 EXPECT_TRUE(base::Time::FromTimeT(1212447159) == add_date); |
| 173 | 109 |
| 174 // Invalid case. | 110 // Invalid case. |
| 175 result = Firefox2Importer::ParseBookmarkFromLine( | 111 result = BookmarksFileImporter::ParseBookmarkFromLine( |
| 176 "<DT><A HREF=\"http://domain.com/?q=%22", | 112 "<DT><A HREF=\"http://domain.com/?q=%22", |
| 177 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); | 113 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); |
| 178 EXPECT_FALSE(result); | 114 EXPECT_FALSE(result); |
| 179 EXPECT_EQ(string16(), title); | 115 EXPECT_EQ(string16(), title); |
| 180 EXPECT_EQ("", url.spec()); | 116 EXPECT_EQ("", url.spec()); |
| 181 EXPECT_EQ(string16(), shortcut); | 117 EXPECT_EQ(string16(), shortcut); |
| 182 EXPECT_EQ(string16(), post_data); | 118 EXPECT_EQ(string16(), post_data); |
| 183 EXPECT_TRUE(base::Time() == add_date); | 119 EXPECT_TRUE(base::Time() == add_date); |
| 184 | 120 |
| 185 // Epiphany format. | 121 // Epiphany format. |
| 186 result = Firefox2Importer::ParseMinimumBookmarkFromLine( | 122 result = BookmarksFileImporter::ParseMinimumBookmarkFromLine( |
| 187 "<dt><a href=\"http://www.google.com/\">Google</a></dt>", | 123 "<dt><a href=\"http://www.google.com/\">Google</a></dt>", |
| 188 charset, &title, &url); | 124 charset, &title, &url); |
| 189 EXPECT_TRUE(result); | 125 EXPECT_TRUE(result); |
| 190 EXPECT_EQ(ASCIIToUTF16("Google"), title); | 126 EXPECT_EQ(ASCIIToUTF16("Google"), title); |
| 191 EXPECT_EQ("http://www.google.com/", url.spec()); | 127 EXPECT_EQ("http://www.google.com/", url.spec()); |
| 192 } | 128 } |
| 193 | 129 |
| 194 TEST(FirefoxImporterTest, Firefox2BookmarkFileImport) { | 130 TEST(BookmarksFileImporterTest, BookmarkFileImport) { |
| 195 base::FilePath path; | 131 base::FilePath path; |
| 196 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 132 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
| 197 path = path.AppendASCII("firefox2_importer"); | 133 path = path.AppendASCII("bookmarks_file_importer"); |
| 198 | 134 |
| 199 // Import all bookmarks from a file which include an empty folder entry. | 135 // Import all bookmarks from a file which include an empty folder entry. |
| 200 base::FilePath empty_folder_path = path.AppendASCII("empty_folder.html"); | 136 base::FilePath empty_folder_path = path.AppendASCII("firefox2.html"); |
| 201 std::set<GURL> default_urls; | 137 BookmarksFileImporter* importer = new BookmarksFileImporter(); |
| 202 Firefox2Importer* importer = new Firefox2Importer(); | |
| 203 importer->AddRef(); | 138 importer->AddRef(); |
| 204 std::vector<ProfileWriter::BookmarkEntry> bookmarks; | 139 std::vector<ProfileWriter::BookmarkEntry> bookmarks; |
| 205 importer->ImportBookmarksFile(empty_folder_path, default_urls, | 140 importer->ImportBookmarksFile(empty_folder_path, NULL, &bookmarks, NULL); |
| 206 importer, &bookmarks, NULL, NULL); | |
| 207 EXPECT_EQ(3U, bookmarks.size()); | 141 EXPECT_EQ(3U, bookmarks.size()); |
| 208 std::vector<ProfileWriter::BookmarkEntry>::iterator it; | 142 std::vector<ProfileWriter::BookmarkEntry>::iterator it; |
| 209 ProfileWriter::BookmarkEntry entry; | 143 ProfileWriter::BookmarkEntry entry; |
| 210 std::vector<string16>::iterator path_it; | 144 std::vector<string16>::iterator path_it; |
| 211 if (bookmarks.size() == 3) { | 145 if (bookmarks.size() == 3) { |
| 212 it = bookmarks.begin(); | 146 it = bookmarks.begin(); |
| 213 entry = *it++; | 147 entry = *it++; |
| 214 EXPECT_EQ(ASCIIToUTF16("Empty"), entry.title); | 148 EXPECT_EQ(ASCIIToUTF16("Empty"), entry.title); |
| 215 EXPECT_TRUE(entry.is_folder); | 149 EXPECT_TRUE(entry.is_folder); |
| 216 EXPECT_EQ(base::Time::FromTimeT(1295938143), entry.creation_time); | 150 EXPECT_EQ(base::Time::FromTimeT(1295938143), entry.creation_time); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 230 entry = *it++; | 164 entry = *it++; |
| 231 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); | 165 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); |
| 232 EXPECT_FALSE(entry.is_folder); | 166 EXPECT_FALSE(entry.is_folder); |
| 233 EXPECT_EQ(base::Time::FromTimeT(0000000000), entry.creation_time); | 167 EXPECT_EQ(base::Time::FromTimeT(0000000000), entry.creation_time); |
| 234 EXPECT_EQ(1U, entry.path.size()); | 168 EXPECT_EQ(1U, entry.path.size()); |
| 235 if (entry.path.size() == 1) | 169 if (entry.path.size() == 1) |
| 236 EXPECT_EQ(ASCIIToUTF16("Not Empty But Default"), entry.path.front()); | 170 EXPECT_EQ(ASCIIToUTF16("Not Empty But Default"), entry.path.front()); |
| 237 EXPECT_EQ("http://www.google.com/", entry.url.spec()); | 171 EXPECT_EQ("http://www.google.com/", entry.url.spec()); |
| 238 } | 172 } |
| 239 | 173 |
| 240 // Import non-default bookmarks from a file. | |
| 241 bookmarks.clear(); | |
| 242 default_urls.insert(GURL("http://www.google.com/")); | |
| 243 importer->ImportBookmarksFile(empty_folder_path, default_urls, | |
| 244 importer, &bookmarks, NULL, NULL); | |
| 245 EXPECT_EQ(2U, bookmarks.size()); | |
| 246 if (bookmarks.size() == 2) { | |
| 247 it = bookmarks.begin(); | |
| 248 entry = *it++; | |
| 249 EXPECT_EQ(ASCIIToUTF16("Empty"), entry.title); | |
| 250 EXPECT_TRUE(entry.is_folder); | |
| 251 EXPECT_EQ(base::Time::FromTimeT(1295938143), entry.creation_time); | |
| 252 EXPECT_EQ(1U, entry.path.size()); | |
| 253 if (entry.path.size() == 1) | |
| 254 EXPECT_EQ(ASCIIToUTF16("Empty's Parent"), entry.path.front()); | |
| 255 | |
| 256 entry = *it++; | |
| 257 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); | |
| 258 EXPECT_FALSE(entry.is_folder); | |
| 259 EXPECT_EQ(base::Time::FromTimeT(1234567890), entry.creation_time); | |
| 260 EXPECT_EQ(1U, entry.path.size()); | |
| 261 if (entry.path.size() == 1) | |
| 262 EXPECT_EQ(ASCIIToUTF16("Not Empty"), entry.path.front()); | |
| 263 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); | |
| 264 } | |
| 265 | |
| 266 // Import Epiphany bookmarks from a file | 174 // Import Epiphany bookmarks from a file |
| 267 base::FilePath epiphany_path = path.AppendASCII("epiphany.html"); | 175 base::FilePath epiphany_path = path.AppendASCII("epiphany.html"); |
| 268 bookmarks.clear(); | 176 bookmarks.clear(); |
| 269 default_urls.clear(); | 177 importer->ImportBookmarksFile(epiphany_path, NULL, &bookmarks, NULL); |
| 270 importer->ImportBookmarksFile(epiphany_path, default_urls, | |
| 271 importer, &bookmarks, NULL, NULL); | |
| 272 EXPECT_EQ(2U, bookmarks.size()); | 178 EXPECT_EQ(2U, bookmarks.size()); |
| 273 if (bookmarks.size() == 2) { | 179 if (bookmarks.size() == 2) { |
| 274 it = bookmarks.begin(); | 180 it = bookmarks.begin(); |
| 275 entry = *it++; | 181 entry = *it++; |
| 276 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); | 182 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); |
| 277 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); | 183 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); |
| 278 EXPECT_EQ(0U, entry.path.size()); | 184 EXPECT_EQ(0U, entry.path.size()); |
| 279 entry = *it++; | 185 entry = *it++; |
| 280 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); | 186 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); |
| 281 EXPECT_EQ("http://www.google.com/", entry.url.spec()); | 187 EXPECT_EQ("http://www.google.com/", entry.url.spec()); |
| 282 EXPECT_EQ(0U, entry.path.size()); | 188 EXPECT_EQ(0U, entry.path.size()); |
| 283 } | 189 } |
| 284 | 190 |
| 285 // Import Epiphany bookmarks from a file to bookmark bar. | 191 // Import Epiphany bookmarks from a file to bookmark bar. |
| 286 bookmarks.clear(); | 192 bookmarks.clear(); |
| 287 default_urls.clear(); | 193 importer->ImportBookmarksFile(epiphany_path, NULL, &bookmarks, NULL); |
| 288 importer->ImportBookmarksFile(epiphany_path, default_urls, | |
| 289 importer, &bookmarks, NULL, NULL); | |
| 290 EXPECT_EQ(2U, bookmarks.size()); | 194 EXPECT_EQ(2U, bookmarks.size()); |
| 291 if (bookmarks.size() == 2) { | 195 if (bookmarks.size() == 2) { |
| 292 it = bookmarks.begin(); | 196 it = bookmarks.begin(); |
| 293 entry = *it++; | 197 entry = *it++; |
| 294 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); | 198 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); |
| 295 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); | 199 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); |
| 296 EXPECT_EQ(0U, entry.path.size()); | 200 EXPECT_EQ(0U, entry.path.size()); |
| 297 entry = *it++; | 201 entry = *it++; |
| 298 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); | 202 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); |
| 299 EXPECT_EQ("http://www.google.com/", entry.url.spec()); | 203 EXPECT_EQ("http://www.google.com/", entry.url.spec()); |
| 300 EXPECT_EQ(0U, entry.path.size()); | 204 EXPECT_EQ(0U, entry.path.size()); |
| 301 } | 205 } |
| 302 | 206 |
| 303 importer->Release(); | 207 importer->Release(); |
| 304 } | 208 } |
| OLD | NEW |