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

Unified Diff: ui/views/controls/styled_label_unittest.cc

Issue 1140083002: Make StyledLabel wrap long words (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 5 years, 7 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/views/controls/styled_label.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/styled_label_unittest.cc
diff --git a/ui/views/controls/styled_label_unittest.cc b/ui/views/controls/styled_label_unittest.cc
index c7ccdb69f346ced8593d091559563cd7f73d85b7..411a8a2b1cd75f3cc5daa70d31aa2978738e54af 100644
--- a/ui/views/controls/styled_label_unittest.cc
+++ b/ui/views/controls/styled_label_unittest.cc
@@ -124,6 +124,32 @@ TEST_F(StyledLabelTest, BasicWrapping) {
EXPECT_EQ(styled()->height() - 3, styled()->child_at(1)->bounds().bottom());
}
+TEST_F(StyledLabelTest, WrapLongWords) {
+ const std::string text("ThisIsTextAsASingleWord");
+ InitStyledLabel(text);
+ Label label(ASCIIToUTF16(text.substr(0, text.size() * 2 / 3)));
+ gfx::Size label_preferred_size = label.GetPreferredSize();
+ EXPECT_EQ(label_preferred_size.height() * 2,
+ StyledLabelContentHeightForWidth(label_preferred_size.width()));
+
+ styled()->SetBounds(
+ 0, 0, styled()->GetInsets().width() + label_preferred_size.width(),
+ styled()->GetInsets().height() + 2 * label_preferred_size.height());
+ styled()->Layout();
+ ASSERT_EQ(2, styled()->child_count());
+ ASSERT_EQ(gfx::Point(), styled()->bounds().origin());
+ EXPECT_EQ(gfx::Point(), styled()->child_at(0)->bounds().origin());
+ EXPECT_EQ(gfx::Point(0, styled()->height() / 2),
+ styled()->child_at(1)->bounds().origin());
+ EXPECT_EQ(styled()->height() / 2, styled()->child_at(1)->height());
msw 2015/05/14 00:31:42 nit: maybe check the height for both children or d
tbarzic 2015/05/14 01:29:24 removed height check. I left origin check, just to
+
+ EXPECT_FALSE(static_cast<Label*>(styled()->child_at(0))->text().empty());
+ EXPECT_FALSE(static_cast<Label*>(styled()->child_at(1))->text().empty());
+ EXPECT_EQ(ASCIIToUTF16(text),
+ static_cast<Label*>(styled()->child_at(0))->text() +
+ static_cast<Label*>(styled()->child_at(1))->text());
+}
+
TEST_F(StyledLabelTest, CreateLinks) {
const std::string text("This is a test block of text.");
InitStyledLabel(text);
« no previous file with comments | « ui/views/controls/styled_label.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698