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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 403 } |
404 | 404 |
405 virtual void SetUp() { | 405 virtual void SetUp() { |
406 // The score computed by SelectFaviconFrames() is dependent on the supported | 406 // The score computed by SelectFaviconFrames() is dependent on the supported |
407 // scale factors of the platform. It is used for determining the goodness of | 407 // scale factors of the platform. It is used for determining the goodness of |
408 // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon(). | 408 // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon(). |
409 // Force the values of the scale factors so that the tests produce the same | 409 // Force the values of the scale factors so that the tests produce the same |
410 // results on all platforms. | 410 // results on all platforms. |
411 std::vector<ui::ScaleFactor> scale_factors; | 411 std::vector<ui::ScaleFactor> scale_factors; |
412 scale_factors.push_back(ui::SCALE_FACTOR_100P); | 412 scale_factors.push_back(ui::SCALE_FACTOR_100P); |
413 ui::test::SetSupportedScaleFactors(scale_factors); | 413 scoped_set_supported_scale_factors_.reset( |
| 414 new ui::test::ScopedSetSupportedScaleFactors(scale_factors)); |
414 | 415 |
415 ChromeRenderViewHostTestHarness::SetUp(); | 416 ChromeRenderViewHostTestHarness::SetUp(); |
416 } | 417 } |
417 | 418 |
418 virtual void TearDown() OVERRIDE { | 419 virtual void TearDown() OVERRIDE { |
419 Profile* profile = Profile::FromBrowserContext( | 420 Profile* profile = Profile::FromBrowserContext( |
420 web_contents()->GetBrowserContext()); | 421 web_contents()->GetBrowserContext()); |
421 FaviconServiceFactory::GetInstance()->SetTestingFactory( | 422 FaviconServiceFactory::GetInstance()->SetTestingFactory( |
422 profile, NULL); | 423 profile, NULL); |
423 ChromeRenderViewHostTestHarness::TearDown(); | 424 ChromeRenderViewHostTestHarness::TearDown(); |
424 } | 425 } |
425 | 426 |
426 private: | 427 private: |
| 428 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> |
| 429 ScopedSetSupportedScaleFactors; |
| 430 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; |
427 DISALLOW_COPY_AND_ASSIGN(FaviconHandlerTest); | 431 DISALLOW_COPY_AND_ASSIGN(FaviconHandlerTest); |
428 }; | 432 }; |
429 | 433 |
430 TEST_F(FaviconHandlerTest, GetFaviconFromHistory) { | 434 TEST_F(FaviconHandlerTest, GetFaviconFromHistory) { |
431 const GURL page_url("http://www.google.com"); | 435 const GURL page_url("http://www.google.com"); |
432 const GURL icon_url("http://www.google.com/favicon"); | 436 const GURL icon_url("http://www.google.com/favicon"); |
433 | 437 |
434 TestFaviconHandlerDelegate delegate; | 438 TestFaviconHandlerDelegate delegate; |
435 Profile* profile = Profile::FromBrowserContext( | 439 Profile* profile = Profile::FromBrowserContext( |
436 web_contents()->GetBrowserContext()); | 440 web_contents()->GetBrowserContext()); |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); | 1133 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); |
1130 EXPECT_NE(0, download_id); | 1134 EXPECT_NE(0, download_id); |
1131 // Report download success with HTTP 200 status. | 1135 // Report download success with HTTP 200 status. |
1132 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, | 1136 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, |
1133 empty_icons, empty_icon_sizes); | 1137 empty_icons, empty_icon_sizes); |
1134 // Icon is not marked as UnableToDownload as HTTP status is not 404. | 1138 // Icon is not marked as UnableToDownload as HTTP status is not 404. |
1135 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); | 1139 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); |
1136 } | 1140 } |
1137 | 1141 |
1138 } // namespace. | 1142 } // namespace. |
OLD | NEW |