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

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

Issue 2809783003: [LargeIconService] Report size of favicon for fallback style to UMA (Closed)
Patch Set: Ilya's comment #3 Created 3 years, 8 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/large_icon_service.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 16, 0); 392 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 16, 0);
393 EXPECT_EQ(gfx::Size(24, 24), *returned_bitmap_size_); 393 EXPECT_EQ(gfx::Size(24, 24), *returned_bitmap_size_);
394 EXPECT_EQ(nullptr, returned_fallback_style_); 394 EXPECT_EQ(nullptr, returned_fallback_style_);
395 } 395 }
396 396
397 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconTooSmall) { 397 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconTooSmall) {
398 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(16, 16, kTestColor)); 398 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(16, 16, kTestColor));
399 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24); 399 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24);
400 EXPECT_EQ(nullptr, returned_bitmap_size_); 400 EXPECT_EQ(nullptr, returned_bitmap_size_);
401 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor)); 401 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor));
402 histogram_tester_.ExpectUniqueSample("Favicons.LargeIconService.FallbackSize",
403 16, /*expected_count=*/1);
402 } 404 }
403 405
404 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconNotSquare) { 406 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconNotSquare) {
405 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 32, kTestColor)); 407 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 32, kTestColor));
406 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24); 408 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24);
407 EXPECT_EQ(nullptr, returned_bitmap_size_); 409 EXPECT_EQ(nullptr, returned_bitmap_size_);
408 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor)); 410 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor));
411 histogram_tester_.ExpectUniqueSample("Favicons.LargeIconService.FallbackSize",
412 24, /*expected_count=*/1);
409 } 413 }
410 414
411 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissing) { 415 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissing) {
412 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult()); 416 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult());
413 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24); 417 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24);
414 EXPECT_EQ(nullptr, returned_bitmap_size_); 418 EXPECT_EQ(nullptr, returned_bitmap_size_);
415 EXPECT_TRUE(returned_fallback_style_->is_default_background_color); 419 EXPECT_TRUE(returned_fallback_style_->is_default_background_color);
420 histogram_tester_.ExpectUniqueSample("Favicons.LargeIconService.FallbackSize",
421 0, /*expected_count=*/1);
416 } 422 }
417 423
418 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissingNoScale) { 424 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissingNoScale) {
419 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult()); 425 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult());
420 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 0); 426 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 0);
421 EXPECT_EQ(nullptr, returned_bitmap_size_); 427 EXPECT_EQ(nullptr, returned_bitmap_size_);
422 EXPECT_TRUE(returned_fallback_style_->is_default_background_color); 428 EXPECT_TRUE(returned_fallback_style_->is_default_background_color);
429 histogram_tester_.ExpectUniqueSample("Favicons.LargeIconService.FallbackSize",
430 0, /*expected_count=*/1);
423 } 431 }
424 432
425 // Oddball case where we demand a high resolution icon to scale down. Generates 433 // Oddball case where we demand a high resolution icon to scale down. Generates
426 // fallback even though an icon with the final size is available. 434 // fallback even though an icon with the final size is available.
427 TEST_P(LargeIconServiceGetterTest, FallbackSinceTooPicky) { 435 TEST_P(LargeIconServiceGetterTest, FallbackSinceTooPicky) {
428 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor)); 436 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor));
429 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 32, 24); 437 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 32, 24);
430 EXPECT_EQ(nullptr, returned_bitmap_size_); 438 EXPECT_EQ(nullptr, returned_bitmap_size_);
431 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor)); 439 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor));
440 histogram_tester_.ExpectUniqueSample("Favicons.LargeIconService.FallbackSize",
441 24, /*expected_count=*/1);
432 } 442 }
433 443
434 // Every test will appear with suffix /0 (param false) and /1 (param true), e.g. 444 // Every test will appear with suffix /0 (param false) and /1 (param true), e.g.
435 // LargeIconServiceGetterTest.FallbackSinceTooPicky/0: get image. 445 // LargeIconServiceGetterTest.FallbackSinceTooPicky/0: get image.
436 // LargeIconServiceGetterTest.FallbackSinceTooPicky/1: get raw bitmap. 446 // LargeIconServiceGetterTest.FallbackSinceTooPicky/1: get raw bitmap.
437 INSTANTIATE_TEST_CASE_P(, // Empty instatiation name. 447 INSTANTIATE_TEST_CASE_P(, // Empty instatiation name.
438 LargeIconServiceGetterTest, 448 LargeIconServiceGetterTest,
439 ::testing::Values(false, true)); 449 ::testing::Values(false, true));
440 450
441 } // namespace 451 } // namespace
442 } // namespace favicon 452 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/large_icon_service.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698