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

Side by Side Diff: components/favicon/core/favicon_handler_unittest.cc

Issue 2948963002: Prefer 192x192 icons from Web Manifests instead of 144x144 (Closed)
Patch Set: Addressed comments. Created 3 years, 5 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
« no previous file with comments | « components/favicon/core/favicon_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/favicon/core/favicon_handler.h" 5 #include "components/favicon/core/favicon_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 EXPECT_CALL(favicon_service_, 1560 EXPECT_CALL(favicon_service_,
1561 SetFavicons(_, kManifestURL, WEB_MANIFEST_ICON, _)); 1561 SetFavicons(_, kManifestURL, WEB_MANIFEST_ICON, _));
1562 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL, _, _)); 1562 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL, _, _));
1563 1563
1564 RunHandlerWithSimpleFaviconCandidates({kIconURL12x12}, kManifestURL); 1564 RunHandlerWithSimpleFaviconCandidates({kIconURL12x12}, kManifestURL);
1565 EXPECT_THAT(favicon_service_.fake()->db_requests(), 1565 EXPECT_THAT(favicon_service_.fake()->db_requests(),
1566 ElementsAre(kPageURL, kManifestURL)); 1566 ElementsAre(kPageURL, kManifestURL));
1567 EXPECT_THAT(delegate_.downloads(), ElementsAre(kManifestURL, kIconURL16x16)); 1567 EXPECT_THAT(delegate_.downloads(), ElementsAre(kManifestURL, kIconURL16x16));
1568 } 1568 }
1569 1569
1570 // Test that icons from a web manifest use a desired size of 192x192.
1571 TEST_F(FaviconHandlerManifestsEnabledTest, Prefer192x192IconFromManifest) {
1572 const GURL kIconURL144x144 = GURL("http://www.google.com/favicon144x144");
1573 const GURL kIconURL192x192 = GURL("http://www.google.com/favicon192x192");
1574
1575 delegate_.fake_image_downloader().Add(kIconURL144x144, IntVector{144});
1576 delegate_.fake_image_downloader().Add(kIconURL192x192, IntVector{192});
1577
1578 const std::vector<favicon::FaviconURL> kManifestIcons = {
1579 FaviconURL(kIconURL144x144, WEB_MANIFEST_ICON,
1580 SizeVector(1U, gfx::Size(144, 144))),
1581 FaviconURL(kIconURL192x192, WEB_MANIFEST_ICON,
1582 SizeVector(1U, gfx::Size(192, 192))),
1583 };
1584
1585 delegate_.fake_manifest_downloader().Add(kManifestURL, kManifestIcons);
1586
1587 RunHandlerWithCandidates(FaviconDriverObserver::TOUCH_LARGEST,
1588 std::vector<favicon::FaviconURL>(), kManifestURL);
1589
1590 EXPECT_THAT(delegate_.downloads(),
1591 ElementsAre(kManifestURL, kIconURL192x192));
1592 }
1593
1570 // Test that the manifest and icon are redownloaded if the icon cached for the 1594 // Test that the manifest and icon are redownloaded if the icon cached for the
1571 // page URL expired. 1595 // page URL expired.
1572 TEST_F(FaviconHandlerManifestsEnabledTest, GetFaviconFromExpiredManifest) { 1596 TEST_F(FaviconHandlerManifestsEnabledTest, GetFaviconFromExpiredManifest) {
1573 const std::vector<favicon::FaviconURL> kManifestIcons = { 1597 const std::vector<favicon::FaviconURL> kManifestIcons = {
1574 FaviconURL(kIconURL64x64, FAVICON, kEmptySizes), 1598 FaviconURL(kIconURL64x64, FAVICON, kEmptySizes),
1575 }; 1599 };
1576 1600
1577 favicon_service_.fake()->Store( 1601 favicon_service_.fake()->Store(
1578 kPageURL, kManifestURL, 1602 kPageURL, kManifestURL,
1579 CreateRawBitmapResult(kManifestURL, WEB_MANIFEST_ICON, 1603 CreateRawBitmapResult(kManifestURL, WEB_MANIFEST_ICON,
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1990
1967 // Complete the download. 1991 // Complete the download.
1968 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _)); 1992 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _));
1969 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _)); 1993 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _));
1970 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually()); 1994 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually());
1971 base::RunLoop().RunUntilIdle(); 1995 base::RunLoop().RunUntilIdle();
1972 } 1996 }
1973 1997
1974 } // namespace 1998 } // namespace
1975 } // namespace favicon 1999 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698