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 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 EXPECT_EQ(0U, handler.image_urls().size()); | 1022 EXPECT_EQ(0U, handler.image_urls().size()); |
1023 | 1023 |
1024 // Verify correct icon size chosen. | 1024 // Verify correct icon size chosen. |
1025 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url); | 1025 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url); |
1026 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid); | 1026 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid); |
1027 EXPECT_FALSE(handler.GetEntry()->GetFavicon().image.IsEmpty()); | 1027 EXPECT_FALSE(handler.GetEntry()->GetFavicon().image.IsEmpty()); |
1028 EXPECT_EQ(gfx::kFaviconSize, | 1028 EXPECT_EQ(gfx::kFaviconSize, |
1029 handler.GetEntry()->GetFavicon().image.ToSkBitmap()->width()); | 1029 handler.GetEntry()->GetFavicon().image.ToSkBitmap()->width()); |
1030 } | 1030 } |
1031 | 1031 |
1032 static ProfileKeyedService* BuildFaviconService( | 1032 static BrowserContextKeyedService* BuildFaviconService( |
1033 content::BrowserContext* profile) { | 1033 content::BrowserContext* profile) { |
1034 return new FaviconService(NULL); | 1034 return new FaviconService(NULL); |
1035 } | 1035 } |
1036 | 1036 |
1037 // Test that Favicon is not requested repeatedly during the same session if | 1037 // Test that Favicon is not requested repeatedly during the same session if |
1038 // server returns HTTP 404 status. | 1038 // server returns HTTP 404 status. |
1039 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { | 1039 TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) { |
1040 const GURL missing_icon_url("http://www.google.com/favicon.ico"); | 1040 const GURL missing_icon_url("http://www.google.com/favicon.ico"); |
1041 const GURL another_icon_url("http://www.youtube.com/favicon.ico"); | 1041 const GURL another_icon_url("http://www.youtube.com/favicon.ico"); |
1042 | 1042 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); | 1098 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); |
1099 EXPECT_NE(0, download_id); | 1099 EXPECT_NE(0, download_id); |
1100 // Report download success with HTTP 200 status. | 1100 // Report download success with HTTP 200 status. |
1101 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, | 1101 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, |
1102 0, empty_icons); | 1102 0, empty_icons); |
1103 // Icon is not marked as UnableToDownload as HTTP status is not 404. | 1103 // Icon is not marked as UnableToDownload as HTTP status is not 404. |
1104 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); | 1104 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); |
1105 } | 1105 } |
1106 | 1106 |
1107 } // namespace. | 1107 } // namespace. |
OLD | NEW |