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

Side by Side Diff: chrome/browser/favicon/favicon_handler_unittest.cc

Issue 56143002: Make FaviconService() use Porfile as parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit test but break the DEPS Created 7 years, 1 month 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
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/favicon/favicon_handler.h" 6 #include "chrome/browser/favicon/favicon_handler.h"
7 #include "chrome/browser/favicon/favicon_service_factory.h" 7 #include "chrome/browser/favicon/favicon_service_factory.h"
8 #include "chrome/browser/history/history_service_factory.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "content/public/browser/favicon_status.h" 11 #include "content/public/browser/favicon_status.h"
11 #include "content/public/browser/invalidate_type.h" 12 #include "content/public/browser/invalidate_type.h"
12 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/gfx/codec/png_codec.h" 16 #include "ui/gfx/codec/png_codec.h"
16 #include "ui/gfx/favicon_size.h" 17 #include "ui/gfx/favicon_size.h"
17 #include "ui/gfx/image/image.h" 18 #include "ui/gfx/image/image.h"
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 expected_index = 0u; 1063 expected_index = 0u;
1063 EXPECT_EQ(17, kSizes4[expected_index]); 1064 EXPECT_EQ(17, kSizes4[expected_index]);
1064 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, 1065 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url,
1065 handler4.GetEntry()->GetFavicon().url); 1066 handler4.GetEntry()->GetFavicon().url);
1066 } 1067 }
1067 1068
1068 #endif 1069 #endif
1069 1070
1070 static BrowserContextKeyedService* BuildFaviconService( 1071 static BrowserContextKeyedService* BuildFaviconService(
1071 content::BrowserContext* profile) { 1072 content::BrowserContext* profile) {
1072 return new FaviconService(NULL); 1073 return new FaviconService(static_cast<Profile*>(profile));
1074 }
1075
1076 static BrowserContextKeyedService* BuildHistoryService(
1077 content::BrowserContext* profile) {
1078 return NULL;
1073 } 1079 }
1074 1080
1075 // Test that Favicon is not requested repeatedly during the same session if 1081 // Test that Favicon is not requested repeatedly during the same session if
1076 // server returns HTTP 404 status. 1082 // server returns HTTP 404 status.
1077 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { 1083 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) {
1078 const GURL missing_icon_url("http://www.google.com/favicon.ico"); 1084 const GURL missing_icon_url("http://www.google.com/favicon.ico");
1079 const GURL another_icon_url("http://www.youtube.com/favicon.ico"); 1085 const GURL another_icon_url("http://www.youtube.com/favicon.ico");
1080 1086
1081 Profile* profile = Profile::FromBrowserContext( 1087 Profile* profile = Profile::FromBrowserContext(
1082 web_contents()->GetBrowserContext()); 1088 web_contents()->GetBrowserContext());
1083 1089
1084 FaviconServiceFactory::GetInstance()->SetTestingFactory( 1090 FaviconServiceFactory::GetInstance()->SetTestingFactory(
1085 profile, BuildFaviconService); 1091 profile, BuildFaviconService);
1092
1093 HistoryServiceFactory::GetInstance()->SetTestingFactory(
1094 profile, BuildHistoryService);
1095
1086 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 1096 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
1087 profile, Profile::IMPLICIT_ACCESS); 1097 profile, Profile::IMPLICIT_ACCESS);
1088 1098
1089 FaviconTabHelper::CreateForWebContents(web_contents()); 1099 FaviconTabHelper::CreateForWebContents(web_contents());
1090 FaviconTabHelper* favicon_tab_helper = 1100 FaviconTabHelper* favicon_tab_helper =
1091 FaviconTabHelper::FromWebContents(web_contents()); 1101 FaviconTabHelper::FromWebContents(web_contents());
1092 1102
1093 std::vector<SkBitmap> empty_icons; 1103 std::vector<SkBitmap> empty_icons;
1094 std::vector<gfx::Size> empty_icon_sizes; 1104 std::vector<gfx::Size> empty_icon_sizes;
1095 int download_id = 0; 1105 int download_id = 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); 1147 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0);
1138 EXPECT_NE(0, download_id); 1148 EXPECT_NE(0, download_id);
1139 // Report download success with HTTP 200 status. 1149 // Report download success with HTTP 200 status.
1140 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, 1150 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url,
1141 empty_icons, empty_icon_sizes); 1151 empty_icons, empty_icon_sizes);
1142 // Icon is not marked as UnableToDownload as HTTP status is not 404. 1152 // Icon is not marked as UnableToDownload as HTTP status is not 404.
1143 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); 1153 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url));
1144 } 1154 }
1145 1155
1146 } // namespace. 1156 } // namespace.
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698