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

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

Issue 10873022: Revert 152904 - Moving FaviconService to a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 (c) 2012 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/i18n/time_formatting.h" 8 #include "base/i18n/time_formatting.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/bookmarks/bookmark_html_writer.h" 16 #include "chrome/browser/bookmarks/bookmark_html_writer.h"
17 #include "chrome/browser/bookmarks/bookmark_model.h" 17 #include "chrome/browser/bookmarks/bookmark_model.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/favicon/favicon_service_factory.h"
20 #include "chrome/browser/history/history_service_factory.h" 19 #include "chrome/browser/history/history_service_factory.h"
21 #include "chrome/browser/importer/firefox2_importer.h" 20 #include "chrome/browser/importer/firefox2_importer.h"
22 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
23 #include "content/public/test/test_browser_thread.h" 22 #include "content/public/test/test_browser_thread.h"
24 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/gfx/codec/png_codec.h" 26 #include "ui/gfx/codec/png_codec.h"
28 27
29 using content::BrowserThread; 28 using content::BrowserThread;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 GURL url4("javascript:alert(\"Hello!\");"); 188 GURL url4("javascript:alert(\"Hello!\");");
190 base::Time t1(base::Time::Now()); 189 base::Time t1(base::Time::Now());
191 base::Time t2(t1 + base::TimeDelta::FromHours(1)); 190 base::Time t2(t1 + base::TimeDelta::FromHours(1));
192 base::Time t3(t1 + base::TimeDelta::FromHours(1)); 191 base::Time t3(t1 + base::TimeDelta::FromHours(1));
193 base::Time t4(t1 + base::TimeDelta::FromHours(1)); 192 base::Time t4(t1 + base::TimeDelta::FromHours(1));
194 const BookmarkNode* f1 = model->AddFolder( 193 const BookmarkNode* f1 = model->AddFolder(
195 model->bookmark_bar_node(), 0, f1_title); 194 model->bookmark_bar_node(), 0, f1_title);
196 model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); 195 model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1);
197 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)-> 196 HistoryServiceFactory::GetForProfile(&profile, Profile::EXPLICIT_ACCESS)->
198 AddPage(url1, history::SOURCE_BROWSED); 197 AddPage(url1, history::SOURCE_BROWSED);
199 FaviconServiceFactory::GetForProfile( 198 profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1,
200 &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( 199 url1_favicon, icon_data, history::FAVICON);
201 url1, url1_favicon, icon_data, history::FAVICON);
202 message_loop.RunAllPending(); 200 message_loop.RunAllPending();
203 const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title); 201 const BookmarkNode* f2 = model->AddFolder(f1, 1, f2_title);
204 model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2); 202 model->AddURLWithCreationTime(f2, 0, url2_title, url2, t2);
205 model->AddURLWithCreationTime(model->bookmark_bar_node(), 203 model->AddURLWithCreationTime(model->bookmark_bar_node(),
206 1, url3_title, url3, t3); 204 1, url3_title, url3, t3);
207 205
208 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1); 206 model->AddURLWithCreationTime(model->other_node(), 0, url1_title, url1, t1);
209 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2); 207 model->AddURLWithCreationTime(model->other_node(), 1, url2_title, url2, t2);
210 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title); 208 const BookmarkNode* f3 = model->AddFolder(model->other_node(), 2, f3_title);
211 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title); 209 const BookmarkNode* f4 = model->AddFolder(f3, 0, f4_title);
212 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1); 210 model->AddURLWithCreationTime(f4, 0, url1_title, url1, t1);
213 model->AddURLWithCreationTime(model->bookmark_bar_node(), 2, url4_title, 211 model->AddURLWithCreationTime(model->bookmark_bar_node(), 2, url4_title,
214 url4, t4); 212 url4, t4);
215 model->AddURLWithCreationTime(model->mobile_node(), 0, url1_title, url1, t1); 213 model->AddURLWithCreationTime(model->mobile_node(), 0, url1_title, url1, t1);
216 214
217 // Write to a temp file. 215 // Write to a temp file.
218 BookmarksObserver observer(&message_loop); 216 BookmarksObserver observer(&message_loop);
219 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer); 217 bookmark_html_writer::WriteBookmarks(&profile, path_, &observer);
220 message_loop.Run(); 218 message_loop.Run();
221 219
222 // Clear favicon so that it would be read from file. 220 // Clear favicon so that it would be read from file.
223 std::vector<unsigned char> empty_data; 221 std::vector<unsigned char> empty_data;
224 FaviconServiceFactory::GetForProfile( 222 profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1,
225 &profile, Profile::EXPLICIT_ACCESS)->SetFavicon( 223 url1_favicon, empty_data, history::FAVICON);
226 url1, url1_favicon, empty_data, history::FAVICON);
227 message_loop.RunAllPending(); 224 message_loop.RunAllPending();
228 225
229 // Read the bookmarks back in. 226 // Read the bookmarks back in.
230 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks; 227 std::vector<ProfileWriter::BookmarkEntry> parsed_bookmarks;
231 std::vector<history::ImportedFaviconUsage> favicons; 228 std::vector<history::ImportedFaviconUsage> favicons;
232 Firefox2Importer::ImportBookmarksFile(path_, 229 Firefox2Importer::ImportBookmarksFile(path_,
233 std::set<GURL>(), 230 std::set<GURL>(),
234 NULL, 231 NULL,
235 &parsed_bookmarks, 232 &parsed_bookmarks,
236 NULL, 233 NULL,
(...skipping 26 matching lines...) Expand all
263 bookmark_folder_name, string16(), string16()); 260 bookmark_folder_name, string16(), string16());
264 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1, 261 AssertBookmarkEntryEquals(parsed_bookmarks[4], false, url1, url1_title, t1,
265 string16(), string16(), string16()); 262 string16(), string16(), string16());
266 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2, 263 AssertBookmarkEntryEquals(parsed_bookmarks[5], false, url2, url2_title, t2,
267 string16(), string16(), string16()); 264 string16(), string16(), string16());
268 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1, 265 AssertBookmarkEntryEquals(parsed_bookmarks[6], false, url1, url1_title, t1,
269 f3_title, f4_title, string16()); 266 f3_title, f4_title, string16());
270 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1, 267 AssertBookmarkEntryEquals(parsed_bookmarks[7], false, url1, url1_title, t1,
271 string16(), string16(), string16()); 268 string16(), string16(), string16());
272 } 269 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_html_writer.cc ('k') | chrome/browser/bookmarks/bookmark_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698