OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/large_icon_service.h" | 5 #include "components/favicon/core/large_icon_service.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "ui/gfx/image/image.h" | 33 #include "ui/gfx/image/image.h" |
34 #include "ui/gfx/image/image_skia.h" | 34 #include "ui/gfx/image/image_skia.h" |
35 #include "url/gurl.h" | 35 #include "url/gurl.h" |
36 | 36 |
37 namespace favicon { | 37 namespace favicon { |
38 namespace { | 38 namespace { |
39 | 39 |
40 using testing::IsEmpty; | 40 using testing::IsEmpty; |
41 using testing::IsNull; | 41 using testing::IsNull; |
42 using testing::Eq; | 42 using testing::Eq; |
| 43 using testing::HasSubstr; |
43 using testing::NiceMock; | 44 using testing::NiceMock; |
| 45 using testing::Not; |
| 46 using testing::Property; |
44 using testing::Return; | 47 using testing::Return; |
45 using testing::SaveArg; | 48 using testing::SaveArg; |
46 using testing::_; | 49 using testing::_; |
47 | 50 |
48 const char kDummyUrl[] = "http://www.example.com"; | 51 const char kDummyUrl[] = "http://www.example.com"; |
49 const char kDummyIconUrl[] = "http://www.example.com/touch_icon.png"; | 52 const char kDummyIconUrl[] = "http://www.example.com/touch_icon.png"; |
50 const SkColor kTestColor = SK_ColorRED; | 53 const SkColor kTestColor = SK_ColorRED; |
51 | 54 |
52 ACTION_P(PostFetchReply, p0) { | 55 ACTION_P(PostFetchReply, p0) { |
53 base::ThreadTaskRunnerHandle::Get()->PostTask( | 56 base::ThreadTaskRunnerHandle::Get()->PostTask( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 void(base::Optional<int64_t> max_download_bytes)); | 112 void(base::Optional<int64_t> max_download_bytes)); |
110 MOCK_METHOD1(SetDesiredImageFrameSize, void(const gfx::Size& size)); | 113 MOCK_METHOD1(SetDesiredImageFrameSize, void(const gfx::Size& size)); |
111 MOCK_METHOD4(StartOrQueueNetworkRequest, | 114 MOCK_METHOD4(StartOrQueueNetworkRequest, |
112 void(const std::string&, | 115 void(const std::string&, |
113 const GURL&, | 116 const GURL&, |
114 const ImageFetcherCallback&, | 117 const ImageFetcherCallback&, |
115 const net::NetworkTrafficAnnotationTag&)); | 118 const net::NetworkTrafficAnnotationTag&)); |
116 MOCK_METHOD0(GetImageDecoder, image_fetcher::ImageDecoder*()); | 119 MOCK_METHOD0(GetImageDecoder, image_fetcher::ImageDecoder*()); |
117 }; | 120 }; |
118 | 121 |
| 122 // TODO(jkrcal): Make the tests a bit crisper, see crbug.com/725822. |
119 class LargeIconServiceTest : public testing::Test { | 123 class LargeIconServiceTest : public testing::Test { |
120 public: | 124 public: |
121 LargeIconServiceTest() | 125 LargeIconServiceTest() |
122 : mock_image_fetcher_(new NiceMock<MockImageFetcher>()), | 126 : mock_image_fetcher_(new NiceMock<MockImageFetcher>()), |
123 large_icon_service_(&mock_favicon_service_, | 127 large_icon_service_(&mock_favicon_service_, |
124 base::ThreadTaskRunnerHandle::Get(), | 128 base::ThreadTaskRunnerHandle::Get(), |
125 base::WrapUnique(mock_image_fetcher_)) {} | 129 base::WrapUnique(mock_image_fetcher_)) {} |
126 | 130 |
127 ~LargeIconServiceTest() override {} | 131 ~LargeIconServiceTest() override {} |
128 | 132 |
(...skipping 23 matching lines...) Expand all Loading... |
152 .WillOnce(PostFetchReply(gfx::Image::CreateFrom1xBitmap( | 156 .WillOnce(PostFetchReply(gfx::Image::CreateFrom1xBitmap( |
153 CreateTestSkBitmap(64, 64, kTestColor)))); | 157 CreateTestSkBitmap(64, 64, kTestColor)))); |
154 EXPECT_CALL(mock_favicon_service_, | 158 EXPECT_CALL(mock_favicon_service_, |
155 SetLastResortFavicons(GURL(kDummyUrl), kExpectedServerUrl, | 159 SetLastResortFavicons(GURL(kDummyUrl), kExpectedServerUrl, |
156 favicon_base::IconType::TOUCH_ICON, _, _)) | 160 favicon_base::IconType::TOUCH_ICON, _, _)) |
157 .WillOnce(PostBoolReply(true)); | 161 .WillOnce(PostBoolReply(true)); |
158 | 162 |
159 large_icon_service_ | 163 large_icon_service_ |
160 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 164 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
161 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, | 165 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, |
162 /*desired_size_in_pixel=*/61, callback.Get()); | 166 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/true, |
| 167 callback.Get()); |
163 | 168 |
164 EXPECT_CALL(callback, Run(true)); | 169 EXPECT_CALL(callback, Run(true)); |
165 base::RunLoop().RunUntilIdle(); | 170 base::RunLoop().RunUntilIdle(); |
166 histogram_tester_.ExpectUniqueSample( | 171 histogram_tester_.ExpectUniqueSample( |
167 "Favicons.LargeIconService.DownloadedSize", 64, /*expected_count=*/1); | 172 "Favicons.LargeIconService.DownloadedSize", 64, /*expected_count=*/1); |
168 } | 173 } |
169 | 174 |
170 TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServerWithCustomUrl) { | 175 TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServerWithCustomUrl) { |
171 variations::testing::VariationParamsManager variation_params( | 176 variations::testing::VariationParamsManager variation_params( |
172 "LargeIconServiceFetching", | 177 "LargeIconServiceFetching", |
173 {{"request_format", | 178 {{"request_format", |
174 "https://t0.gstatic.com/" | 179 "https://t0.gstatic.com/" |
175 "faviconV2?size=%d&min_size=%d&max_size=%d&url=%s"}, | 180 "faviconV2?%ssize=%d&min_size=%d&max_size=%d&url=%s"}, |
176 {"enforced_min_size_in_pixel", "43"}, | 181 {"enforced_min_size_in_pixel", "43"}, |
177 {"desired_to_max_size_factor", "1.5"}}, | 182 {"desired_to_max_size_factor", "1.5"}}, |
178 {"LargeIconServiceFetching"}); | 183 {"LargeIconServiceFetching"}); |
179 const GURL kExpectedServerUrl( | 184 const GURL kExpectedServerUrl( |
180 "https://t0.gstatic.com/" | 185 "https://t0.gstatic.com/faviconV2?check_seen=true&" |
181 "faviconV2?size=61&min_size=43&max_size=91&url=http://www.example.com/"); | 186 "size=61&min_size=43&max_size=91&url=http://www.example.com/"); |
182 | 187 |
183 EXPECT_CALL(mock_favicon_service_, UnableToDownloadFavicon(_)).Times(0); | 188 EXPECT_CALL(mock_favicon_service_, UnableToDownloadFavicon(_)).Times(0); |
184 | 189 |
185 base::MockCallback<base::Callback<void(bool success)>> callback; | 190 base::MockCallback<base::Callback<void(bool success)>> callback; |
186 EXPECT_CALL(*mock_image_fetcher_, | 191 EXPECT_CALL(*mock_image_fetcher_, |
187 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) | 192 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) |
188 .WillOnce(PostFetchReply(gfx::Image::CreateFrom1xBitmap( | 193 .WillOnce(PostFetchReply(gfx::Image::CreateFrom1xBitmap( |
189 CreateTestSkBitmap(64, 64, kTestColor)))); | 194 CreateTestSkBitmap(64, 64, kTestColor)))); |
190 EXPECT_CALL(mock_favicon_service_, | 195 EXPECT_CALL(mock_favicon_service_, |
191 SetLastResortFavicons(GURL(kDummyUrl), kExpectedServerUrl, | 196 SetLastResortFavicons(GURL(kDummyUrl), kExpectedServerUrl, |
192 favicon_base::IconType::TOUCH_ICON, _, _)) | 197 favicon_base::IconType::TOUCH_ICON, _, _)) |
193 .WillOnce(PostBoolReply(true)); | 198 .WillOnce(PostBoolReply(true)); |
194 | 199 |
195 large_icon_service_ | 200 large_icon_service_ |
196 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 201 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
197 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, | 202 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, |
198 /*desired_size_in_pixel=*/61, callback.Get()); | 203 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/true, |
| 204 callback.Get()); |
199 | 205 |
200 EXPECT_CALL(callback, Run(true)); | 206 EXPECT_CALL(callback, Run(true)); |
201 base::RunLoop().RunUntilIdle(); | 207 base::RunLoop().RunUntilIdle(); |
202 } | 208 } |
203 | 209 |
204 TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServerWithOriginalUrl) { | 210 TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServerWithOriginalUrl) { |
205 const GURL kExpectedServerUrl( | 211 const GURL kExpectedServerUrl( |
206 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" | 212 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" |
207 "&check_seen=true&size=61&min_size=42&max_size=122" | 213 "&check_seen=true&size=61&min_size=42&max_size=122" |
208 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"); | 214 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"); |
209 const GURL kExpectedOriginalUrl("http://www.example.com/favicon.png"); | 215 const GURL kExpectedOriginalUrl("http://www.example.com/favicon.png"); |
210 | 216 |
211 image_fetcher::RequestMetadata expected_metadata; | 217 image_fetcher::RequestMetadata expected_metadata; |
212 expected_metadata.content_location_header = kExpectedOriginalUrl.spec(); | 218 expected_metadata.content_location_header = kExpectedOriginalUrl.spec(); |
213 EXPECT_CALL(*mock_image_fetcher_, | 219 EXPECT_CALL(*mock_image_fetcher_, |
214 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) | 220 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) |
215 .WillOnce(PostFetchReplyWithMetadata( | 221 .WillOnce(PostFetchReplyWithMetadata( |
216 gfx::Image::CreateFrom1xBitmap( | 222 gfx::Image::CreateFrom1xBitmap( |
217 CreateTestSkBitmap(64, 64, kTestColor)), | 223 CreateTestSkBitmap(64, 64, kTestColor)), |
218 expected_metadata)); | 224 expected_metadata)); |
219 EXPECT_CALL(mock_favicon_service_, | 225 EXPECT_CALL(mock_favicon_service_, |
220 SetLastResortFavicons(GURL(kDummyUrl), kExpectedOriginalUrl, | 226 SetLastResortFavicons(GURL(kDummyUrl), kExpectedOriginalUrl, |
221 favicon_base::IconType::TOUCH_ICON, _, _)) | 227 favicon_base::IconType::TOUCH_ICON, _, _)) |
222 .WillOnce(PostBoolReply(true)); | 228 .WillOnce(PostBoolReply(true)); |
223 | 229 |
224 base::MockCallback<base::Callback<void(bool success)>> callback; | 230 base::MockCallback<base::Callback<void(bool success)>> callback; |
225 large_icon_service_ | 231 large_icon_service_ |
226 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 232 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
227 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, | 233 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, |
228 /*desired_size_in_pixel=*/61, callback.Get()); | 234 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/true, |
| 235 callback.Get()); |
229 | 236 |
230 EXPECT_CALL(callback, Run(true)); | 237 EXPECT_CALL(callback, Run(true)); |
231 base::RunLoop().RunUntilIdle(); | 238 base::RunLoop().RunUntilIdle(); |
232 } | 239 } |
233 | 240 |
234 TEST_F(LargeIconServiceTest, ShouldTrimQueryParametersForGoogleServer) { | 241 TEST_F(LargeIconServiceTest, ShouldTrimQueryParametersForGoogleServer) { |
235 const GURL kDummyUrlWithQuery("http://www.example.com?foo=1"); | 242 const GURL kDummyUrlWithQuery("http://www.example.com?foo=1"); |
236 const GURL kExpectedServerUrl( | 243 const GURL kExpectedServerUrl( |
237 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" | 244 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" |
238 "&check_seen=true&size=61&min_size=42&max_size=122" | 245 "&check_seen=true&size=61&min_size=42&max_size=122" |
239 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"); | 246 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"); |
240 | 247 |
241 EXPECT_CALL(*mock_image_fetcher_, | 248 EXPECT_CALL(*mock_image_fetcher_, |
242 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) | 249 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) |
243 .WillOnce(PostFetchReply(gfx::Image::CreateFrom1xBitmap( | 250 .WillOnce(PostFetchReply(gfx::Image::CreateFrom1xBitmap( |
244 CreateTestSkBitmap(64, 64, kTestColor)))); | 251 CreateTestSkBitmap(64, 64, kTestColor)))); |
245 // Verify that the non-trimmed page URL is used when writing to the database. | 252 // Verify that the non-trimmed page URL is used when writing to the database. |
246 EXPECT_CALL(mock_favicon_service_, | 253 EXPECT_CALL(mock_favicon_service_, |
247 SetLastResortFavicons(_, kExpectedServerUrl, _, _, _)); | 254 SetLastResortFavicons(_, kExpectedServerUrl, _, _, _)); |
248 | 255 |
249 large_icon_service_ | 256 large_icon_service_ |
250 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 257 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
251 GURL(kDummyUrlWithQuery), /*min_source_size_in_pixel=*/42, | 258 GURL(kDummyUrlWithQuery), /*min_source_size_in_pixel=*/42, |
252 /*desired_size_in_pixel=*/61, base::Callback<void(bool success)>()); | 259 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/true, |
| 260 base::Callback<void(bool success)>()); |
253 | 261 |
254 base::RunLoop().RunUntilIdle(); | 262 base::RunLoop().RunUntilIdle(); |
255 } | 263 } |
256 | 264 |
| 265 TEST_F(LargeIconServiceTest, ShouldNotCheckOnPublicUrls) { |
| 266 // The request has no "check_seen=true"; full URL is tested elsewhere. |
| 267 EXPECT_CALL( |
| 268 *mock_image_fetcher_, |
| 269 StartOrQueueNetworkRequest( |
| 270 _, Property(&GURL::query, Not(HasSubstr("check_seen=true"))), _, _)) |
| 271 .WillOnce(PostFetchReply(gfx::Image())); |
| 272 |
| 273 base::MockCallback<base::Callback<void(bool success)>> callback; |
| 274 |
| 275 large_icon_service_ |
| 276 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
| 277 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, |
| 278 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/false, |
| 279 callback.Get()); |
| 280 |
| 281 EXPECT_CALL(callback, Run(false)); |
| 282 base::RunLoop().RunUntilIdle(); |
| 283 } |
| 284 |
257 TEST_F(LargeIconServiceTest, ShouldNotQueryGoogleServerIfInvalidScheme) { | 285 TEST_F(LargeIconServiceTest, ShouldNotQueryGoogleServerIfInvalidScheme) { |
258 const GURL kDummyFtpUrl("ftp://www.example.com"); | 286 const GURL kDummyFtpUrl("ftp://www.example.com"); |
259 | 287 |
260 EXPECT_CALL(*mock_image_fetcher_, StartOrQueueNetworkRequest(_, _, _, _)) | 288 EXPECT_CALL(*mock_image_fetcher_, StartOrQueueNetworkRequest(_, _, _, _)) |
261 .Times(0); | 289 .Times(0); |
262 | 290 |
263 base::MockCallback<base::Callback<void(bool success)>> callback; | 291 base::MockCallback<base::Callback<void(bool success)>> callback; |
264 | 292 |
265 large_icon_service_ | 293 large_icon_service_ |
266 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 294 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
267 GURL(kDummyFtpUrl), /*min_source_size_in_pixel=*/42, | 295 GURL(kDummyFtpUrl), /*min_source_size_in_pixel=*/42, |
268 /*desired_size_in_pixel=*/61, callback.Get()); | 296 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/true, |
| 297 callback.Get()); |
269 | 298 |
270 EXPECT_CALL(callback, Run(false)); | 299 EXPECT_CALL(callback, Run(false)); |
271 base::RunLoop().RunUntilIdle(); | 300 base::RunLoop().RunUntilIdle(); |
272 EXPECT_THAT(histogram_tester_.GetAllSamples( | 301 EXPECT_THAT(histogram_tester_.GetAllSamples( |
273 "Favicons.LargeIconService.DownloadedSize"), | 302 "Favicons.LargeIconService.DownloadedSize"), |
274 IsEmpty()); | 303 IsEmpty()); |
275 } | 304 } |
276 | 305 |
277 TEST_F(LargeIconServiceTest, ShouldReportUnavailableIfFetchFromServerFails) { | 306 TEST_F(LargeIconServiceTest, ShouldReportUnavailableIfFetchFromServerFails) { |
278 const GURL kDummyUrlWithQuery("http://www.example.com?foo=1"); | 307 const GURL kDummyUrlWithQuery("http://www.example.com?foo=1"); |
279 const GURL kExpectedServerUrl( | 308 const GURL kExpectedServerUrl( |
280 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" | 309 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" |
281 "&check_seen=true&size=61&min_size=42&max_size=122" | 310 "&check_seen=true&size=61&min_size=42&max_size=122" |
282 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"); | 311 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"); |
283 | 312 |
284 EXPECT_CALL(mock_favicon_service_, SetLastResortFavicons(_, _, _, _, _)) | 313 EXPECT_CALL(mock_favicon_service_, SetLastResortFavicons(_, _, _, _, _)) |
285 .Times(0); | 314 .Times(0); |
286 | 315 |
287 base::MockCallback<base::Callback<void(bool success)>> callback; | 316 base::MockCallback<base::Callback<void(bool success)>> callback; |
288 EXPECT_CALL(*mock_image_fetcher_, | 317 EXPECT_CALL(*mock_image_fetcher_, |
289 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) | 318 StartOrQueueNetworkRequest(_, kExpectedServerUrl, _, _)) |
290 .WillOnce(PostFetchReply(gfx::Image())); | 319 .WillOnce(PostFetchReply(gfx::Image())); |
291 EXPECT_CALL(mock_favicon_service_, | 320 EXPECT_CALL(mock_favicon_service_, |
292 UnableToDownloadFavicon(kExpectedServerUrl)); | 321 UnableToDownloadFavicon(kExpectedServerUrl)); |
293 | 322 |
294 large_icon_service_ | 323 large_icon_service_ |
295 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 324 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
296 kDummyUrlWithQuery, /*min_source_size_in_pixel=*/42, | 325 kDummyUrlWithQuery, /*min_source_size_in_pixel=*/42, |
297 /*desired_size_in_pixel=*/61, callback.Get()); | 326 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/true, |
| 327 callback.Get()); |
298 | 328 |
299 EXPECT_CALL(callback, Run(false)); | 329 EXPECT_CALL(callback, Run(false)); |
300 base::RunLoop().RunUntilIdle(); | 330 base::RunLoop().RunUntilIdle(); |
301 // Verify that download failure gets recorded. | 331 // Verify that download failure gets recorded. |
302 histogram_tester_.ExpectUniqueSample( | 332 histogram_tester_.ExpectUniqueSample( |
303 "Favicons.LargeIconService.DownloadedSize", 0, /*expected_count=*/1); | 333 "Favicons.LargeIconService.DownloadedSize", 0, /*expected_count=*/1); |
304 } | 334 } |
305 | 335 |
306 TEST_F(LargeIconServiceTest, ShouldNotGetFromGoogleServerIfUnavailable) { | 336 TEST_F(LargeIconServiceTest, ShouldNotGetFromGoogleServerIfUnavailable) { |
307 ON_CALL( | 337 ON_CALL( |
308 mock_favicon_service_, | 338 mock_favicon_service_, |
309 WasUnableToDownloadFavicon(GURL( | 339 WasUnableToDownloadFavicon(GURL( |
310 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" | 340 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" |
311 "&check_seen=true&size=61&min_size=42&max_size=122" | 341 "&check_seen=true&size=61&min_size=42&max_size=122" |
312 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"))) | 342 "&fallback_opts=TYPE,SIZE,URL&url=http://www.example.com/"))) |
313 .WillByDefault(Return(true)); | 343 .WillByDefault(Return(true)); |
314 | 344 |
315 EXPECT_CALL(mock_favicon_service_, UnableToDownloadFavicon(_)).Times(0); | 345 EXPECT_CALL(mock_favicon_service_, UnableToDownloadFavicon(_)).Times(0); |
316 EXPECT_CALL(*mock_image_fetcher_, StartOrQueueNetworkRequest(_, _, _, _)) | 346 EXPECT_CALL(*mock_image_fetcher_, StartOrQueueNetworkRequest(_, _, _, _)) |
317 .Times(0); | 347 .Times(0); |
318 EXPECT_CALL(mock_favicon_service_, SetLastResortFavicons(_, _, _, _, _)) | 348 EXPECT_CALL(mock_favicon_service_, SetLastResortFavicons(_, _, _, _, _)) |
319 .Times(0); | 349 .Times(0); |
320 | 350 |
321 base::MockCallback<base::Callback<void(bool success)>> callback; | 351 base::MockCallback<base::Callback<void(bool success)>> callback; |
322 large_icon_service_ | 352 large_icon_service_ |
323 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( | 353 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( |
324 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, | 354 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, |
325 /*desired_size_in_pixel=*/61, callback.Get()); | 355 /*desired_size_in_pixel=*/61, /*may_page_url_be_private=*/true, |
| 356 callback.Get()); |
326 | 357 |
327 EXPECT_CALL(callback, Run(false)); | 358 EXPECT_CALL(callback, Run(false)); |
328 base::RunLoop().RunUntilIdle(); | 359 base::RunLoop().RunUntilIdle(); |
329 EXPECT_THAT(histogram_tester_.GetAllSamples( | 360 EXPECT_THAT(histogram_tester_.GetAllSamples( |
330 "Favicons.LargeIconService.DownloadedSize"), | 361 "Favicons.LargeIconService.DownloadedSize"), |
331 IsEmpty()); | 362 IsEmpty()); |
332 } | 363 } |
333 | 364 |
334 class LargeIconServiceGetterTest : public LargeIconServiceTest, | 365 class LargeIconServiceGetterTest : public LargeIconServiceTest, |
335 public ::testing::WithParamInterface<bool> { | 366 public ::testing::WithParamInterface<bool> { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 515 |
485 // Every test will appear with suffix /0 (param false) and /1 (param true), e.g. | 516 // Every test will appear with suffix /0 (param false) and /1 (param true), e.g. |
486 // LargeIconServiceGetterTest.FallbackSinceTooPicky/0: get image. | 517 // LargeIconServiceGetterTest.FallbackSinceTooPicky/0: get image. |
487 // LargeIconServiceGetterTest.FallbackSinceTooPicky/1: get raw bitmap. | 518 // LargeIconServiceGetterTest.FallbackSinceTooPicky/1: get raw bitmap. |
488 INSTANTIATE_TEST_CASE_P(, // Empty instatiation name. | 519 INSTANTIATE_TEST_CASE_P(, // Empty instatiation name. |
489 LargeIconServiceGetterTest, | 520 LargeIconServiceGetterTest, |
490 ::testing::Values(false, true)); | 521 ::testing::Values(false, true)); |
491 | 522 |
492 } // namespace | 523 } // namespace |
493 } // namespace favicon | 524 } // namespace favicon |
OLD | NEW |