OLD | NEW |
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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
10 #include "content/public/browser/favicon_status.h" | 10 #include "content/public/browser/favicon_status.h" |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 handler.reset(new HistoryRequestHandler(page_url, latest_icon_url, | 967 handler.reset(new HistoryRequestHandler(page_url, latest_icon_url, |
968 chrome::TOUCH_ICON, callback)); | 968 chrome::TOUCH_ICON, callback)); |
969 SetFaviconBitmapResult(latest_icon_url, chrome::TOUCH_ICON, | 969 SetFaviconBitmapResult(latest_icon_url, chrome::TOUCH_ICON, |
970 false /* expired */, &handler->history_results_); | 970 false /* expired */, &handler->history_results_); |
971 handler->InvokeCallback(); | 971 handler->InvokeCallback(); |
972 | 972 |
973 // No download request. | 973 // No download request. |
974 EXPECT_FALSE(download_handler->HasDownload()); | 974 EXPECT_FALSE(download_handler->HasDownload()); |
975 } | 975 } |
976 | 976 |
| 977 #if !defined(OS_ANDROID) |
| 978 |
977 // Test the favicon which is selected when the web page provides several | 979 // Test the favicon which is selected when the web page provides several |
978 // favicons and none of the favicons are cached in history. | 980 // favicons and none of the favicons are cached in history. |
979 // The goal of this test is to be more of an integration test than | 981 // The goal of this test is to be more of an integration test than |
980 // SelectFaviconFramesTest.*. | 982 // SelectFaviconFramesTest.*. |
981 TEST_F(FaviconHandlerTest, MultipleFavicons) { | 983 TEST_F(FaviconHandlerTest, MultipleFavicons) { |
982 const GURL kPageURL("http://www.google.com"); | 984 const GURL kPageURL("http://www.google.com"); |
983 const FaviconURL kSourceIconURLs[] = { | 985 const FaviconURL kSourceIconURLs[] = { |
984 FaviconURL(GURL("http://www.google.com/a"), FaviconURL::FAVICON), | 986 FaviconURL(GURL("http://www.google.com/a"), FaviconURL::FAVICON), |
985 FaviconURL(GURL("http://www.google.com/b"), FaviconURL::FAVICON), | 987 FaviconURL(GURL("http://www.google.com/b"), FaviconURL::FAVICON), |
986 FaviconURL(GURL("http://www.google.com/c"), FaviconURL::FAVICON), | 988 FaviconURL(GURL("http://www.google.com/c"), FaviconURL::FAVICON), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 std::vector<FaviconURL> urls4(kSourceIconURLs, | 1058 std::vector<FaviconURL> urls4(kSourceIconURLs, |
1057 kSourceIconURLs + arraysize(kSizes4)); | 1059 kSourceIconURLs + arraysize(kSizes4)); |
1058 DownloadTillDoneIgnoringHistory(&handler4, kPageURL, urls4, kSizes4); | 1060 DownloadTillDoneIgnoringHistory(&handler4, kPageURL, urls4, kSizes4); |
1059 EXPECT_TRUE(handler4.GetEntry()->GetFavicon().valid); | 1061 EXPECT_TRUE(handler4.GetEntry()->GetFavicon().valid); |
1060 expected_index = 0u; | 1062 expected_index = 0u; |
1061 EXPECT_EQ(17, kSizes4[expected_index]); | 1063 EXPECT_EQ(17, kSizes4[expected_index]); |
1062 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, | 1064 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, |
1063 handler4.GetEntry()->GetFavicon().url); | 1065 handler4.GetEntry()->GetFavicon().url); |
1064 } | 1066 } |
1065 | 1067 |
| 1068 #endif |
| 1069 |
1066 static BrowserContextKeyedService* BuildFaviconService( | 1070 static BrowserContextKeyedService* BuildFaviconService( |
1067 content::BrowserContext* profile) { | 1071 content::BrowserContext* profile) { |
1068 return new FaviconService(NULL); | 1072 return new FaviconService(NULL); |
1069 } | 1073 } |
1070 | 1074 |
1071 // Test that Favicon is not requested repeatedly during the same session if | 1075 // Test that Favicon is not requested repeatedly during the same session if |
1072 // server returns HTTP 404 status. | 1076 // server returns HTTP 404 status. |
1073 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { | 1077 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { |
1074 const GURL missing_icon_url("http://www.google.com/favicon.ico"); | 1078 const GURL missing_icon_url("http://www.google.com/favicon.ico"); |
1075 const GURL another_icon_url("http://www.youtube.com/favicon.ico"); | 1079 const GURL another_icon_url("http://www.youtube.com/favicon.ico"); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); | 1137 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); |
1134 EXPECT_NE(0, download_id); | 1138 EXPECT_NE(0, download_id); |
1135 // Report download success with HTTP 200 status. | 1139 // Report download success with HTTP 200 status. |
1136 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, | 1140 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, |
1137 empty_icons, empty_icon_sizes); | 1141 empty_icons, empty_icon_sizes); |
1138 // Icon is not marked as UnableToDownload as HTTP status is not 404. | 1142 // Icon is not marked as UnableToDownload as HTTP status is not 404. |
1139 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); | 1143 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); |
1140 } | 1144 } |
1141 | 1145 |
1142 } // namespace. | 1146 } // namespace. |
OLD | NEW |