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

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

Issue 2054273002: Font fallback for UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 | content/browser/renderer_host/dwrite_font_proxy_message_filter_win.cc » ('j') | 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/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 #include "url/origin.h" 16 #include "url/origin.h"
16 17
17 #if !defined(OS_ANDROID) 18 #if !defined(OS_ANDROID)
18 #include "ui/gfx/font_list.h" // nogncheck 19 #include "ui/gfx/font_list.h" // nogncheck
19 #include "ui/gfx/text_elider.h" // nogncheck 20 #include "ui/gfx/text_elider.h" // nogncheck
20 #include "ui/gfx/text_utils.h" // nogncheck 21 #include "ui/gfx/text_utils.h" // nogncheck
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // More space available - elide directories, partially elide filename. 102 // More space available - elide directories, partially elide filename.
102 Testcase testcases[] = { 103 Testcase testcases[] = {
103 {"http://battersbox.com/directory/foo/peter_paul_and_mary.html", 104 {"http://battersbox.com/directory/foo/peter_paul_and_mary.html",
104 "battersbox.com/" + kEllipsisStr + "/peter" + kEllipsisStr}, 105 "battersbox.com/" + kEllipsisStr + "/peter" + kEllipsisStr},
105 }; 106 };
106 RunUrlTest(testcases, arraysize(testcases)); 107 RunUrlTest(testcases, arraysize(testcases));
107 } 108 }
108 109
109 // Test eliding of empty strings, URLs with ports, passwords, queries, etc. 110 // Test eliding of empty strings, URLs with ports, passwords, queries, etc.
110 TEST(TextEliderTest, TestMoreEliding) { 111 TEST(TextEliderTest, TestMoreEliding) {
112 #if defined(OS_WIN)
113 // Needed to bypass DCHECK in GetFallbackFont.
114 base::MessageLoopForUI message_loop;
115 #endif
111 const std::string kEllipsisStr(gfx::kEllipsis); 116 const std::string kEllipsisStr(gfx::kEllipsis);
112 Testcase testcases[] = { 117 Testcase testcases[] = {
113 {"http://www.google.com/foo?bar", "www.google.com/foo?bar"}, 118 {"http://www.google.com/foo?bar", "www.google.com/foo?bar"},
114 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo?" + kEllipsisStr}, 119 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo?" + kEllipsisStr},
115 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo" + kEllipsisStr}, 120 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo" + kEllipsisStr},
116 {"http://xyz.google.com/foo?bar", "xyz.google.com/fo" + kEllipsisStr}, 121 {"http://xyz.google.com/foo?bar", "xyz.google.com/fo" + kEllipsisStr},
117 {"http://a.b.com/pathname/c?d", "a.b.com/" + kEllipsisStr + "/c?d"}, 122 {"http://a.b.com/pathname/c?d", "a.b.com/" + kEllipsisStr + "/c?d"},
118 {"", ""}, 123 {"", ""},
119 {"http://foo.bar..example.com...hello/test/filename.html", 124 {"http://foo.bar..example.com...hello/test/filename.html",
120 "foo.bar..example.com...hello/" + kEllipsisStr + "/filename.html"}, 125 "foo.bar..example.com...hello/" + kEllipsisStr + "/filename.html"},
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 EXPECT_EQ(base::string16(), formatted_omit_scheme) 517 EXPECT_EQ(base::string16(), formatted_omit_scheme)
513 << "Explicitly test the url::Origin which takes an empty, invalid URL"; 518 << "Explicitly test the url::Origin which takes an empty, invalid URL";
514 519
515 formatted_omit_scheme = url_formatter::FormatOriginForSecurityDisplay( 520 formatted_omit_scheme = url_formatter::FormatOriginForSecurityDisplay(
516 url::Origin(GURL()), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC); 521 url::Origin(GURL()), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
517 EXPECT_EQ(base::string16(), formatted_omit_scheme) 522 EXPECT_EQ(base::string16(), formatted_omit_scheme)
518 << "Explicitly test the url::Origin which takes an empty, invalid URL"; 523 << "Explicitly test the url::Origin which takes an empty, invalid URL";
519 } 524 }
520 525
521 } // namespace 526 } // namespace
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/dwrite_font_proxy_message_filter_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698