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

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: win fix 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 TEST(BookmarkHTMLReaderTest, 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; 17 bool result;
80 18
81 // Tests charset. 19 // Tests charset.
82 std::string charset; 20 std::string charset;
83 result = Firefox2Importer::ParseCharsetFromLine( 21 result = bookmark_html_reader::exposed_for_testing::ParseCharsetFromLine(
84 "<META HTTP-EQUIV=\"Content-Type\" " 22 "<META HTTP-EQUIV=\"Content-Type\" "
85 "CONTENT=\"text/html; charset=UTF-8\">", 23 "CONTENT=\"text/html; charset=UTF-8\">",
86 &charset); 24 &charset);
87 EXPECT_TRUE(result); 25 EXPECT_TRUE(result);
88 EXPECT_EQ("UTF-8", charset); 26 EXPECT_EQ("UTF-8", charset);
89 27
90 // Escaped characters in name. 28 // Escaped characters in name.
91 string16 folder_name; 29 base::string16 folder_name;
92 bool is_toolbar_folder; 30 bool is_toolbar_folder;
93 base::Time folder_add_date; 31 base::Time folder_add_date;
94 result = Firefox2Importer::ParseFolderNameFromLine( 32 result = bookmark_html_reader::exposed_for_testing::ParseFolderNameFromLine(
95 "<DT><H3 ADD_DATE=\"1207558707\" >&lt; &gt;" 33 "<DT><H3 ADD_DATE=\"1207558707\" >&lt; &gt;"
96 " &amp; &quot; &#39; \\ /</H3>", 34 " &amp; &quot; &#39; \\ /</H3>",
97 charset, &folder_name, &is_toolbar_folder, &folder_add_date); 35 charset, &folder_name, &is_toolbar_folder, &folder_add_date);
98 EXPECT_TRUE(result); 36 EXPECT_TRUE(result);
99 EXPECT_EQ(ASCIIToUTF16("< > & \" ' \\ /"), folder_name); 37 EXPECT_EQ(ASCIIToUTF16("< > & \" ' \\ /"), folder_name);
100 EXPECT_FALSE(is_toolbar_folder); 38 EXPECT_FALSE(is_toolbar_folder);
101 EXPECT_TRUE(base::Time::FromTimeT(1207558707) == folder_add_date); 39 EXPECT_TRUE(base::Time::FromTimeT(1207558707) == folder_add_date);
102 40
103 // Empty name and toolbar folder attribute. 41 // Empty name and toolbar folder attribute.
104 result = Firefox2Importer::ParseFolderNameFromLine( 42 result = bookmark_html_reader::exposed_for_testing::ParseFolderNameFromLine(
105 "<DT><H3 PERSONAL_TOOLBAR_FOLDER=\"true\"></H3>", 43 "<DT><H3 PERSONAL_TOOLBAR_FOLDER=\"true\"></H3>",
106 charset, &folder_name, &is_toolbar_folder, &folder_add_date); 44 charset, &folder_name, &is_toolbar_folder, &folder_add_date);
107 EXPECT_TRUE(result); 45 EXPECT_TRUE(result);
108 EXPECT_EQ(string16(), folder_name); 46 EXPECT_EQ(base::string16(), folder_name);
109 EXPECT_TRUE(is_toolbar_folder); 47 EXPECT_TRUE(is_toolbar_folder);
110 48
111 // Unicode characters in title and shortcut. 49 // Unicode characters in title and shortcut.
112 string16 title; 50 base::string16 title;
113 GURL url, favicon; 51 GURL url, favicon;
114 string16 shortcut; 52 base::string16 shortcut;
115 string16 post_data; 53 base::string16 post_data;
116 base::Time add_date; 54 base::Time add_date;
117 result = Firefox2Importer::ParseBookmarkFromLine( 55 result = bookmark_html_reader::exposed_for_testing::ParseBookmarkFromLine(
118 "<DT><A HREF=\"http://chinese.site.cn/path?query=1#ref\" " 56 "<DT><A HREF=\"http://chinese.site.cn/path?query=1#ref\" "
119 "SHORTCUTURL=\"\xE4\xB8\xAD\">\xE4\xB8\xAD\xE6\x96\x87</A>", 57 "SHORTCUTURL=\"\xE4\xB8\xAD\">\xE4\xB8\xAD\xE6\x96\x87</A>",
120 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 58 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
121 EXPECT_TRUE(result); 59 EXPECT_TRUE(result);
122 EXPECT_EQ(L"\x4E2D\x6587", UTF16ToWide(title)); 60 EXPECT_EQ(L"\x4E2D\x6587", UTF16ToWide(title));
123 EXPECT_EQ("http://chinese.site.cn/path?query=1#ref", url.spec()); 61 EXPECT_EQ("http://chinese.site.cn/path?query=1#ref", url.spec());
124 EXPECT_EQ(L"\x4E2D", UTF16ToWide(shortcut)); 62 EXPECT_EQ(L"\x4E2D", UTF16ToWide(shortcut));
125 EXPECT_EQ(string16(), post_data); 63 EXPECT_EQ(base::string16(), post_data);
126 EXPECT_TRUE(base::Time() == add_date); 64 EXPECT_TRUE(base::Time() == add_date);
127 65
128 // No shortcut, and url contains %22 ('"' character). 66 // No shortcut, and url contains %22 ('"' character).
129 result = Firefox2Importer::ParseBookmarkFromLine( 67 result = bookmark_html_reader::exposed_for_testing::ParseBookmarkFromLine(
130 "<DT><A HREF=\"http://domain.com/?q=%22<>%22\">name</A>", 68 "<DT><A HREF=\"http://domain.com/?q=%22<>%22\">name</A>",
131 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 69 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
132 EXPECT_TRUE(result); 70 EXPECT_TRUE(result);
133 EXPECT_EQ(ASCIIToUTF16("name"), title); 71 EXPECT_EQ(ASCIIToUTF16("name"), title);
134 EXPECT_EQ("http://domain.com/?q=%22%3C%3E%22", url.spec()); 72 EXPECT_EQ("http://domain.com/?q=%22%3C%3E%22", url.spec());
135 EXPECT_EQ(string16(), shortcut); 73 EXPECT_EQ(base::string16(), shortcut);
136 EXPECT_EQ(string16(), post_data); 74 EXPECT_EQ(base::string16(), post_data);
137 EXPECT_TRUE(base::Time() == add_date); 75 EXPECT_TRUE(base::Time() == add_date);
138 76
139 result = Firefox2Importer::ParseBookmarkFromLine( 77 result = bookmark_html_reader::exposed_for_testing::ParseBookmarkFromLine(
140 "<DT><A HREF=\"http://domain.com/?g=&quot;\"\">name</A>", 78 "<DT><A HREF=\"http://domain.com/?g=&quot;\"\">name</A>",
141 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 79 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
142 EXPECT_TRUE(result); 80 EXPECT_TRUE(result);
143 EXPECT_EQ(ASCIIToUTF16("name"), title); 81 EXPECT_EQ(ASCIIToUTF16("name"), title);
144 EXPECT_EQ("http://domain.com/?g=%22", url.spec()); 82 EXPECT_EQ("http://domain.com/?g=%22", url.spec());
145 EXPECT_EQ(string16(), shortcut); 83 EXPECT_EQ(base::string16(), shortcut);
146 EXPECT_EQ(string16(), post_data); 84 EXPECT_EQ(base::string16(), post_data);
147 EXPECT_TRUE(base::Time() == add_date); 85 EXPECT_TRUE(base::Time() == add_date);
148 86
149 // Creation date. 87 // Creation date.
150 result = Firefox2Importer::ParseBookmarkFromLine( 88 result = bookmark_html_reader::exposed_for_testing::ParseBookmarkFromLine(
151 "<DT><A HREF=\"http://site/\" ADD_DATE=\"1121301154\">name</A>", 89 "<DT><A HREF=\"http://site/\" ADD_DATE=\"1121301154\">name</A>",
152 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 90 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
153 EXPECT_TRUE(result); 91 EXPECT_TRUE(result);
154 EXPECT_EQ(ASCIIToUTF16("name"), title); 92 EXPECT_EQ(ASCIIToUTF16("name"), title);
155 EXPECT_EQ(GURL("http://site/"), url); 93 EXPECT_EQ(GURL("http://site/"), url);
156 EXPECT_EQ(string16(), shortcut); 94 EXPECT_EQ(base::string16(), shortcut);
157 EXPECT_EQ(string16(), post_data); 95 EXPECT_EQ(base::string16(), post_data);
158 EXPECT_TRUE(base::Time::FromTimeT(1121301154) == add_date); 96 EXPECT_TRUE(base::Time::FromTimeT(1121301154) == add_date);
159 97
160 // Post-data 98 // Post-data
161 result = Firefox2Importer::ParseBookmarkFromLine( 99 result = bookmark_html_reader::exposed_for_testing::ParseBookmarkFromLine(
162 "<DT><A HREF=\"http://localhost:8080/test/hello.html\" ADD_DATE=\"" 100 "<DT><A HREF=\"http://localhost:8080/test/hello.html\" ADD_DATE=\""
163 "1212447159\" LAST_VISIT=\"1212447251\" LAST_MODIFIED=\"1212447248\"" 101 "1212447159\" LAST_VISIT=\"1212447251\" LAST_MODIFIED=\"1212447248\""
164 "SHORTCUTURL=\"post\" ICON=\"data:\" POST_DATA=\"lname%3D%25s\"" 102 "SHORTCUTURL=\"post\" ICON=\"data:\" POST_DATA=\"lname%3D%25s\""
165 "LAST_CHARSET=\"UTF-8\" ID=\"rdf:#$weKaR3\">Test Post keyword</A>", 103 "LAST_CHARSET=\"UTF-8\" ID=\"rdf:#$weKaR3\">Test Post keyword</A>",
166 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 104 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
167 EXPECT_TRUE(result); 105 EXPECT_TRUE(result);
168 EXPECT_EQ(ASCIIToUTF16("Test Post keyword"), title); 106 EXPECT_EQ(ASCIIToUTF16("Test Post keyword"), title);
169 EXPECT_EQ("http://localhost:8080/test/hello.html", url.spec()); 107 EXPECT_EQ("http://localhost:8080/test/hello.html", url.spec());
170 EXPECT_EQ(ASCIIToUTF16("post"), shortcut); 108 EXPECT_EQ(ASCIIToUTF16("post"), shortcut);
171 EXPECT_EQ(ASCIIToUTF16("lname%3D%25s"), post_data); 109 EXPECT_EQ(ASCIIToUTF16("lname%3D%25s"), post_data);
172 EXPECT_TRUE(base::Time::FromTimeT(1212447159) == add_date); 110 EXPECT_TRUE(base::Time::FromTimeT(1212447159) == add_date);
173 111
174 // Invalid case. 112 // Invalid case.
175 result = Firefox2Importer::ParseBookmarkFromLine( 113 result = bookmark_html_reader::exposed_for_testing::ParseBookmarkFromLine(
176 "<DT><A HREF=\"http://domain.com/?q=%22", 114 "<DT><A HREF=\"http://domain.com/?q=%22",
177 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data); 115 charset, &title, &url, &favicon, &shortcut, &add_date, &post_data);
178 EXPECT_FALSE(result); 116 EXPECT_FALSE(result);
179 EXPECT_EQ(string16(), title); 117 EXPECT_EQ(base::string16(), title);
180 EXPECT_EQ("", url.spec()); 118 EXPECT_EQ("", url.spec());
181 EXPECT_EQ(string16(), shortcut); 119 EXPECT_EQ(base::string16(), shortcut);
182 EXPECT_EQ(string16(), post_data); 120 EXPECT_EQ(base::string16(), post_data);
183 EXPECT_TRUE(base::Time() == add_date); 121 EXPECT_TRUE(base::Time() == add_date);
184 122
185 // Epiphany format. 123 // Epiphany format.
186 result = Firefox2Importer::ParseMinimumBookmarkFromLine( 124 result =
187 "<dt><a href=\"http://www.google.com/\">Google</a></dt>", 125 bookmark_html_reader::exposed_for_testing::ParseMinimumBookmarkFromLine(
188 charset, &title, &url); 126 "<dt><a href=\"http://www.google.com/\">Google</a></dt>",
127 charset, &title, &url);
189 EXPECT_TRUE(result); 128 EXPECT_TRUE(result);
190 EXPECT_EQ(ASCIIToUTF16("Google"), title); 129 EXPECT_EQ(ASCIIToUTF16("Google"), title);
191 EXPECT_EQ("http://www.google.com/", url.spec()); 130 EXPECT_EQ("http://www.google.com/", url.spec());
192 } 131 }
193 132
194 TEST(FirefoxImporterTest, Firefox2BookmarkFileImport) { 133 TEST(BookmarkHTMLReaderTest, BookmarkFileImport) {
195 base::FilePath path; 134 base::FilePath path;
196 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); 135 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
197 path = path.AppendASCII("firefox2_importer"); 136 path = path.AppendASCII("bookmark_html_reader");
198 137
199 // Import all bookmarks from a file which include an empty folder entry. 138 // Import all bookmarks from a file which include an empty folder entry.
200 base::FilePath empty_folder_path = path.AppendASCII("empty_folder.html"); 139 base::FilePath empty_folder_path = path.AppendASCII("firefox2.html");
201 std::set<GURL> default_urls; 140 std::vector<ImportedBookmarkEntry> bookmarks;
202 Firefox2Importer* importer = new Firefox2Importer(); 141 bookmark_html_reader::ImportBookmarksFile(
203 importer->AddRef(); 142 NULL, NULL, empty_folder_path, &bookmarks, NULL);
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 bookmark_html_reader::ImportBookmarksFile(
270 importer->ImportBookmarksFile(epiphany_path, default_urls, 180 NULL, NULL, epiphany_path, &bookmarks, NULL);
271 importer, &bookmarks, NULL, NULL);
272 EXPECT_EQ(2U, bookmarks.size()); 181 EXPECT_EQ(2U, bookmarks.size());
273 if (bookmarks.size() == 2) { 182 if (bookmarks.size() == 2) {
274 it = bookmarks.begin(); 183 it = bookmarks.begin();
275 entry = *it++; 184 entry = *it++;
276 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); 185 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title);
277 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); 186 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
278 EXPECT_EQ(0U, entry.path.size()); 187 EXPECT_EQ(0U, entry.path.size());
279 entry = *it++; 188 entry = *it++;
280 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); 189 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
281 EXPECT_EQ("http://www.google.com/", entry.url.spec()); 190 EXPECT_EQ("http://www.google.com/", entry.url.spec());
282 EXPECT_EQ(0U, entry.path.size()); 191 EXPECT_EQ(0U, entry.path.size());
283 } 192 }
284 193
285 // Import Epiphany bookmarks from a file to bookmark bar. 194 // Import Epiphany bookmarks from a file to bookmark bar.
286 bookmarks.clear(); 195 bookmarks.clear();
287 default_urls.clear(); 196 bookmark_html_reader::ImportBookmarksFile(
288 importer->ImportBookmarksFile(epiphany_path, default_urls, 197 NULL, NULL, epiphany_path, &bookmarks, NULL);
289 importer, &bookmarks, NULL, NULL);
290 EXPECT_EQ(2U, bookmarks.size()); 198 EXPECT_EQ(2U, bookmarks.size());
291 if (bookmarks.size() == 2) { 199 if (bookmarks.size() == 2) {
292 it = bookmarks.begin(); 200 it = bookmarks.begin();
293 entry = *it++; 201 entry = *it++;
294 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title); 202 EXPECT_EQ(ASCIIToUTF16("[Tamura Yukari.com]"), entry.title);
295 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec()); 203 EXPECT_EQ("http://www.tamurayukari.com/", entry.url.spec());
296 EXPECT_EQ(0U, entry.path.size()); 204 EXPECT_EQ(0U, entry.path.size());
297 entry = *it++; 205 entry = *it++;
298 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title); 206 EXPECT_EQ(ASCIIToUTF16("Google"), entry.title);
299 EXPECT_EQ("http://www.google.com/", entry.url.spec()); 207 EXPECT_EQ("http://www.google.com/", entry.url.spec());
300 EXPECT_EQ(0U, entry.path.size()); 208 EXPECT_EQ(0U, entry.path.size());
301 } 209 }
302
303 importer->Release();
304 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698