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

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

Issue 6931018: Initial implementation of "Synced Bookmarks" folder. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merge Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // F2 164 // F2
165 // url2 165 // url2
166 // url3 166 // url3
167 // url4 167 // url4
168 // Other 168 // Other
169 // url1 169 // url1
170 // url2 170 // url2
171 // F3 171 // F3
172 // F4 172 // F4
173 // url1 173 // url1
174 // Synced
175 // url1
174 string16 f1_title = ASCIIToUTF16("F\"&;<1\""); 176 string16 f1_title = ASCIIToUTF16("F\"&;<1\"");
175 string16 f2_title = ASCIIToUTF16("F2"); 177 string16 f2_title = ASCIIToUTF16("F2");
176 string16 f3_title = ASCIIToUTF16("F 3"); 178 string16 f3_title = ASCIIToUTF16("F 3");
177 string16 f4_title = ASCIIToUTF16("F4"); 179 string16 f4_title = ASCIIToUTF16("F4");
178 string16 url1_title = ASCIIToUTF16("url 1"); 180 string16 url1_title = ASCIIToUTF16("url 1");
179 string16 url2_title = ASCIIToUTF16("url&2"); 181 string16 url2_title = ASCIIToUTF16("url&2");
180 string16 url3_title = ASCIIToUTF16("url\"3"); 182 string16 url3_title = ASCIIToUTF16("url\"3");
181 string16 url4_title = ASCIIToUTF16("url\"&;"); 183 string16 url4_title = ASCIIToUTF16("url\"&;");
182 GURL url1("http://url1"); 184 GURL url1("http://url1");
183 GURL url1_favicon("http://url1/icon.ico"); 185 GURL url1_favicon("http://url1/icon.ico");
(...skipping 17 matching lines...) Expand all
201 model->AddURLWithCreationTime(model->GetBookmarkBarNode(), 203 model->AddURLWithCreationTime(model->GetBookmarkBarNode(),
202 1, url3_title, url3, t3); 204 1, url3_title, url3, t3);
203 205
204 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1); 206 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1);
205 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2); 207 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2);
206 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title); 208 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title);
207 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title); 209 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title);
208 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1); 210 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1);
209 model->AddURLWithCreationTime(model->GetBookmarkBarNode(), 2, url4_title, 211 model->AddURLWithCreationTime(model->GetBookmarkBarNode(), 2, url4_title,
210 url4, t4); 212 url4, t4);
213 model->AddURLWithCreationTime(model->synced_node(), 0, url1_title, url1, t1);
211 214
212 // Write to a temp file. 215 // Write to a temp file.
213 BookmarksObserver observer(&message_loop); 216 BookmarksObserver observer(&message_loop);
214 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); 217 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer);
215 message_loop.Run(); 218 message_loop.Run();
216 219
217 // Clear favicon so that it would be read from file. 220 // Clear favicon so that it would be read from file.
218 std::vector<unsigned char> empty_data; 221 std::vector<unsigned char> empty_data;
219 profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, 222 profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1,
220 url1_favicon, empty_data, history::FAVICON); 223 url1_favicon, empty_data, history::FAVICON);
221 message_loop.RunAllPending(); 224 message_loop.RunAllPending();
222 225
223 // Read the bookmarks back in. 226 // Read the bookmarks back in.
224 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; 227 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks;
225 std::vector<history::ImportedFaviconUsage> favicons; 228 std::vector<history::ImportedFaviconUsage> favicons;
226 Firefox2Importer::ImportBookmarksFile(path_, 229 Firefox2Importer::ImportBookmarksFile(path_,
227 std::set<GURL>(), 230 std::set<GURL>(),
228 false, 231 false,
229 ASCIIToUTF16("x"), 232 ASCIIToUTF16("x"),
230 NULL, 233 NULL,
231 &parsed_bookmarks, 234 &parsed_bookmarks,
232 NULL, 235 NULL,
233 &favicons); 236 &favicons);
234 237
235 // Check loaded favicon (url1 is represents by 3 separate bookmarks). 238 // Check loaded favicon (url1 is represented by 4 separate bookmarks).
236 EXPECT_EQ(3U, favicons.size()); 239 EXPECT_EQ(4U, favicons.size());
237 for (size_t i = 0; i < favicons.size(); i++) { 240 for (size_t i = 0; i < favicons.size(); i++) {
238 if (url1_favicon == favicons[i].favicon_url) { 241 if (url1_favicon == favicons[i].favicon_url) {
239 EXPECT_EQ(1U, favicons[i].urls.size()); 242 EXPECT_EQ(1U, favicons[i].urls.size());
240 std::set<GURL>::const_iterator iter = favicons[i].urls.find(url1); 243 std::set<GURL>::const_iterator iter = favicons[i].urls.find(url1);
241 ASSERT_TRUE(iter != favicons[i].urls.end()); 244 ASSERT_TRUE(iter != favicons[i].urls.end());
242 ASSERT_TRUE(*iter == url1); 245 ASSERT_TRUE(*iter == url1);
243 ASSERT_TRUE(favicons[i].png_data == icon_data); 246 ASSERT_TRUE(favicons[i].png_data == icon_data);
244 } 247 }
245 } 248 }
246 249
247 // Verify we got back what we wrote. 250 // Verify we got back what we wrote.
248 ASSERT_EQ(7U, parsed_bookmarks.size()); 251 ASSERT_EQ(8U, parsed_bookmarks.size());
249 // Windows and ChromeOS builds use Sentence case. 252 // Windows and ChromeOS builds use Sentence case.
250 string16 bookmark_folder_name = 253 string16 bookmark_folder_name =
251 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_FOLDER_NAME); 254 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_FOLDER_NAME);
252 AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1, 255 AssertBookmarkEntryEquals(parsed_bookmarks[0], false, url1, url1_title, t1,
253 bookmark_folder_name, f1_title, string16()); 256 bookmark_folder_name, f1_title, string16());
254 AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2, 257 AssertBookmarkEntryEquals(parsed_bookmarks[1], false, url2, url2_title, t2,
255 bookmark_folder_name, f1_title, f2_title); 258 bookmark_folder_name, f1_title, f2_title);
256 AssertBookmarkEntryEquals(parsed_bookmarks[2], false, url3, url3_title, t3, 259 AssertBookmarkEntryEquals(parsed_bookmarks[2], false, url3, url3_title, t3,
257 bookmark_folder_name, string16(), string16()); 260 bookmark_folder_name, string16(), string16());
258 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4, 261 AssertBookmarkEntryEquals(parsed_bookmarks[3], false, url4, url4_title, t4,
259 bookmark_folder_name, string16(), string16()); 262 bookmark_folder_name, string16(), string16());
260 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, 263 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1,
261 string16(), string16(), string16()); 264 string16(), string16(), string16());
262 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, 265 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2,
263 string16(), string16(), string16()); 266 string16(), string16(), string16());
264 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, 267 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1,
265 f3_title, f4_title, string16()); 268 f3_title, f4_title, string16());
269 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1,
270 string16(), string16(), string16());
266 } 271 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_html_writer.cc ('k') | chrome/browser/bookmarks/bookmark_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698