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

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

Issue 2784233003: [LargeIconService] Allow decoding of images in the service (Closed)
Patch Set: Peter's comments #4 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
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 11 matching lines...) Expand all
22 #include "components/favicon_base/favicon_types.h" 22 #include "components/favicon_base/favicon_types.h"
23 #include "components/image_fetcher/core/image_fetcher.h" 23 #include "components/image_fetcher/core/image_fetcher.h"
24 #include "components/image_fetcher/core/request_metadata.h" 24 #include "components/image_fetcher/core/request_metadata.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 27 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "third_party/skia/include/core/SkColor.h" 28 #include "third_party/skia/include/core/SkColor.h"
29 #include "ui/gfx/codec/png_codec.h" 29 #include "ui/gfx/codec/png_codec.h"
30 #include "ui/gfx/geometry/size.h" 30 #include "ui/gfx/geometry/size.h"
31 #include "ui/gfx/image/image.h" 31 #include "ui/gfx/image/image.h"
32 #include "ui/gfx/image/image_skia.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 34
34 namespace favicon { 35 namespace favicon {
35 namespace { 36 namespace {
36 37
38 using testing::IsNull;
39 using testing::Eq;
37 using testing::NiceMock; 40 using testing::NiceMock;
38 using testing::Return; 41 using testing::Return;
39 using testing::SaveArg; 42 using testing::SaveArg;
40 using testing::_; 43 using testing::_;
41 44
42 const char kDummyUrl[] = "http://www.example.com"; 45 const char kDummyUrl[] = "http://www.example.com";
43 const char kDummyIconUrl[] = "http://www.example.com/touch_icon.png"; 46 const char kDummyIconUrl[] = "http://www.example.com/touch_icon.png";
44 const SkColor kTestColor = SK_ColorRED; 47 const SkColor kTestColor = SK_ColorRED;
45 48
46 ACTION_P(PostFetchReply, p0) { 49 ACTION_P(PostFetchReply, p0) {
(...skipping 27 matching lines...) Expand all
74 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &data->data()); 77 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &data->data());
75 result.bitmap_data = data; 78 result.bitmap_data = data;
76 79
77 result.pixel_size = gfx::Size(w, h); 80 result.pixel_size = gfx::Size(w, h);
78 result.icon_url = GURL(kDummyIconUrl); 81 result.icon_url = GURL(kDummyIconUrl);
79 result.icon_type = favicon_base::TOUCH_ICON; 82 result.icon_type = favicon_base::TOUCH_ICON;
80 CHECK(result.is_valid()); 83 CHECK(result.is_valid());
81 return result; 84 return result;
82 } 85 }
83 86
87 bool HasBackgroundColor(
88 const favicon_base::FallbackIconStyle& fallback_icon_style,
89 SkColor color) {
90 return !fallback_icon_style.is_default_background_color &&
91 fallback_icon_style.background_color == color;
92 }
93
84 class MockImageFetcher : public image_fetcher::ImageFetcher { 94 class MockImageFetcher : public image_fetcher::ImageFetcher {
85 public: 95 public:
86 MOCK_METHOD1(SetImageFetcherDelegate, 96 MOCK_METHOD1(SetImageFetcherDelegate,
87 void(image_fetcher::ImageFetcherDelegate* delegate)); 97 void(image_fetcher::ImageFetcherDelegate* delegate));
88 MOCK_METHOD1(SetDataUseServiceName, 98 MOCK_METHOD1(SetDataUseServiceName,
89 void(image_fetcher::ImageFetcher::DataUseServiceName name)); 99 void(image_fetcher::ImageFetcher::DataUseServiceName name));
90 MOCK_METHOD1(SetImageDownloadLimit, 100 MOCK_METHOD1(SetImageDownloadLimit,
91 void(base::Optional<int64_t> max_download_bytes)); 101 void(base::Optional<int64_t> max_download_bytes));
92 MOCK_METHOD1(SetDesiredImageFrameSize, void(const gfx::Size& size)); 102 MOCK_METHOD1(SetDesiredImageFrameSize, void(const gfx::Size& size));
93 MOCK_METHOD3(StartOrQueueNetworkRequest, 103 MOCK_METHOD3(StartOrQueueNetworkRequest,
94 void(const std::string&, 104 void(const std::string&,
95 const GURL&, 105 const GURL&,
96 const ImageFetcherCallback&)); 106 const ImageFetcherCallback&));
97 MOCK_METHOD0(GetImageDecoder, image_fetcher::ImageDecoder*()); 107 MOCK_METHOD0(GetImageDecoder, image_fetcher::ImageDecoder*());
98 }; 108 };
99 109
100 class LargeIconServiceTest : public testing::Test { 110 class LargeIconServiceTest : public testing::Test {
101 public: 111 public:
102 LargeIconServiceTest() 112 LargeIconServiceTest()
103 : mock_image_fetcher_(new NiceMock<MockImageFetcher>()), 113 : mock_image_fetcher_(new NiceMock<MockImageFetcher>()),
104 large_icon_service_(&mock_favicon_service_, 114 large_icon_service_(&mock_favicon_service_,
105 base::ThreadTaskRunnerHandle::Get(), 115 base::ThreadTaskRunnerHandle::Get(),
106 base::WrapUnique(mock_image_fetcher_)), 116 base::WrapUnique(mock_image_fetcher_)) {}
107 is_callback_invoked_(false) {}
108 117
109 ~LargeIconServiceTest() override { 118 ~LargeIconServiceTest() override {}
110 }
111
112 void ResultCallback(const favicon_base::LargeIconResult& result) {
113 is_callback_invoked_ = true;
114
115 // Checking presence and absence of results.
116 EXPECT_EQ(expected_bitmap_.is_valid(), result.bitmap.is_valid());
117 EXPECT_EQ(expected_fallback_icon_style_ != nullptr,
118 result.fallback_icon_style != nullptr);
119
120 if (expected_bitmap_.is_valid()) {
121 EXPECT_EQ(expected_bitmap_.pixel_size, result.bitmap.pixel_size);
122 // Not actually checking bitmap content.
123 }
124 if (expected_fallback_icon_style_.get()) {
125 EXPECT_EQ(*expected_fallback_icon_style_,
126 *result.fallback_icon_style);
127 }
128 }
129
130 void InjectMockResult(
131 const GURL& page_url,
132 const favicon_base::FaviconRawBitmapResult& mock_result) {
133 EXPECT_CALL(mock_favicon_service_,
134 GetLargestRawFaviconForPageURL(page_url, _, _, _, _))
135 .WillOnce(PostReply<5>(mock_result));
136 }
137 119
138 protected: 120 protected:
139 base::MessageLoopForIO loop_; 121 base::MessageLoopForIO loop_;
140 122
141 NiceMock<MockImageFetcher>* mock_image_fetcher_; 123 NiceMock<MockImageFetcher>* mock_image_fetcher_;
142 testing::NiceMock<MockFaviconService> mock_favicon_service_; 124 testing::NiceMock<MockFaviconService> mock_favicon_service_;
143 LargeIconService large_icon_service_; 125 LargeIconService large_icon_service_;
144 base::CancelableTaskTracker cancelable_task_tracker_;
145
146 favicon_base::FaviconRawBitmapResult expected_bitmap_;
147 std::unique_ptr<favicon_base::FallbackIconStyle>
148 expected_fallback_icon_style_;
149
150 bool is_callback_invoked_;
151 126
152 private: 127 private:
153 DISALLOW_COPY_AND_ASSIGN(LargeIconServiceTest); 128 DISALLOW_COPY_AND_ASSIGN(LargeIconServiceTest);
154 }; 129 };
155 130
156 TEST_F(LargeIconServiceTest, SameSize) {
157 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor));
158 expected_bitmap_ = CreateTestBitmapResult(24, 24, kTestColor);
159 large_icon_service_.GetLargeIconOrFallbackStyle(
160 GURL(kDummyUrl),
161 24, // |min_source_size_in_pixel|
162 24, // |desired_size_in_pixel|
163 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
164 &cancelable_task_tracker_);
165 base::RunLoop().RunUntilIdle();
166 EXPECT_TRUE(is_callback_invoked_);
167 }
168
169 TEST_F(LargeIconServiceTest, ScaleDown) {
170 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(32, 32, kTestColor));
171 expected_bitmap_ = CreateTestBitmapResult(24, 24, kTestColor);
172 large_icon_service_.GetLargeIconOrFallbackStyle(
173 GURL(kDummyUrl), 24, 24,
174 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
175 &cancelable_task_tracker_);
176 base::RunLoop().RunUntilIdle();
177 EXPECT_TRUE(is_callback_invoked_);
178 }
179
180 TEST_F(LargeIconServiceTest, ScaleUp) {
181 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(16, 16, kTestColor));
182 expected_bitmap_ = CreateTestBitmapResult(24, 24, kTestColor);
183 large_icon_service_.GetLargeIconOrFallbackStyle(
184 GURL(kDummyUrl),
185 14, // Lowered requirement so stored bitmap is admitted.
186 24,
187 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
188 &cancelable_task_tracker_);
189 base::RunLoop().RunUntilIdle();
190 EXPECT_TRUE(is_callback_invoked_);
191 }
192
193 // |desired_size_in_pixel| == 0 means retrieve original image without scaling.
194 TEST_F(LargeIconServiceTest, NoScale) {
195 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor));
196 expected_bitmap_ = CreateTestBitmapResult(24, 24, kTestColor);
197 large_icon_service_.GetLargeIconOrFallbackStyle(
198 GURL(kDummyUrl), 16, 0,
199 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
200 &cancelable_task_tracker_);
201 base::RunLoop().RunUntilIdle();
202 EXPECT_TRUE(is_callback_invoked_);
203 }
204
205 TEST_F(LargeIconServiceTest, FallbackSinceIconTooSmall) {
206 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(16, 16, kTestColor));
207 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
208 expected_fallback_icon_style_->background_color = kTestColor;
209 expected_fallback_icon_style_->is_default_background_color = false;
210 large_icon_service_.GetLargeIconOrFallbackStyle(
211 GURL(kDummyUrl), 24, 24,
212 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
213 &cancelable_task_tracker_);
214 base::RunLoop().RunUntilIdle();
215 EXPECT_TRUE(is_callback_invoked_);
216 }
217
218 TEST_F(LargeIconServiceTest, FallbackSinceIconNotSquare) {
219 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 32, kTestColor));
220 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
221 expected_fallback_icon_style_->background_color = kTestColor;
222 expected_fallback_icon_style_->is_default_background_color = false;
223 large_icon_service_.GetLargeIconOrFallbackStyle(
224 GURL(kDummyUrl), 24, 24,
225 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
226 &cancelable_task_tracker_);
227 base::RunLoop().RunUntilIdle();
228 EXPECT_TRUE(is_callback_invoked_);
229 }
230
231 TEST_F(LargeIconServiceTest, FallbackSinceIconMissing) {
232 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult());
233 // Expect default fallback style, including background.
234 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
235 large_icon_service_.GetLargeIconOrFallbackStyle(
236 GURL(kDummyUrl), 24, 24,
237 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
238 &cancelable_task_tracker_);
239 base::RunLoop().RunUntilIdle();
240 EXPECT_TRUE(is_callback_invoked_);
241 }
242
243 TEST_F(LargeIconServiceTest, FallbackSinceIconMissingNoScale) {
244 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult());
245 // Expect default fallback style, including background.
246 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
247 large_icon_service_.GetLargeIconOrFallbackStyle(
248 GURL(kDummyUrl), 24, 0,
249 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
250 &cancelable_task_tracker_);
251 base::RunLoop().RunUntilIdle();
252 EXPECT_TRUE(is_callback_invoked_);
253 }
254
255 // Oddball case where we demand a high resolution icon to scale down. Generates
256 // fallback even though an icon with the final size is available.
257 TEST_F(LargeIconServiceTest, FallbackSinceTooPicky) {
258 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor));
259 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
260 expected_fallback_icon_style_->background_color = kTestColor;
261 expected_fallback_icon_style_->is_default_background_color = false;
262 large_icon_service_.GetLargeIconOrFallbackStyle(
263 GURL(kDummyUrl), 32, 24,
264 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
265 &cancelable_task_tracker_);
266 base::RunLoop().RunUntilIdle();
267 EXPECT_TRUE(is_callback_invoked_);
268 }
269
270 TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServer) { 131 TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServer) {
271 const GURL kExpectedServerUrl( 132 const GURL kExpectedServerUrl(
272 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true" 133 "https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true"
273 "&size=64&min_size=42&max_size=128&fallback_opts=TYPE,SIZE" 134 "&size=64&min_size=42&max_size=128&fallback_opts=TYPE,SIZE"
274 "&url=http://www.example.com/"); 135 "&url=http://www.example.com/");
275 136
276 EXPECT_CALL(mock_favicon_service_, UnableToDownloadFavicon(_)).Times(0); 137 EXPECT_CALL(mock_favicon_service_, UnableToDownloadFavicon(_)).Times(0);
277 138
278 base::MockCallback<base::Callback<void(bool success)>> callback; 139 base::MockCallback<base::Callback<void(bool success)>> callback;
279 EXPECT_CALL(*mock_image_fetcher_, 140 EXPECT_CALL(*mock_image_fetcher_,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 235
375 base::MockCallback<base::Callback<void(bool success)>> callback; 236 base::MockCallback<base::Callback<void(bool success)>> callback;
376 large_icon_service_ 237 large_icon_service_
377 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache( 238 .GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache(
378 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, callback.Get()); 239 GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, callback.Get());
379 240
380 EXPECT_CALL(callback, Run(false)); 241 EXPECT_CALL(callback, Run(false));
381 base::RunLoop().RunUntilIdle(); 242 base::RunLoop().RunUntilIdle();
382 } 243 }
383 244
245 class LargeIconServiceGetterTest : public LargeIconServiceTest,
246 public ::testing::WithParamInterface<bool> {
247 public:
248 LargeIconServiceGetterTest() : LargeIconServiceTest() {}
249 ~LargeIconServiceGetterTest() override {}
250
251 void GetLargeIconOrFallbackStyleAndWaitForCallback(
252 const GURL& page_url,
253 int min_source_size_in_pixel,
254 int desired_size_in_pixel) {
255 // Switch over testing two analogous functions based on the bool param.
256 if (GetParam()) {
257 large_icon_service_.GetLargeIconOrFallbackStyle(
258 page_url, min_source_size_in_pixel, desired_size_in_pixel,
259 base::Bind(&LargeIconServiceGetterTest::RawBitmapResultCallback,
260 base::Unretained(this)),
261 &cancelable_task_tracker_);
262 } else {
263 large_icon_service_.GetLargeIconImageOrFallbackStyle(
264 page_url, min_source_size_in_pixel, desired_size_in_pixel,
265 base::Bind(&LargeIconServiceGetterTest::ImageResultCallback,
266 base::Unretained(this)),
267 &cancelable_task_tracker_);
268 }
269 base::RunLoop().RunUntilIdle();
270 }
271
272 void RawBitmapResultCallback(const favicon_base::LargeIconResult& result) {
273 if (result.bitmap.is_valid()) {
274 returned_bitmap_size_ =
275 base::MakeUnique<gfx::Size>(result.bitmap.pixel_size);
276 }
277 StoreFallbackStyle(result.fallback_icon_style.get());
278 }
279
280 void ImageResultCallback(const favicon_base::LargeIconImageResult& result) {
281 if (!result.image.IsEmpty()) {
282 returned_bitmap_size_ =
283 base::MakeUnique<gfx::Size>(result.image.ToImageSkia()->size());
284 }
285 StoreFallbackStyle(result.fallback_icon_style.get());
286 }
287
288 void StoreFallbackStyle(
289 const favicon_base::FallbackIconStyle* fallback_style) {
290 if (fallback_style) {
291 returned_fallback_style_ =
292 base::MakeUnique<favicon_base::FallbackIconStyle>(*fallback_style);
293 }
294 }
295
296 void InjectMockResult(
297 const GURL& page_url,
298 const favicon_base::FaviconRawBitmapResult& mock_result) {
299 ON_CALL(mock_favicon_service_,
300 GetLargestRawFaviconForPageURL(page_url, _, _, _, _))
301 .WillByDefault(PostReply<5>(mock_result));
302 }
303
304 protected:
305 base::CancelableTaskTracker cancelable_task_tracker_;
306
307 std::unique_ptr<favicon_base::FallbackIconStyle> returned_fallback_style_;
308 std::unique_ptr<gfx::Size> returned_bitmap_size_;
309
310 private:
311 DISALLOW_COPY_AND_ASSIGN(LargeIconServiceGetterTest);
312 };
313
314 TEST_P(LargeIconServiceGetterTest, SameSize) {
315 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor));
316 GetLargeIconOrFallbackStyleAndWaitForCallback(
317 GURL(kDummyUrl),
318 24, // |min_source_size_in_pixel|
319 24); // |desired_size_in_pixel|
320 EXPECT_EQ(gfx::Size(24, 24), *returned_bitmap_size_);
321 EXPECT_EQ(nullptr, returned_fallback_style_);
322 }
323
324 TEST_P(LargeIconServiceGetterTest, ScaleDown) {
325 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(32, 32, kTestColor));
326 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24);
327 EXPECT_EQ(gfx::Size(24, 24), *returned_bitmap_size_);
328 EXPECT_EQ(nullptr, returned_fallback_style_);
329 }
330
331 TEST_P(LargeIconServiceGetterTest, ScaleUp) {
332 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(16, 16, kTestColor));
333 GetLargeIconOrFallbackStyleAndWaitForCallback(
334 GURL(kDummyUrl),
335 14, // Lowered requirement so stored bitmap is admitted.
336 24);
337 EXPECT_EQ(gfx::Size(24, 24), *returned_bitmap_size_);
338 EXPECT_EQ(nullptr, returned_fallback_style_);
339 }
340
341 // |desired_size_in_pixel| == 0 means retrieve original image without scaling.
342 TEST_P(LargeIconServiceGetterTest, NoScale) {
343 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor));
344 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 16, 0);
345 EXPECT_EQ(gfx::Size(24, 24), *returned_bitmap_size_);
346 EXPECT_EQ(nullptr, returned_fallback_style_);
347 }
348
349 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconTooSmall) {
350 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(16, 16, kTestColor));
351 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24);
352 EXPECT_EQ(nullptr, returned_bitmap_size_);
353 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor));
354 }
355
356 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconNotSquare) {
357 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 32, kTestColor));
358 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24);
359 EXPECT_EQ(nullptr, returned_bitmap_size_);
360 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor));
361 }
362
363 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissing) {
364 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult());
365 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 24);
366 EXPECT_EQ(nullptr, returned_bitmap_size_);
367 EXPECT_TRUE(returned_fallback_style_->is_default_background_color);
368 }
369
370 TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissingNoScale) {
371 InjectMockResult(GURL(kDummyUrl), favicon_base::FaviconRawBitmapResult());
372 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 24, 0);
373 EXPECT_EQ(nullptr, returned_bitmap_size_);
374 EXPECT_TRUE(returned_fallback_style_->is_default_background_color);
375 }
376
377 // Oddball case where we demand a high resolution icon to scale down. Generates
378 // fallback even though an icon with the final size is available.
379 TEST_P(LargeIconServiceGetterTest, FallbackSinceTooPicky) {
380 InjectMockResult(GURL(kDummyUrl), CreateTestBitmapResult(24, 24, kTestColor));
381 GetLargeIconOrFallbackStyleAndWaitForCallback(GURL(kDummyUrl), 32, 24);
382 EXPECT_EQ(nullptr, returned_bitmap_size_);
383 EXPECT_TRUE(HasBackgroundColor(*returned_fallback_style_, kTestColor));
384 }
385
386 // Every test will appear with suffix /0 (param false) and /1 (param true), e.g.
387 // LargeIconServiceGetterTest.FallbackSinceTooPicky/0: get image.
388 // LargeIconServiceGetterTest.FallbackSinceTooPicky/1: get raw bitmap.
389 INSTANTIATE_TEST_CASE_P(, // Empty instatiation name.
390 LargeIconServiceGetterTest,
391 ::testing::Values(false, true));
392
384 } // namespace 393 } // namespace
385 } // namespace favicon 394 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/large_icon_service.cc ('k') | components/favicon_base/favicon_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698