diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 00:42:03 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 00:42:03 +0000 |
commit | a6ed3e143ed88f495e5c00a79ad9ea68f8253533 (patch) | |
tree | 3400ccbbfa9a26da9b4144d7f09c058dcd1dfc15 /app | |
parent | 3c31dc9ee55519e7e34016d4edd2f250640410b0 (diff) | |
download | chromium_src-a6ed3e143ed88f495e5c00a79ad9ea68f8253533.zip chromium_src-a6ed3e143ed88f495e5c00a79ad9ea68f8253533.tar.gz chromium_src-a6ed3e143ed88f495e5c00a79ad9ea68f8253533.tar.bz2 |
Re-enable TextEliderTest.ElideTextLongStrings.
Pango returns 0 for absurdly long strings. Cut the text in half and try again if this occurs.
BUG=15435
Review URL: http://codereview.chromium.org/414013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r-- | app/gfx/text_elider.cc | 8 | ||||
-rw-r--r-- | app/gfx/text_elider_unittest.cc | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/app/gfx/text_elider.cc b/app/gfx/text_elider.cc index dc9b199..3d94813 100644 --- a/app/gfx/text_elider.cc +++ b/app/gfx/text_elider.cc @@ -301,6 +301,14 @@ std::wstring ElideText(const std::wstring& text, return text; int current_text_pixel_width = font.GetStringWidth(text); + + // Pango will return 0 width for absurdly long strings. Cut the string in + // half and try again. + if (current_text_pixel_width <= 0 && !text.empty()) { + return ElideText(text.substr(0, text.length() / 2), font, + available_pixel_width); + } + if (current_text_pixel_width <= available_pixel_width) return text; diff --git a/app/gfx/text_elider_unittest.cc b/app/gfx/text_elider_unittest.cc index fb6e7523..385d92d 100644 --- a/app/gfx/text_elider_unittest.cc +++ b/app/gfx/text_elider_unittest.cc @@ -186,9 +186,7 @@ TEST(TextEliderTest, TestFilenameEliding) { } } -// This test is disabled. -// See bug 15435. -TEST(TextEliderTest, DISABLED_ElideTextLongStrings) { +TEST(TextEliderTest, ElideTextLongStrings) { const std::wstring kEllipsisStr(kEllipsis); std::wstring data_scheme(L"data:text/plain,"); |