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

Side by Side Diff: components/url_formatter/elide_url_unittest.cc

Issue 2798443003: Run all TextEliderTest tests on iOS (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/url_formatter/elide_url.h" 5 #include "components/url_formatter/elide_url.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 177
178 TEST(TextEliderTest, TestHostEliding) { 178 TEST(TextEliderTest, TestHostEliding) {
179 const std::string kEllipsisStr(gfx::kEllipsis); 179 const std::string kEllipsisStr(gfx::kEllipsis);
180 Testcase testcases[] = { 180 Testcase testcases[] = {
181 {"http://google.com", "google.com"}, 181 {"http://google.com", "google.com"},
182 {"http://reallyreallyreallylongdomainname.com", 182 {"http://reallyreallyreallylongdomainname.com",
183 "reallyreallyreallylongdomainname.com"}, 183 "reallyreallyreallylongdomainname.com"},
184 {"http://foo", "foo"}, 184 {"http://foo", "foo"},
185 {"http://foo.bar", "foo.bar"}, 185 {"http://foo.bar", "foo.bar"},
186 #if !defined(OS_IOS)
187 // iOS width calculations are off by a letter from other platforms for
188 // strings with too many kerned letters on the default font set.
189 // TODO(rohitrao): Fix secure_display::ElideHost for iOS
190 // (crbug.com/517604).
191 {"http://subdomain.google.com", kEllipsisStr + ".google.com"}, 186 {"http://subdomain.google.com", kEllipsisStr + ".google.com"},
192 {"http://a.b.c.d.e.f.com", kEllipsisStr + "f.com"}, 187 {"http://a.b.c.d.e.f.com", kEllipsisStr + "f.com"},
193 {"http://subdomain.foo.bar", kEllipsisStr + "in.foo.bar"}, 188 {"http://subdomain.foo.bar", kEllipsisStr + "in.foo.bar"},
194 {"http://subdomain.reallylongdomainname.com", 189 {"http://subdomain.reallylongdomainname.com",
195 kEllipsisStr + "ain.reallylongdomainname.com"}, 190 kEllipsisStr + "ain.reallylongdomainname.com"},
196 {"http://a.b.c.d.e.f.com", kEllipsisStr + ".e.f.com"}, 191 {"http://a.b.c.d.e.f.com", kEllipsisStr + ".e.f.com"},
197 // IDN - Greek alpha.beta.gamma.delta.epsilon.zeta.com 192 // IDN - Greek alpha.beta.gamma.delta.epsilon.zeta.com
198 {"http://xn--mxa.xn--nxa.xn--oxa.xn--pxa.xn--qxa.xn--rxa.com", 193 {"http://xn--mxa.xn--nxa.xn--oxa.xn--pxa.xn--qxa.xn--rxa.com",
199 kEllipsisStr + ".\xCE\xB5.\xCE\xB6.com"}, 194 kEllipsisStr + ".\xCE\xB5.\xCE\xB6.com"},
200 #endif // !defined(OS_IOS)
201 }; 195 };
202 196
203 for (size_t i = 0; i < arraysize(testcases); ++i) { 197 for (size_t i = 0; i < arraysize(testcases); ++i) {
204 const float available_width = gfx::GetStringWidthF( 198 const float available_width = gfx::GetStringWidthF(
205 base::UTF8ToUTF16(testcases[i].output), gfx::FontList()); 199 base::UTF8ToUTF16(testcases[i].output), gfx::FontList());
206 EXPECT_EQ(base::UTF8ToUTF16(testcases[i].output), 200 EXPECT_EQ(base::UTF8ToUTF16(testcases[i].output),
207 url_formatter::ElideHost(GURL(testcases[i].input), 201 url_formatter::ElideHost(GURL(testcases[i].input),
208 gfx::FontList(), available_width)); 202 gfx::FontList(), available_width));
209 } 203 }
210 204
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 EXPECT_EQ(base::string16(), formatted_omit_scheme) 497 EXPECT_EQ(base::string16(), formatted_omit_scheme)
504 << "Explicitly test the url::Origin which takes an empty, invalid URL"; 498 << "Explicitly test the url::Origin which takes an empty, invalid URL";
505 499
506 formatted_omit_scheme = url_formatter::FormatOriginForSecurityDisplay( 500 formatted_omit_scheme = url_formatter::FormatOriginForSecurityDisplay(
507 url::Origin(GURL()), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); 501 url::Origin(GURL()), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
508 EXPECT_EQ(base::string16(), formatted_omit_scheme) 502 EXPECT_EQ(base::string16(), formatted_omit_scheme)
509 << "Explicitly test the url::Origin which takes an empty, invalid URL"; 503 << "Explicitly test the url::Origin which takes an empty, invalid URL";
510 } 504 }
511 505
512 } // namespace 506 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698