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

Side by Side Diff: ios/chrome/browser/favicon/large_icon_cache_unittest.cc

Issue 2374753002: Track when fallback icon color is the default. (Closed)
Patch Set: Created 4 years, 2 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
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 "ios/chrome/browser/favicon/large_icon_cache.h" 5 #include "ios/chrome/browser/favicon/large_icon_cache.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "components/favicon_base/fallback_icon_style.h" 8 #include "components/favicon_base/fallback_icon_style.h"
9 #include "components/favicon_base/favicon_types.h" 9 #include "components/favicon_base/favicon_types.h"
10 #include "skia/ext/skia_utils_ios.h" 10 #include "skia/ext/skia_utils_ios.h"
(...skipping 25 matching lines...) Expand all
36 result.icon_type = favicon_base::TOUCH_ICON; 36 result.icon_type = favicon_base::TOUCH_ICON;
37 CHECK(result.is_valid()); 37 CHECK(result.is_valid());
38 return result; 38 return result;
39 } 39 }
40 40
41 class LargeIconCacheTest : public testing::Test { 41 class LargeIconCacheTest : public testing::Test {
42 public: 42 public:
43 LargeIconCacheTest() { 43 LargeIconCacheTest() {
44 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle()); 44 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle());
45 expected_fallback_icon_style_->background_color = kTestColor; 45 expected_fallback_icon_style_->background_color = kTestColor;
46 expected_fallback_icon_style_->is_default_background_color = false;
46 expected_bitmap_ = CreateTestBitmap(24, 24, kTestColor); 47 expected_bitmap_ = CreateTestBitmap(24, 24, kTestColor);
47 large_icon_cache_.reset(new LargeIconCache); 48 large_icon_cache_.reset(new LargeIconCache);
48 } 49 }
49 50
50 ~LargeIconCacheTest() override {} 51 ~LargeIconCacheTest() override {}
51 52
52 protected: 53 protected:
53 std::unique_ptr<LargeIconCache> large_icon_cache_; 54 std::unique_ptr<LargeIconCache> large_icon_cache_;
54 favicon_base::FaviconRawBitmapResult expected_bitmap_; 55 favicon_base::FaviconRawBitmapResult expected_bitmap_;
55 std::unique_ptr<favicon_base::FallbackIconStyle> 56 std::unique_ptr<favicon_base::FallbackIconStyle>
(...skipping 22 matching lines...) Expand all
78 79
79 std::unique_ptr<favicon_base::LargeIconResult> result1 = 80 std::unique_ptr<favicon_base::LargeIconResult> result1 =
80 large_icon_cache_->GetCachedResult(GURL(kDummyUrl)); 81 large_icon_cache_->GetCachedResult(GURL(kDummyUrl));
81 EXPECT_EQ(true, result1->bitmap.is_valid()); 82 EXPECT_EQ(true, result1->bitmap.is_valid());
82 EXPECT_EQ(expected_result1->bitmap.pixel_size, result1->bitmap.pixel_size); 83 EXPECT_EQ(expected_result1->bitmap.pixel_size, result1->bitmap.pixel_size);
83 84
84 std::unique_ptr<favicon_base::LargeIconResult> result2 = 85 std::unique_ptr<favicon_base::LargeIconResult> result2 =
85 large_icon_cache_->GetCachedResult(GURL(kDummyUrl2)); 86 large_icon_cache_->GetCachedResult(GURL(kDummyUrl2));
86 EXPECT_EQ(false, result2->bitmap.is_valid()); 87 EXPECT_EQ(false, result2->bitmap.is_valid());
87 EXPECT_EQ(expected_result2->fallback_icon_style->background_color, 88 EXPECT_EQ(expected_result2->fallback_icon_style->background_color,
88 result2->fallback_icon_style->background_color); 89 result2->fallback_icon_style->background_color);
pkotwicz 2016/09/28 03:52:52 Shouldn't you also test: EXPECT_EQ(expected_resul
sfiera 2016/09/28 13:15:52 Done.
89 90
90 // Test overwriting kDummyUrl. 91 // Test overwriting kDummyUrl.
91 large_icon_cache_->SetCachedResult(GURL(kDummyUrl), *expected_result2); 92 large_icon_cache_->SetCachedResult(GURL(kDummyUrl), *expected_result2);
92 std::unique_ptr<favicon_base::LargeIconResult> result3 = 93 std::unique_ptr<favicon_base::LargeIconResult> result3 =
93 large_icon_cache_->GetCachedResult(GURL(kDummyUrl2)); 94 large_icon_cache_->GetCachedResult(GURL(kDummyUrl2));
94 EXPECT_EQ(false, result3->bitmap.is_valid()); 95 EXPECT_EQ(false, result3->bitmap.is_valid());
95 EXPECT_EQ(expected_result2->fallback_icon_style->background_color, 96 EXPECT_EQ(expected_result2->fallback_icon_style->background_color,
96 result3->fallback_icon_style->background_color); 97 result3->fallback_icon_style->background_color);
pkotwicz 2016/09/28 03:52:52 Shouldn't you test is_default_background_color her
sfiera 2016/09/28 13:15:52 Done.
97 } 98 }
98 99
99 } // namespace 100 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698