Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_reader_unittest.cc

Issue 14575004: Extract BookmarksFileImporter from Firefox2Importer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, dropped extra include Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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" 5 #include "chrome/browser/bookmarks/bookmark_html_reader.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/history/history_types.h" 12 #include "chrome/browser/bookmarks/imported_bookmark_entry.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" 13 #include "chrome/common/chrome_paths.h"
14 #include "testing/gtest/include/gtest/gtest.h"
17 15
18 // TODO(jschuh): Disabled on Win64 build. http://crbug.com/179688 16 namespace bookmark_html_reader {
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 17
25 // The following 2 tests require the use of the NSSDecryptor, on OSX this needs 18 TEST(BookmarkHTMLReaderTest, ParseTests) {
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; 19 bool result;
80 20
81 // Tests charset. 21 // Tests charset.
82 std::string charset; 22 std::string charset;
83 result = Firefox2Importer::ParseCharsetFromLine( 23 result = internal::ParseCharsetFromLine(
84 "<META HTTP-EQUIV=\"Content-Type\" " 24 "<META HTTP-EQUIV=\"Content-Type\" "
85 "CONTENT=\"text/html; charset=UTF-8\">", 25 "CONTENT=\"text/html; charset=UTF-8\">",
86 &charset); 26 &charset);
87 EXPECT_TRUE(result); 27 EXPECT_TRUE(result);
88 EXPECT_EQ("UTF-8", charset); 28 EXPECT_EQ("UTF-8", charset);
89 29
90 // Escaped characters in name. 30 // Escaped characters in name.
91 string16 folder_name; 31 base::string16 folder_name;
92 bool is_toolbar_folder; 32 bool is_toolbar_folder;
93 base::Time folder_add_date; 33 base::Time folder_add_date;
94 result = Firefox2Importer::ParseFolderNameFromLine( 34 result = internal::ParseFolderNameFromLine(
95 "<DT><H3 ADD_DATE=\"1207558707\" >&lt; &gt;" 35 "<DT><H3 ADD_DATE=\"1207558707\" >&lt; &gt;"
96 " &amp; &quot; &#39; \\ /</H3>", 36 " &amp; &quot; &#39; \\ /</H3>",
97 charset, &folder_name, &is_toolbar_folder, &folder_add_date); 37 charset, &folder_name, &is_toolbar_folder, &folder_add_date);
98 EXPECT_TRUE(result); 38 EXPECT_TRUE(result);
99 EXPECT_EQ(ASCIIToUTF16("< > & \" ' \\ /"), folder_name); 39 EXPECT_EQ(ASCIIToUTF16("< > & \" ' \\ /"), folder_name);
100 EXPECT_FALSE(is_toolbar_folder); 40 EXPECT_FALSE(is_toolbar_folder);
101 EXPECT_TRUE(base::Time::FromTimeT(1207558707) == folder_add_date); 41 EXPECT_TRUE(base::Time::FromTimeT(1207558707) == folder_add_date);
102 42
103 // Empty name and toolbar folder attribute. 43 // Empty name and toolbar folder attribute.
104 result = Firefox2Importer::ParseFolderNameFromLine( 44 result = internal::ParseFolderNameFromLine(
105 "<DT><H3 PERSONAL_TOOLBAR_FOLDER=\"true\"></H3>", 45 "<DT><H3 PERSONAL_TOOLBAR_FOLDER=\"true\"></H3>",
106 charset, &folder_name, &is_toolbar_folder, &folder_add_date); 46 charset, &folder_name, &is_toolbar_folder, &folder_add_date);
107 EXPECT_TRUE(result); 47 EXPECT_TRUE(result);
108 EXPECT_EQ(string16(), folder_name); 48 EXPECT_EQ(base::string16(), folder_name);
109 EXPECT_TRUE(is_toolbar_folder); 49 EXPECT_TRUE(is_toolbar_folder);
110 50
111 // Unicode characters in title and shortcut. 51 // Unicode characters in title and shortcut.
112 string16 title; 52 base::string16 title;
113 GURL url, favicon; 53 GURL url, favicon;
114 string16 shortcut; 54 base::string16 shortcut;
115 string16 post_data; 55 base::string16 post_data;
116 base::Time add_date; 56 base::Time add_date;
117 result = Firefox2Importer::ParseBookmarkFromLine( 57 result = internal::ParseBookmarkFromLine(
118 "<DT><A HREF=\"http://chinese.site.cn/path?query=1#ref\" " 58 "<DT><A HREF=\"http://chinese.site.cn/path?query=1#ref\" "
119 "SHORTCUTURL=\"\xE4\xB8\xAD\">\xE4\xB8\xAD\xE6\x96\x87</A>", 59 "SHORTCUTURL=\"\xE4\xB8\xAD\">\xE4\xB8\xAD\xE6\x96\x87</A>",
120 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 60 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
121 EXPECT_TRUE(result); 61 EXPECT_TRUE(result);
122 EXPECT_EQ(L"\x4E2D\x6587", UTF16ToWide(title)); 62 EXPECT_EQ(L"\x4E2D\x6587", UTF16ToWide(title));
123 EXPECT_EQ("http://chinese.site.cn/path?query=1#ref", url.spec()); 63 EXPECT_EQ("http://chinese.site.cn/path?query=1#ref", url.spec());
124 EXPECT_EQ(L"\x4E2D", UTF16ToWide(shortcut)); 64 EXPECT_EQ(L"\x4E2D", UTF16ToWide(shortcut));
125 EXPECT_EQ(string16(), post_data); 65 EXPECT_EQ(base::string16(), post_data);
126 EXPECT_TRUE(base::Time() == add_date); 66 EXPECT_TRUE(base::Time() == add_date);
127 67
128 // No shortcut, and url contains %22 ('"' character). 68 // No shortcut, and url contains %22 ('"' character).
129 result = Firefox2Importer::ParseBookmarkFromLine( 69 result = internal::ParseBookmarkFromLine(
130 "<DT><A HREF=\"http://domain.com/?q=%22<>%22\">name</A>", 70 "<DT><A HREF=\"http://domain.com/?q=%22<>%22\">name</A>",
131 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 71 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
132 EXPECT_TRUE(result); 72 EXPECT_TRUE(result);
133 EXPECT_EQ(ASCIIToUTF16("name"), title); 73 EXPECT_EQ(ASCIIToUTF16("name"), title);
134 EXPECT_EQ("http://domain.com/?q=%22%3C%3E%22", url.spec()); 74 EXPECT_EQ("http://domain.com/?q=%22%3C%3E%22", url.spec());
135 EXPECT_EQ(string16(), shortcut); 75 EXPECT_EQ(base::string16(), shortcut);
136 EXPECT_EQ(string16(), post_data); 76 EXPECT_EQ(base::string16(), post_data);
137 EXPECT_TRUE(base::Time() == add_date); 77 EXPECT_TRUE(base::Time() == add_date);
138 78
139 result = Firefox2Importer::ParseBookmarkFromLine( 79 result = internal::ParseBookmarkFromLine(
140 "<DT><A HREF=\"http://domain.com/?g=&quot;\"\">name</A>", 80 "<DT><A HREF=\"http://domain.com/?g=&quot;\"\">name</A>",
141 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 81 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
142 EXPECT_TRUE(result); 82 EXPECT_TRUE(result);
143 EXPECT_EQ(ASCIIToUTF16("name"), title); 83 EXPECT_EQ(ASCIIToUTF16("name"), title);
144 EXPECT_EQ("http://domain.com/?g=%22", url.spec()); 84 EXPECT_EQ("http://domain.com/?g=%22", url.spec());
145 EXPECT_EQ(string16(), shortcut); 85 EXPECT_EQ(base::string16(), shortcut);
146 EXPECT_EQ(string16(), post_data); 86 EXPECT_EQ(base::string16(), post_data);
147 EXPECT_TRUE(base::Time() == add_date); 87 EXPECT_TRUE(base::Time() == add_date);
148 88
149 // Creation date. 89 // Creation date.
150 result = Firefox2Importer::ParseBookmarkFromLine( 90 result = internal::ParseBookmarkFromLine(
151 "<DT><A HREF=\"http://site/\" ADD_DATE=\"1121301154\">name</A>", 91 "<DT><A HREF=\"http://site/\" ADD_DATE=\"1121301154\">name</A>",
152 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 92 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
153 EXPECT_TRUE(result); 93 EXPECT_TRUE(result);
154 EXPECT_EQ(ASCIIToUTF16("name"), title); 94 EXPECT_EQ(ASCIIToUTF16("name"), title);
155 EXPECT_EQ(GURL("http://site/"), url); 95 EXPECT_EQ(GURL("http://site/"), url);
156 EXPECT_EQ(string16(), shortcut); 96 EXPECT_EQ(base::string16(), shortcut);
157 EXPECT_EQ(string16(), post_data); 97 EXPECT_EQ(base::string16(), post_data);
158 EXPECT_TRUE(base::Time::FromTimeT(1121301154) == add_date); 98 EXPECT_TRUE(base::Time::FromTimeT(1121301154) == add_date);
159 99
160 // Post-data 100 // Post-data
161 result = Firefox2Importer::ParseBookmarkFromLine( 101 result = internal::ParseBookmarkFromLine(
162 "<DT><A HREF=\"http://localhost:8080/test/hello.html\" ADD_DATE=\"" 102 "<DT><A HREF=\"http://localhost:8080/test/hello.html\" ADD_DATE=\""
163 "1212447159\" LAST_VISIT=\"1212447251\" LAST_MODIFIED=\"1212447248\"" 103 "1212447159\" LAST_VISIT=\"1212447251\" LAST_MODIFIED=\"1212447248\""
164 "SHORTCUTURL=\"post\" ICON=\"data:\" POST_DATA=\"lname%3D%25s\"" 104 "SHORTCUTURL=\"post\" ICON=\"data:\" POST_DATA=\"lname%3D%25s\""
165 "LAST_CHARSET=\"UTF-8\" ID=\"rdf:#$weKaR3\">Test Post keyword</A>", 105 "LAST_CHARSET=\"UTF-8\" ID=\"rdf:#$weKaR3\">Test Post keyword</A>",
166 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 106 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
167 EXPECT_TRUE(result); 107 EXPECT_TRUE(result);
168 EXPECT_EQ(ASCIIToUTF16("Test Post keyword"), title); 108 EXPECT_EQ(ASCIIToUTF16("Test Post keyword"), title);
169 EXPECT_EQ("http://localhost:8080/test/hello.html", url.spec()); 109 EXPECT_EQ("http://localhost:8080/test/hello.html", url.spec());
170 EXPECT_EQ(ASCIIToUTF16("post"), shortcut); 110 EXPECT_EQ(ASCIIToUTF16("post"), shortcut);
171 EXPECT_EQ(ASCIIToUTF16("lname%3D%25s"), post_data); 111 EXPECT_EQ(ASCIIToUTF16("lname%3D%25s"), post_data);
172 EXPECT_TRUE(base::Time::FromTimeT(1212447159) == add_date); 112 EXPECT_TRUE(base::Time::FromTimeT(1212447159) == add_date);
173 113
174 // Invalid case. 114 // Invalid case.
175 result = Firefox2Importer::ParseBookmarkFromLine( 115 result = internal::ParseBookmarkFromLine(
176 "<DT><A HREF=\"http://domain.com/?q=%22", 116 "<DT><A HREF=\"http://domain.com/?q=%22",
177 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 117 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
178 EXPECT_FALSE(result); 118 EXPECT_FALSE(result);
179 EXPECT_EQ(string16(), title); 119 EXPECT_EQ(base::string16(), title);
180 EXPECT_EQ("", url.spec()); 120 EXPECT_EQ("", url.spec());
181 EXPECT_EQ(string16(), shortcut); 121 EXPECT_EQ(base::string16(), shortcut);
182 EXPECT_EQ(string16(), post_data); 122 EXPECT_EQ(base::string16(), post_data);
183 EXPECT_TRUE(base::Time() == add_date); 123 EXPECT_TRUE(base::Time() == add_date);
184 124
185 // Epiphany format. 125 // Epiphany format.
186 result = Firefox2Importer::ParseMinimumBookmarkFromLine( 126 result = internal::ParseMinimumBookmarkFromLine(
187 "<dt><a href=\"http://www.google.com/\">Google</a></dt>", 127 "<dt><a href=\"http://www.google.com/\">Google</a></dt>",
188 charset, &title, &url); 128 charset, &title, &url);
189 EXPECT_TRUE(result); 129 EXPECT_TRUE(result);
190 EXPECT_EQ(ASCIIToUTF16("Google"), title); 130 EXPECT_EQ(ASCIIToUTF16("Google"), title);
191 EXPECT_EQ("http://www.google.com/", url.spec()); 131 EXPECT_EQ("http://www.google.com/", url.spec());
192 } 132 }
193 133
194 TEST(FirefoxImporterTest, Firefox2BookmarkFileImport) { 134 TEST(BookmarkHTMLReaderTest, BookmarkFileImport) {
195 base::FilePath path; 135 base::FilePath path;
196 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); 136 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
197 path = path.AppendASCII("firefox2_importer"); 137 path = path.AppendASCII("bookmark_html_reader");
198 138
199 // Import all bookmarks from a file which include an empty folder entry. 139 // Import all bookmarks from a file which include an empty folder entry.
200 base::FilePath empty_folder_path = path.AppendASCII("empty_folder.html"); 140 base::FilePath empty_folder_path = path.AppendASCII("firefox2.html");
201 std::set<GURL> default_urls; 141 std::vector<ImportedBookmarkEntry> bookmarks;
202 Firefox2Importer* importer = new Firefox2Importer(); 142 ImportBookmarksFile(NULL, NULL, empty_folder_path, &bookmarks, NULL);
203 importer->AddRef();
204 std::vector<ProfileWriter::BookmarkEntry> bookmarks;
205 importer->ImportBookmarksFile(empty_folder_path, default_urls,
206 importer, &bookmarks, NULL, NULL);
207 EXPECT_EQ(3U, bookmarks.size()); 143 EXPECT_EQ(3U, bookmarks.size());
208 std::vector<ProfileWriter::BookmarkEntry>::iterator it; 144 std::vector<ImportedBookmarkEntry>::iterator it;
209 ProfileWriter::BookmarkEntry entry; 145 ImportedBookmarkEntry entry;
210 std::vector<string16>::iterator path_it; 146 std::vector<base::string16>::iterator path_it;
211 if (bookmarks.size() == 3) { 147 if (bookmarks.size() == 3) {
212 it = bookmarks.begin(); 148 it = bookmarks.begin();
213 entry = *it++; 149 entry = *it++;
214 EXPECT_EQ(ASCIIToUTF16("Empty"), entry.title); 150 EXPECT_EQ(ASCIIToUTF16("Empty"), entry.title);
215 EXPECT_TRUE(entry.is_folder); 151 EXPECT_TRUE(entry.is_folder);
216 EXPECT_EQ(base::Time::FromTimeT(1295938143), entry.creation_time); 152 EXPECT_EQ(base::Time::FromTimeT(1295938143), entry.creation_time);
217 EXPECT_EQ(1U, entry.path.size()); 153 EXPECT_EQ(1U, entry.path.size());
218 if (entry.path.size() == 1) 154 if (entry.path.size() == 1)
219 EXPECT_EQ(ASCIIToUTF16("Empty's Parent"), entry.path.front()); 155 EXPECT_EQ(ASCIIToUTF16("Empty's Parent"), entry.path.front());
220 156
221 entry = *it++; 157 entry = *it++;
222 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); 158 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title);
223 EXPECT_FALSE(entry.is_folder); 159 EXPECT_FALSE(entry.is_folder);
224 EXPECT_EQ(base::Time::FromTimeT(1234567890), entry.creation_time); 160 EXPECT_EQ(base::Time::FromTimeT(1234567890), entry.creation_time);
225 EXPECT_EQ(1U, entry.path.size()); 161 EXPECT_EQ(1U, entry.path.size());
226 if (entry.path.size() == 1) 162 if (entry.path.size() == 1)
227 EXPECT_EQ(ASCIIToUTF16("Not Empty"), entry.path.front()); 163 EXPECT_EQ(ASCIIToUTF16("Not Empty"), entry.path.front());
228 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); 164 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
229 165
230 entry = *it++; 166 entry = *it++;
231 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); 167 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
232 EXPECT_FALSE(entry.is_folder); 168 EXPECT_FALSE(entry.is_folder);
233 EXPECT_EQ(base::Time::FromTimeT(0000000000), entry.creation_time); 169 EXPECT_EQ(base::Time::FromTimeT(0000000000), entry.creation_time);
234 EXPECT_EQ(1U, entry.path.size()); 170 EXPECT_EQ(1U, entry.path.size());
235 if (entry.path.size() == 1) 171 if (entry.path.size() == 1)
236 EXPECT_EQ(ASCIIToUTF16("Not Empty But Default"), entry.path.front()); 172 EXPECT_EQ(ASCIIToUTF16("Not Empty But Default"), entry.path.front());
237 EXPECT_EQ("http://www.google.com/", entry.url.spec()); 173 EXPECT_EQ("http://www.google.com/", entry.url.spec());
238 } 174 }
239 175
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 176 // Import Epiphany bookmarks from a file
267 base::FilePath epiphany_path = path.AppendASCII("epiphany.html"); 177 base::FilePath epiphany_path = path.AppendASCII("epiphany.html");
268 bookmarks.clear(); 178 bookmarks.clear();
269 default_urls.clear(); 179 ImportBookmarksFile(NULL, NULL, epiphany_path, &bookmarks, NULL);
270 importer->ImportBookmarksFile(epiphany_path, default_urls,
271 importer, &bookmarks, NULL, NULL);
272 EXPECT_EQ(2U, bookmarks.size()); 180 EXPECT_EQ(2U, bookmarks.size());
273 if (bookmarks.size() == 2) { 181 if (bookmarks.size() == 2) {
274 it = bookmarks.begin(); 182 it = bookmarks.begin();
275 entry = *it++; 183 entry = *it++;
276 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); 184 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title);
277 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); 185 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
278 EXPECT_EQ(0U, entry.path.size()); 186 EXPECT_EQ(0U, entry.path.size());
279 entry = *it++; 187 entry = *it++;
280 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); 188 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
281 EXPECT_EQ("http://www.google.com/", entry.url.spec()); 189 EXPECT_EQ("http://www.google.com/", entry.url.spec());
282 EXPECT_EQ(0U, entry.path.size()); 190 EXPECT_EQ(0U, entry.path.size());
283 } 191 }
284 192
285 // Import Epiphany bookmarks from a file to bookmark bar. 193 // Import Epiphany bookmarks from a file to bookmark bar.
286 bookmarks.clear(); 194 bookmarks.clear();
287 default_urls.clear(); 195 ImportBookmarksFile(NULL, NULL, epiphany_path, &bookmarks, NULL);
288 importer->ImportBookmarksFile(epiphany_path, default_urls,
289 importer, &bookmarks, NULL, NULL);
290 EXPECT_EQ(2U, bookmarks.size()); 196 EXPECT_EQ(2U, bookmarks.size());
291 if (bookmarks.size() == 2) { 197 if (bookmarks.size() == 2) {
292 it = bookmarks.begin(); 198 it = bookmarks.begin();
293 entry = *it++; 199 entry = *it++;
294 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); 200 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title);
295 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); 201 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
296 EXPECT_EQ(0U, entry.path.size()); 202 EXPECT_EQ(0U, entry.path.size());
297 entry = *it++; 203 entry = *it++;
298 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); 204 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
299 EXPECT_EQ("http://www.google.com/", entry.url.spec()); 205 EXPECT_EQ("http://www.google.com/", entry.url.spec());
300 EXPECT_EQ(0U, entry.path.size()); 206 EXPECT_EQ(0U, entry.path.size());
301 } 207 }
208 }
302 209
303 importer->Release(); 210 } // namespace bookmark_html_reader
304 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698