BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / favicon / chrome_fallback_icon_client_unittest.cc
blob81a6b89465c77131043ca100f5e087d14ad6d314
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
3 // found in the LICENSE file.
5 #include "chrome/browser/favicon/chrome_fallback_icon_client.h"
7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h"
12 TEST(ChromeFallbackIconClientTest, GetFontNameList) {
13 ChromeFallbackIconClient client;
14 // Just ensure non-empty, otherwise not checking the actual font.
15 EXPECT_FALSE(client.GetFontNameList().empty());
18 TEST(ChromeFallbackIconClientTest, GetFallbackIconText) {
19 struct {
20 const char* url_str;
21 const char* expected;
22 } test_cases[] = {
23 // Test vacuous or invalid cases.
24 {"", ""},
25 {"http:///", ""},
26 {"this is not an URL", ""},
27 {"!@#$%^&*()", ""},
28 // Test URLs with a domain in the registry.
29 {"http://www.google.com/", "G"},
30 {"ftp://GOogLE.com/", "G"},
31 {"https://www.google.com:8080/path?query#ref", "G"},
32 {"http://www.amazon.com", "A"},
33 {"http://zmzaon.co.uk/", "Z"},
34 {"http://w-3.137.org", "1"},
35 // Test URLs with a domian not in the registry.
36 {"http://localhost/", "L"},
37 {"chrome-search://local-ntp/local-ntp.html", "L"},
38 // Test IP URLs.
39 {"http://192.168.0.1/", "IP"},
40 {"http://[2001:4860:4860::8888]/", "IP"},
41 // Miscellaneous edge cases.
42 {"http://www..com/", "."},
43 {"http://ip.ip/", "I"},
44 // xn-- related cases: we're not supporint xn-- yet
45 {"http://xn--oogle-60a/", "X"},
46 {"http://xn-oogle-60a/", "X"},
48 for (size_t i = 0; i < arraysize(test_cases); ++i) {
49 ChromeFallbackIconClient client;
50 base::string16 expected = base::ASCIIToUTF16(test_cases[i].expected);
51 GURL url(test_cases[i].url_str);
52 EXPECT_EQ(expected, client.GetFallbackIconText(url))
53 << " for test_cases[" << i << "]";