| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), | 206 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), |
| 207 &cancelable_task_tracker_); | 207 &cancelable_task_tracker_); |
| 208 base::RunLoop().RunUntilIdle(); | 208 base::RunLoop().RunUntilIdle(); |
| 209 EXPECT_TRUE(is_callback_invoked_); | 209 EXPECT_TRUE(is_callback_invoked_); |
| 210 } | 210 } |
| 211 | 211 |
| 212 TEST_F(LargeIconServiceTest, FallbackSinceIconTooSmall) { | 212 TEST_F(LargeIconServiceTest, FallbackSinceIconTooSmall) { |
| 213 mock_favicon_service_->InjectResult(CreateTestBitmap(16, 16, kTestColor)); | 213 mock_favicon_service_->InjectResult(CreateTestBitmap(16, 16, kTestColor)); |
| 214 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle); | 214 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle); |
| 215 expected_fallback_icon_style_->background_color = kTestColor; | 215 expected_fallback_icon_style_->background_color = kTestColor; |
| 216 expected_fallback_icon_style_->is_default_background_color = false; |
| 216 large_icon_service_->GetLargeIconOrFallbackStyle( | 217 large_icon_service_->GetLargeIconOrFallbackStyle( |
| 217 GURL(kDummyUrl), | 218 GURL(kDummyUrl), |
| 218 24, | 219 24, |
| 219 24, | 220 24, |
| 220 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), | 221 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), |
| 221 &cancelable_task_tracker_); | 222 &cancelable_task_tracker_); |
| 222 base::RunLoop().RunUntilIdle(); | 223 base::RunLoop().RunUntilIdle(); |
| 223 EXPECT_TRUE(is_callback_invoked_); | 224 EXPECT_TRUE(is_callback_invoked_); |
| 224 } | 225 } |
| 225 | 226 |
| 226 TEST_F(LargeIconServiceTest, FallbackSinceIconNotSquare) { | 227 TEST_F(LargeIconServiceTest, FallbackSinceIconNotSquare) { |
| 227 mock_favicon_service_->InjectResult(CreateTestBitmap(24, 32, kTestColor)); | 228 mock_favicon_service_->InjectResult(CreateTestBitmap(24, 32, kTestColor)); |
| 228 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle); | 229 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle); |
| 229 expected_fallback_icon_style_->background_color = kTestColor; | 230 expected_fallback_icon_style_->background_color = kTestColor; |
| 231 expected_fallback_icon_style_->is_default_background_color = false; |
| 230 large_icon_service_->GetLargeIconOrFallbackStyle( | 232 large_icon_service_->GetLargeIconOrFallbackStyle( |
| 231 GURL(kDummyUrl), | 233 GURL(kDummyUrl), |
| 232 24, | 234 24, |
| 233 24, | 235 24, |
| 234 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), | 236 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), |
| 235 &cancelable_task_tracker_); | 237 &cancelable_task_tracker_); |
| 236 base::RunLoop().RunUntilIdle(); | 238 base::RunLoop().RunUntilIdle(); |
| 237 EXPECT_TRUE(is_callback_invoked_); | 239 EXPECT_TRUE(is_callback_invoked_); |
| 238 } | 240 } |
| 239 | 241 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 264 base::RunLoop().RunUntilIdle(); | 266 base::RunLoop().RunUntilIdle(); |
| 265 EXPECT_TRUE(is_callback_invoked_); | 267 EXPECT_TRUE(is_callback_invoked_); |
| 266 } | 268 } |
| 267 | 269 |
| 268 // Oddball case where we demand a high resolution icon to scale down. Generates | 270 // Oddball case where we demand a high resolution icon to scale down. Generates |
| 269 // fallback even though an icon with the final size is available. | 271 // fallback even though an icon with the final size is available. |
| 270 TEST_F(LargeIconServiceTest, FallbackSinceTooPicky) { | 272 TEST_F(LargeIconServiceTest, FallbackSinceTooPicky) { |
| 271 mock_favicon_service_->InjectResult(CreateTestBitmap(24, 24, kTestColor)); | 273 mock_favicon_service_->InjectResult(CreateTestBitmap(24, 24, kTestColor)); |
| 272 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle); | 274 expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle); |
| 273 expected_fallback_icon_style_->background_color = kTestColor; | 275 expected_fallback_icon_style_->background_color = kTestColor; |
| 276 expected_fallback_icon_style_->is_default_background_color = false; |
| 274 large_icon_service_->GetLargeIconOrFallbackStyle( | 277 large_icon_service_->GetLargeIconOrFallbackStyle( |
| 275 GURL(kDummyUrl), | 278 GURL(kDummyUrl), |
| 276 32, | 279 32, |
| 277 24, | 280 24, |
| 278 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), | 281 base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)), |
| 279 &cancelable_task_tracker_); | 282 &cancelable_task_tracker_); |
| 280 base::RunLoop().RunUntilIdle(); | 283 base::RunLoop().RunUntilIdle(); |
| 281 EXPECT_TRUE(is_callback_invoked_); | 284 EXPECT_TRUE(is_callback_invoked_); |
| 282 } | 285 } |
| 283 | 286 |
| 284 } // namespace | 287 } // namespace |
| 285 } // namespace favicon | 288 } // namespace favicon |
| OLD | NEW |