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

Unified Diff: chrome/common/favicon/fallback_icon_url_parser_unittest.cc

Issue 1010783002: [Icons NTP] Working prototype to fetch, store, and display big icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaks and unit test fix. Created 5 years, 9 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: chrome/common/favicon/fallback_icon_url_parser_unittest.cc
diff --git a/chrome/common/favicon/fallback_icon_url_parser_unittest.cc b/chrome/common/favicon/fallback_icon_url_parser_unittest.cc
index 14f7dcc3028e2f825d2c6f3f9cb9a1a5e753c286..f22bb9520953be35b40b9c1f055ca5d0289cc9c1 100644
--- a/chrome/common/favicon/fallback_icon_url_parser_unittest.cc
+++ b/chrome/common/favicon/fallback_icon_url_parser_unittest.cc
@@ -213,39 +213,57 @@ TEST_F(FallbackIconUrlParserTest, ParseFallbackIconPathSuccess) {
{
chrome::ParsedFallbackIconPath parsed;
EXPECT_TRUE(parsed.Parse(specs + "/" + kTestUrlStr));
- EXPECT_EQ(GURL(kTestUrlStr), parsed.url());
EXPECT_EQ(31, parsed.size_in_pixels());
const favicon_base::FallbackIconStyle& style = parsed.style();
EXPECT_EQ(SkColorSetRGB(0x00, 0x00, 0x00), style.background_color);
EXPECT_EQ(SkColorSetRGB(0xFF, 0xFF, 0xFF), style.text_color);
EXPECT_EQ(0.75, style.font_size_ratio);
EXPECT_EQ(0.25, style.roundness);
+ EXPECT_EQ(GURL(kTestUrlStr), GURL(parsed.url_string()));
+ EXPECT_EQ(specs.length() + 1, parsed.path_index());
}
// Empty URL.
{
chrome::ParsedFallbackIconPath parsed;
EXPECT_TRUE(parsed.Parse(specs + "/"));
- EXPECT_EQ(GURL(), parsed.url());
EXPECT_EQ(31, parsed.size_in_pixels());
const favicon_base::FallbackIconStyle& style = parsed.style();
EXPECT_EQ(SkColorSetRGB(0x00, 0x00, 0x00), style.background_color);
EXPECT_EQ(SkColorSetRGB(0xFF, 0xFF, 0xFF), style.text_color);
EXPECT_EQ(0.75, style.font_size_ratio);
EXPECT_EQ(0.25, style.roundness);
+ EXPECT_EQ(GURL(), GURL(parsed.url_string()));
+ EXPECT_EQ(specs.length() + 1, parsed.path_index());
+ }
+
+ // Tolerate invalid URL.
+ {
+ chrome::ParsedFallbackIconPath parsed;
+ EXPECT_TRUE(parsed.Parse(specs + "/NOT A VALID URL"));
+ EXPECT_EQ(31, parsed.size_in_pixels());
+ const favicon_base::FallbackIconStyle& style = parsed.style();
+ EXPECT_EQ(SkColorSetRGB(0x00, 0x00, 0x00), style.background_color);
+ EXPECT_EQ(SkColorSetRGB(0xFF, 0xFF, 0xFF), style.text_color);
+ EXPECT_EQ(0.75, style.font_size_ratio);
+ EXPECT_EQ(0.25, style.roundness);
+ EXPECT_EQ("NOT A VALID URL", parsed.url_string());
+ EXPECT_EQ(specs.length() + 1, parsed.path_index());
}
// Size and style are default.
{
+ std::string specs2 = ",,,,";
chrome::ParsedFallbackIconPath parsed;
- EXPECT_TRUE(parsed.Parse(std::string(",,,,/") + kTestUrlStr));
- EXPECT_EQ(GURL(kTestUrlStr), parsed.url());
+ EXPECT_TRUE(parsed.Parse(specs2 + "/" + kTestUrlStr));
EXPECT_EQ(gfx::kFaviconSize, parsed.size_in_pixels());
const favicon_base::FallbackIconStyle& style = parsed.style();
EXPECT_EQ(kDefaultBackgroundColor, style.background_color);
EXPECT_EQ(kDefaultTextColorLight, style.text_color);
EXPECT_EQ(kDefaultFontSizeRatio, style.font_size_ratio);
EXPECT_EQ(kDefaultRoundness, style.roundness);
+ EXPECT_EQ(GURL(kTestUrlStr), GURL(parsed.url_string()));
+ EXPECT_EQ(specs2.length() + 1, parsed.path_index());
}
}
@@ -255,8 +273,6 @@ TEST_F(FallbackIconUrlParserTest, ParseFallbackIconPathFailure) {
"-1,000,fff,0.75,0.25/http://www.google.com/",
// Bad specs.
"32,#junk,fff,0.75,0.25/http://www.google.com/",
- // Bad URL.
- "32,000,fff,0.75,0.25/NOT A VALID URL",
};
for (size_t i = 0; i < arraysize(test_cases); ++i) {
chrome::ParsedFallbackIconPath parsed;
« no previous file with comments | « chrome/common/favicon/fallback_icon_url_parser.cc ('k') | chrome/renderer/chrome_content_renderer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698