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

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

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename methods and vars to make image_scale more clear Created 7 years, 3 months 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 | Annotate | Revision Log
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/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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 346
347 virtual void SetUp() { 347 virtual void SetUp() {
348 // The score computed by SelectFaviconFrames() is dependent on the supported 348 // The score computed by SelectFaviconFrames() is dependent on the supported
349 // scale factors of the platform. It is used for determining the goodness of 349 // scale factors of the platform. It is used for determining the goodness of
350 // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon(). 350 // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon().
351 // Force the values of the scale factors so that the tests produce the same 351 // Force the values of the scale factors so that the tests produce the same
352 // results on all platforms. 352 // results on all platforms.
353 std::vector<ui::ScaleFactor> scale_factors; 353 std::vector<ui::ScaleFactor> scale_factors;
354 scale_factors.push_back(ui::SCALE_FACTOR_100P); 354 scale_factors.push_back(ui::SCALE_FACTOR_100P);
355 ui::test::SetSupportedScaleFactors(scale_factors); 355 scoped_set_supported_scale_factors_.reset(
356 new ui::test::ScopedSetSupportedScaleFactors(scale_factors));
356 357
357 ChromeRenderViewHostTestHarness::SetUp(); 358 ChromeRenderViewHostTestHarness::SetUp();
358 } 359 }
359 360
360 virtual void TearDown() OVERRIDE { 361 virtual void TearDown() OVERRIDE {
361 Profile* profile = Profile::FromBrowserContext( 362 Profile* profile = Profile::FromBrowserContext(
362 web_contents()->GetBrowserContext()); 363 web_contents()->GetBrowserContext());
363 FaviconServiceFactory::GetInstance()->SetTestingFactory( 364 FaviconServiceFactory::GetInstance()->SetTestingFactory(
364 profile, NULL); 365 profile, NULL);
365 ChromeRenderViewHostTestHarness::TearDown(); 366 ChromeRenderViewHostTestHarness::TearDown();
366 } 367 }
367 368
368 private: 369 private:
370 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors>
371 ScopedSetSupportedScaleFactors;
372 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_;
369 DISALLOW_COPY_AND_ASSIGN(FaviconHandlerTest); 373 DISALLOW_COPY_AND_ASSIGN(FaviconHandlerTest);
370 }; 374 };
371 375
372 TEST_F(FaviconHandlerTest, GetFaviconFromHistory) { 376 TEST_F(FaviconHandlerTest, GetFaviconFromHistory) {
373 const GURL page_url("http://www.google.com"); 377 const GURL page_url("http://www.google.com");
374 const GURL icon_url("http://www.google.com/favicon"); 378 const GURL icon_url("http://www.google.com/favicon");
375 379
376 TestFaviconHandlerDelegate delegate(web_contents()); 380 TestFaviconHandlerDelegate delegate(web_contents());
377 Profile* profile = Profile::FromBrowserContext( 381 Profile* profile = Profile::FromBrowserContext(
378 web_contents()->GetBrowserContext()); 382 web_contents()->GetBrowserContext());
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0, 0); 1106 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0, 0);
1103 EXPECT_NE(0, download_id); 1107 EXPECT_NE(0, download_id);
1104 // Report download success with HTTP 200 status. 1108 // Report download success with HTTP 200 status.
1105 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, 1109 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url,
1106 0, empty_icons); 1110 0, empty_icons);
1107 // Icon is not marked as UnableToDownload as HTTP status is not 404. 1111 // Icon is not marked as UnableToDownload as HTTP status is not 404.
1108 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); 1112 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url));
1109 } 1113 }
1110 1114
1111 } // namespace. 1115 } // namespace.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698