summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authorgroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 01:09:01 +0000
committergroby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-02 01:09:01 +0000
commitea86e39583c4ac7c794ad07eac068fa17edd8061 (patch)
tree1d9fe2bcc6e6448354a65795cfb44ae1590d15dd /ui/base
parente50163387652ab5e8cc6002f86019d829d879327 (diff)
downloadchromium_src-ea86e39583c4ac7c794ad07eac068fa17edd8061.zip
chromium_src-ea86e39583c4ac7c794ad07eac068fa17edd8061.tar.gz
chromium_src-ea86e39583c4ac7c794ad07eac068fa17edd8061.tar.bz2
Fix unit tests to handle different font widths.
Addresses a broken ASAN test on CrOS. http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASAN%20Tests%20%283%29/builds/2888/steps/ui_unittests/logs/stdio It should shorten to battersbox.com/dir…, but due to different font widths on CrOS shortens to battersbox.com/di… This change takes font width into account for the expected string, too. BUG=none Review URL: https://chromiumcodereview.appspot.com/12386056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/text/text_elider_unittest.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/ui/base/text/text_elider_unittest.cc b/ui/base/text/text_elider_unittest.cc
index b95a8d6..222c821 100644
--- a/ui/base/text/text_elider_unittest.cc
+++ b/ui/base/text/text_elider_unittest.cc
@@ -180,7 +180,18 @@ TEST(TextEliderTest, TestTrailingEllipsisSlashEllipsisHack) {
GURL url("http://battersbox.com/directory/foo/peter_paul_and_mary.html");
int available_width = font.GetStringWidth(
UTF8ToUTF16("battersbox.com/" + kEllipsisStr + "/" + kEllipsisStr));
- EXPECT_EQ(UTF8ToUTF16("battersbox.com/dir" + kEllipsisStr),
+
+ // Create the expected string, after elision. Depending on font size, the
+ // directory might become /dir... or /di... or/d... - it never should be
+ // shorter than that. (If it is, the font considers d... to be longer
+ // than .../... - that should never happen).
+ ASSERT_GT(font.GetStringWidth(UTF8ToUTF16(kEllipsisStr + "/" + kEllipsisStr)),
+ font.GetStringWidth(UTF8ToUTF16("d" + kEllipsisStr)));
+ GURL long_url("http://battersbox.com/directorynameisreallylongtoforcetrunc");
+ string16 expected = ElideUrl(long_url, font, available_width, std::string());
+ // Ensure that the expected result still contains part of the directory name.
+ ASSERT_GT(expected.length(), std::string("battersbox.com/d").length());
+ EXPECT_EQ(expected,
ElideUrl(url, font, available_width, std::string()));
// More space available - elide directories, partially elide filename.