Chromium Code Reviews| 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 "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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1203 | 1203 |
| 1204 EXPECT_THAT( | 1204 EXPECT_THAT( |
| 1205 handler->GetIconURLs(), | 1205 handler->GetIconURLs(), |
| 1206 ElementsAre( | 1206 ElementsAre( |
| 1207 // The 512x512 bitmap is the best match for the desired size. | 1207 // The 512x512 bitmap is the best match for the desired size. |
| 1208 kIconURL1024_512, kIconURL1_17, kIconURL16_14, | 1208 kIconURL1024_512, kIconURL1_17, kIconURL16_14, |
| 1209 // The rest of bitmaps come in order, there is no "sizes" attribute. | 1209 // The rest of bitmaps come in order, there is no "sizes" attribute. |
| 1210 kIconURLWithoutSize1, kIconURLWithoutSize2)); | 1210 kIconURLWithoutSize1, kIconURLWithoutSize2)); |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 TEST_F(FaviconHandlerTest, TestSortTouchIconLargest) { | |
| 1214 const GURL kIconURLWithoutSize("http://www.google.com/touchicon-nosize"); | |
| 1215 const GURL kIconURL144x144("http://www.google.com/touchicon144x144"); | |
| 1216 const GURL kIconURL192x192("http://www.google.com/touchicon192x192"); | |
|
noyau (Ping after 24h)
2017/07/04 15:21:00
I'm trying to decipher these unit tests and at the
mastiz
2017/07/04 15:36:38
I can totally imagine the pain of parsing this big
noyau (Ping after 24h)
2017/07/05 07:28:32
Agreed about outside of this patch.
| |
| 1217 | |
| 1218 const std::vector<favicon::FaviconURL> kSourceIconURLs{ | |
| 1219 FaviconURL(kIconURLWithoutSize, TOUCH_ICON, kEmptySizes), | |
| 1220 FaviconURL(kIconURL144x144, TOUCH_ICON, | |
| 1221 SizeVector(1U, gfx::Size(144, 144))), | |
| 1222 FaviconURL(kIconURL192x192, TOUCH_ICON, | |
| 1223 SizeVector(1U, gfx::Size(192, 192))), | |
| 1224 }; | |
| 1225 | |
| 1226 std::unique_ptr<FaviconHandler> handler = RunHandlerWithCandidates( | |
| 1227 FaviconDriverObserver::TOUCH_LARGEST, kSourceIconURLs); | |
| 1228 | |
| 1229 EXPECT_THAT( | |
| 1230 handler->GetIconURLs(), | |
| 1231 ElementsAre(kIconURL192x192, kIconURL144x144, kIconURLWithoutSize)); | |
| 1232 } | |
| 1233 | |
| 1213 TEST_F(FaviconHandlerTest, TestDownloadLargestFavicon) { | 1234 TEST_F(FaviconHandlerTest, TestDownloadLargestFavicon) { |
| 1214 // Names represent the bitmap sizes per icon. | 1235 // Names represent the bitmap sizes per icon. |
| 1215 const GURL kIconURL1024_512("http://www.google.com/a"); | 1236 const GURL kIconURL1024_512("http://www.google.com/a"); |
| 1216 const GURL kIconURL15_14("http://www.google.com/b"); | 1237 const GURL kIconURL15_14("http://www.google.com/b"); |
| 1217 const GURL kIconURL16_512("http://www.google.com/c"); | 1238 const GURL kIconURL16_512("http://www.google.com/c"); |
| 1218 const GURL kIconURLWithoutSize1("http://www.google.com/d"); | 1239 const GURL kIconURLWithoutSize1("http://www.google.com/d"); |
| 1219 const GURL kIconURLWithoutSize2("http://www.google.com/e"); | 1240 const GURL kIconURLWithoutSize2("http://www.google.com/e"); |
| 1220 | 1241 |
| 1221 RunHandlerWithCandidates( | 1242 RunHandlerWithCandidates( |
| 1222 FaviconDriverObserver::NON_TOUCH_LARGEST, | 1243 FaviconDriverObserver::NON_TOUCH_LARGEST, |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1989 | 2010 |
| 1990 // Complete the download. | 2011 // Complete the download. |
| 1991 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _)); | 2012 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _)); |
| 1992 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _)); | 2013 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _)); |
| 1993 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually()); | 2014 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually()); |
| 1994 base::RunLoop().RunUntilIdle(); | 2015 base::RunLoop().RunUntilIdle(); |
| 1995 } | 2016 } |
| 1996 | 2017 |
| 1997 } // namespace | 2018 } // namespace |
| 1998 } // namespace favicon | 2019 } // namespace favicon |
| OLD | NEW |