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/chrome_favicon_client.h" |
6 #include "chrome/browser/favicon/favicon_handler.h" | 7 #include "chrome/browser/favicon/favicon_handler.h" |
7 #include "chrome/browser/favicon/favicon_service.h" | 8 #include "chrome/browser/favicon/favicon_service.h" |
8 #include "chrome/browser/favicon/favicon_service_factory.h" | 9 #include "chrome/browser/favicon/favicon_service_factory.h" |
9 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/gfx/codec/png_codec.h" | 14 #include "ui/gfx/codec/png_codec.h" |
14 #include "ui/gfx/favicon_size.h" | 15 #include "ui/gfx/favicon_size.h" |
15 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 handler1.download_handler()->SetImageSizes(sizes); | 1399 handler1.download_handler()->SetImageSizes(sizes); |
1399 handler1.download_handler()->InvokeCallback(); | 1400 handler1.download_handler()->InvokeCallback(); |
1400 | 1401 |
1401 // Verify icon2 has been saved into history. | 1402 // Verify icon2 has been saved into history. |
1402 EXPECT_EQ(kSourceIconURLs[1].icon_url, handler1.history_handler()->icon_url_); | 1403 EXPECT_EQ(kSourceIconURLs[1].icon_url, handler1.history_handler()->icon_url_); |
1403 EXPECT_EQ(gfx::Size(actual_size2, actual_size2), | 1404 EXPECT_EQ(gfx::Size(actual_size2, actual_size2), |
1404 handler1.history_handler()->size_); | 1405 handler1.history_handler()->size_); |
1405 } | 1406 } |
1406 | 1407 |
1407 static KeyedService* BuildFaviconService(content::BrowserContext* profile) { | 1408 static KeyedService* BuildFaviconService(content::BrowserContext* profile) { |
1408 return new FaviconService(static_cast<Profile*>(profile)); | 1409 FaviconClient* favicon_client = |
| 1410 new ChromeFaviconClient(static_cast<Profile*>(profile)); |
| 1411 return new FaviconService(static_cast<Profile*>(profile), favicon_client); |
1409 } | 1412 } |
1410 | 1413 |
1411 static KeyedService* BuildHistoryService(content::BrowserContext* profile) { | 1414 static KeyedService* BuildHistoryService(content::BrowserContext* profile) { |
1412 return NULL; | 1415 return NULL; |
1413 } | 1416 } |
1414 | 1417 |
1415 // Test that Favicon is not requested repeatedly during the same session if | 1418 // Test that Favicon is not requested repeatedly during the same session if |
1416 // server returns HTTP 404 status. | 1419 // server returns HTTP 404 status. |
1417 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { | 1420 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { |
1418 const GURL missing_icon_url("http://www.google.com/favicon.ico"); | 1421 const GURL missing_icon_url("http://www.google.com/favicon.ico"); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); | 1484 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); |
1482 EXPECT_NE(0, download_id); | 1485 EXPECT_NE(0, download_id); |
1483 // Report download success with HTTP 200 status. | 1486 // Report download success with HTTP 200 status. |
1484 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, | 1487 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, |
1485 empty_icons, empty_icon_sizes); | 1488 empty_icons, empty_icon_sizes); |
1486 // Icon is not marked as UnableToDownload as HTTP status is not 404. | 1489 // Icon is not marked as UnableToDownload as HTTP status is not 404. |
1487 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); | 1490 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); |
1488 } | 1491 } |
1489 | 1492 |
1490 } // namespace. | 1493 } // namespace. |
OLD | NEW |