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

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

Issue 684613002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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 "chrome/browser/favicon/favicon_handler.h" 5 #include "chrome/browser/favicon/favicon_handler.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/favicon/chrome_favicon_client.h" 8 #include "chrome/browser/favicon/chrome_favicon_client.h"
9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" 9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h"
10 #include "chrome/browser/favicon/favicon_service.h" 10 #include "chrome/browser/favicon/favicon_service.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 download_->image_url, 394 download_->image_url,
395 bitmaps, 395 bitmaps,
396 original_bitmap_sizes); 396 original_bitmap_sizes);
397 } 397 }
398 398
399 class FaviconHandlerTest : public ChromeRenderViewHostTestHarness { 399 class FaviconHandlerTest : public ChromeRenderViewHostTestHarness {
400 public: 400 public:
401 FaviconHandlerTest() { 401 FaviconHandlerTest() {
402 } 402 }
403 403
404 virtual ~FaviconHandlerTest() { 404 ~FaviconHandlerTest() override {}
405 }
406 405
407 // Simulates requesting a favicon for |page_url| given: 406 // Simulates requesting a favicon for |page_url| given:
408 // - We have not previously cached anything in history for |page_url| or for 407 // - We have not previously cached anything in history for |page_url| or for
409 // any of |candidates|. 408 // any of |candidates|.
410 // - The page provides favicons at |candidate_icons|. 409 // - The page provides favicons at |candidate_icons|.
411 // - The favicons at |candidate_icons| have edge pixel sizes of 410 // - The favicons at |candidate_icons| have edge pixel sizes of
412 // |candidate_icon_sizes|. 411 // |candidate_icon_sizes|.
413 void DownloadTillDoneIgnoringHistory( 412 void DownloadTillDoneIgnoringHistory(
414 TestFaviconHandler* favicon_handler, 413 TestFaviconHandler* favicon_handler,
415 const GURL& page_url, 414 const GURL& page_url,
(...skipping 24 matching lines...) Expand all
440 const GURL& page_url, 439 const GURL& page_url,
441 const std::vector<FaviconURL>& candidate_icons) { 440 const std::vector<FaviconURL>& candidate_icons) {
442 favicon_handler->ResetNumFaviconUpdateNotifications(); 441 favicon_handler->ResetNumFaviconUpdateNotifications();
443 442
444 favicon_handler->FetchFavicon(page_url); 443 favicon_handler->FetchFavicon(page_url);
445 favicon_handler->history_handler()->InvokeCallback(); 444 favicon_handler->history_handler()->InvokeCallback();
446 445
447 favicon_handler->OnUpdateFaviconURL(candidate_icons); 446 favicon_handler->OnUpdateFaviconURL(candidate_icons);
448 } 447 }
449 448
450 virtual void SetUp() { 449 void SetUp() override {
451 // The score computed by SelectFaviconFrames() is dependent on the supported 450 // The score computed by SelectFaviconFrames() is dependent on the supported
452 // scale factors of the platform. It is used for determining the goodness of 451 // scale factors of the platform. It is used for determining the goodness of
453 // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon(). 452 // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon().
454 // Force the values of the scale factors so that the tests produce the same 453 // Force the values of the scale factors so that the tests produce the same
455 // results on all platforms. 454 // results on all platforms.
456 std::vector<ui::ScaleFactor> scale_factors; 455 std::vector<ui::ScaleFactor> scale_factors;
457 scale_factors.push_back(ui::SCALE_FACTOR_100P); 456 scale_factors.push_back(ui::SCALE_FACTOR_100P);
458 scoped_set_supported_scale_factors_.reset( 457 scoped_set_supported_scale_factors_.reset(
459 new ui::test::ScopedSetSupportedScaleFactors(scale_factors)); 458 new ui::test::ScopedSetSupportedScaleFactors(scale_factors));
460 459
461 ChromeRenderViewHostTestHarness::SetUp(); 460 ChromeRenderViewHostTestHarness::SetUp();
462 } 461 }
463 462
464 virtual void TearDown() override { 463 void TearDown() override {
465 Profile* profile = Profile::FromBrowserContext( 464 Profile* profile = Profile::FromBrowserContext(
466 web_contents()->GetBrowserContext()); 465 web_contents()->GetBrowserContext());
467 FaviconServiceFactory::GetInstance()->SetTestingFactory( 466 FaviconServiceFactory::GetInstance()->SetTestingFactory(
468 profile, NULL); 467 profile, NULL);
469 ChromeRenderViewHostTestHarness::TearDown(); 468 ChromeRenderViewHostTestHarness::TearDown();
470 } 469 }
471 470
472 private: 471 private:
473 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> 472 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors>
474 ScopedSetSupportedScaleFactors; 473 ScopedSetSupportedScaleFactors;
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); 1541 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0);
1543 EXPECT_NE(0, download_id); 1542 EXPECT_NE(0, download_id);
1544 // Report download success with HTTP 200 status. 1543 // Report download success with HTTP 200 status.
1545 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, 1544 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url,
1546 empty_icons, empty_icon_sizes); 1545 empty_icons, empty_icon_sizes);
1547 // Icon is not marked as UnableToDownload as HTTP status is not 404. 1546 // Icon is not marked as UnableToDownload as HTTP status is not 404.
1548 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); 1547 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url));
1549 } 1548 }
1550 1549
1551 } // namespace. 1550 } // namespace.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698