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

Unified Diff: ui/base/text/text_elider_unittest.cc

Issue 13846005: Fix infinite loop caused by ElideText() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android failure Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/text/text_elider.cc ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/text/text_elider_unittest.cc
diff --git a/ui/base/text/text_elider_unittest.cc b/ui/base/text/text_elider_unittest.cc
index 222c821a72d71586cdb79e4f8e82ab47e591983e..7b45fd4c45359e2c50922efc261884b98193cd97 100644
--- a/ui/base/text/text_elider_unittest.cc
+++ b/ui/base/text/text_elider_unittest.cc
@@ -345,6 +345,31 @@ TEST(TextEliderTest, ElideTextTruncate) {
}
}
+TEST(TextEliderTest, ElideTextEllipsis) {
+ const gfx::Font font;
+ const int kTestWidth = font.GetStringWidth(ASCIIToUTF16("Test"));
+ const char* kEllipsis = "\xE2\x80\xA6";
+ const int kEllipsisWidth = font.GetStringWidth(UTF8ToUTF16(kEllipsis));
+ struct TestData {
+ const char* input;
+ int width;
+ const char* output;
+ } cases[] = {
+ { "", 0, "" },
+ { "Test", 0, "" },
+ { "Test", kEllipsisWidth, kEllipsis },
+ { "", kTestWidth, "" },
+ { "Tes", kTestWidth, "Tes" },
+ { "Test", kTestWidth, "Test" },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ string16 result = ElideText(UTF8ToUTF16(cases[i].input), font,
+ cases[i].width, ELIDE_AT_END);
+ EXPECT_EQ(cases[i].output, UTF16ToUTF8(result));
+ }
+}
+
// Checks that all occurrences of |first_char| are followed by |second_char| and
// all occurrences of |second_char| are preceded by |first_char| in |text|.
static void CheckSurrogatePairs(const string16& text,
« no previous file with comments | « ui/base/text/text_elider.cc ('k') | ui/views/controls/label_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698