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

Unified Diff: components/favicon/core/large_icon_service_unittest.cc

Issue 1318523011: [Password Manager] Copiable username and origin. Linkable origin elided from the left. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Icons appearance fixed Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/favicon/core/large_icon_service_unittest.cc
diff --git a/components/favicon/core/large_icon_service_unittest.cc b/components/favicon/core/large_icon_service_unittest.cc
index be6905251a0e13a4fe2adb95524b08f77f106b4f..64e1118acc7b7a33fa2da0310061ecfa216d3a08 100644
--- a/components/favicon/core/large_icon_service_unittest.cc
+++ b/components/favicon/core/large_icon_service_unittest.cc
@@ -137,6 +137,13 @@ class LargeIconServiceTest : public testing::Test {
EXPECT_FALSE(mock_favicon_service_->HasUnusedResults());
}
+ void setNonDefaultParsedFallbackStyle() {
+ parsed_fallback_icon_style_.background_color = SK_ColorGRAY;
+ parsed_fallback_icon_style_.text_color = SK_ColorWHITE;
+ parsed_fallback_icon_style_.font_size_ratio = 0.7;
+ parsed_fallback_icon_style_.roundness = 0.9;
+ }
+
protected:
base::MessageLoopForIO loop_;
@@ -146,6 +153,7 @@ class LargeIconServiceTest : public testing::Test {
favicon_base::FaviconRawBitmapResult expected_bitmap_;
scoped_ptr<favicon_base::FallbackIconStyle> expected_fallback_icon_style_;
+ favicon_base::FallbackIconStyle parsed_fallback_icon_style_;
bool is_callback_invoked_;
@@ -160,6 +168,7 @@ TEST_F(LargeIconServiceTest, SameSize) {
GURL(kDummyUrl),
24, // |min_source_size_in_pixel|
24, // |desired_size_in_pixel|
+ parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -170,9 +179,7 @@ TEST_F(LargeIconServiceTest, ScaleDown) {
mock_favicon_service_->InjectResult(CreateTestBitmap(32, 32, kTestColor));
expected_bitmap_ = CreateTestBitmap(24, 24, kTestColor);
large_icon_service_->GetLargeIconOrFallbackStyle(
- GURL(kDummyUrl),
- 24,
- 24,
+ GURL(kDummyUrl), 24, 24, parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -185,7 +192,7 @@ TEST_F(LargeIconServiceTest, ScaleUp) {
large_icon_service_->GetLargeIconOrFallbackStyle(
GURL(kDummyUrl),
14, // Lowered requirement so stored bitmap is admitted.
- 24,
+ 24, parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -197,9 +204,7 @@ TEST_F(LargeIconServiceTest, NoScale) {
mock_favicon_service_->InjectResult(CreateTestBitmap(24, 24, kTestColor));
expected_bitmap_ = CreateTestBitmap(24, 24, kTestColor);
large_icon_service_->GetLargeIconOrFallbackStyle(
- GURL(kDummyUrl),
- 16,
- 0,
+ GURL(kDummyUrl), 16, 0, parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -208,12 +213,14 @@ TEST_F(LargeIconServiceTest, NoScale) {
TEST_F(LargeIconServiceTest, FallbackSinceIconTooSmall) {
mock_favicon_service_->InjectResult(CreateTestBitmap(16, 16, kTestColor));
+ setNonDefaultParsedFallbackStyle();
expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
+ *expected_fallback_icon_style_ = parsed_fallback_icon_style_;
+ // The parsed background color should be overridden with the dominant color of
+ // the icon. Other specifications should be preserved.
expected_fallback_icon_style_->background_color = kTestColor;
large_icon_service_->GetLargeIconOrFallbackStyle(
- GURL(kDummyUrl),
- 24,
- 24,
+ GURL(kDummyUrl), 24, 24, parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -222,12 +229,14 @@ TEST_F(LargeIconServiceTest, FallbackSinceIconTooSmall) {
TEST_F(LargeIconServiceTest, FallbackSinceIconNotSquare) {
mock_favicon_service_->InjectResult(CreateTestBitmap(24, 32, kTestColor));
+ setNonDefaultParsedFallbackStyle();
expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
+ *expected_fallback_icon_style_ = parsed_fallback_icon_style_;
+ // The parsed background color should be overridden with the dominant color of
+ // the icon. Other specifications should be preserved.
expected_fallback_icon_style_->background_color = kTestColor;
large_icon_service_->GetLargeIconOrFallbackStyle(
- GURL(kDummyUrl),
- 24,
- 24,
+ GURL(kDummyUrl), 24, 24, parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -236,12 +245,12 @@ TEST_F(LargeIconServiceTest, FallbackSinceIconNotSquare) {
TEST_F(LargeIconServiceTest, FallbackSinceIconMissing) {
mock_favicon_service_->InjectResult(favicon_base::FaviconRawBitmapResult());
- // Expect default fallback style, including background.
+ setNonDefaultParsedFallbackStyle();
+ // Expect specified fallback style.
expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
+ *expected_fallback_icon_style_ = parsed_fallback_icon_style_;
large_icon_service_->GetLargeIconOrFallbackStyle(
- GURL(kDummyUrl),
- 24,
- 24,
+ GURL(kDummyUrl), 24, 24, parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -250,12 +259,12 @@ TEST_F(LargeIconServiceTest, FallbackSinceIconMissing) {
TEST_F(LargeIconServiceTest, FallbackSinceIconMissingNoScale) {
mock_favicon_service_->InjectResult(favicon_base::FaviconRawBitmapResult());
- // Expect default fallback style, including background.
+ setNonDefaultParsedFallbackStyle();
+ // Expect specified fallback style.
expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
+ *expected_fallback_icon_style_ = parsed_fallback_icon_style_;
large_icon_service_->GetLargeIconOrFallbackStyle(
- GURL(kDummyUrl),
- 24,
- 0,
+ GURL(kDummyUrl), 24, 0, parsed_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();
@@ -269,9 +278,7 @@ TEST_F(LargeIconServiceTest, FallbackSinceTooPicky) {
expected_fallback_icon_style_.reset(new favicon_base::FallbackIconStyle);
expected_fallback_icon_style_->background_color = kTestColor;
large_icon_service_->GetLargeIconOrFallbackStyle(
- GURL(kDummyUrl),
- 32,
- 24,
+ GURL(kDummyUrl), 32, 24, *expected_fallback_icon_style_,
base::Bind(&LargeIconServiceTest::ResultCallback, base::Unretained(this)),
&cancelable_task_tracker_);
base::MessageLoop::current()->RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698