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

Unified Diff: ui/views/controls/label_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_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label_unittest.cc
diff --git a/ui/views/controls/label_unittest.cc b/ui/views/controls/label_unittest.cc
index bc778913a7e899400055571ee8d6e8b859e50567..13e70344f7f5bb2363d357f142b0e13f013d3b9e 100644
--- a/ui/views/controls/label_unittest.cc
+++ b/ui/views/controls/label_unittest.cc
@@ -184,6 +184,24 @@ TEST(LabelTest, SingleLineSizing) {
required_size.width() + border.width());
}
+TEST(LabelTest, MultilineSmallAvailableWidthSizing) {
+ Label label;
+ string16 test_text(ASCIIToUTF16("Too Wide."));
+
+ label.SetMultiLine(true);
+ label.SetAllowCharacterBreak(true);
+ label.SetElideBehavior(Label::ELIDE_AT_END);
+ label.SetText(test_text);
+
+ // Check that Label can be laid out at a variety of small sizes,
+ // splitting the words into up to one character per line if necessary.
+ // Incorrect word splitting may cause infinite loops in text layout.
+ gfx::Size required_size = label.GetPreferredSize();
+ for (int i = 1; i < required_size.width(); ++i) {
+ EXPECT_GT(label.GetHeightForWidth(i), 0);
+ }
+}
+
TEST(LabelTest, MultiLineSizing) {
Label label;
label.set_focusable(false);
« no previous file with comments | « ui/base/text/text_elider_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698