Chromium Code Reviews| 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..ab485a31ab0c86b149c63f56af729c047e70e4ba 100644 |
| --- a/ui/views/controls/styled_label_unittest.cc |
| +++ b/ui/views/controls/styled_label_unittest.cc |
| @@ -124,6 +124,30 @@ TEST_F(StyledLabelTest, BasicWrapping) { |
| EXPECT_EQ(styled()->height() - 3, styled()->child_at(1)->bounds().bottom()); |
| } |
| +TEST_F(StyledLabelTest, WrapLongWords) { |
| + const std::string text("Thisistextasasingleword"); |
|
msw
2015/05/13 23:05:39
nit: camel case words :)
tbarzic
2015/05/14 00:02:28
Done.
|
| + 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()->SetBorder(Border::CreateEmptyBorder(3, 3, 3, 3)); |
|
msw
2015/05/13 23:05:40
Is this 3px border necessary? Would no border simp
tbarzic
2015/05/14 00:02:28
wouldn't really simplify it, but it's not essentia
|
| + 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()); |
| + EXPECT_EQ(3, styled()->child_at(0)->x()); |
|
msw
2015/05/13 23:05:40
nit: check if the origin is equal to gfx::Point()
tbarzic
2015/05/14 00:02:28
Done.
|
| + EXPECT_EQ(3, styled()->child_at(0)->y()); |
| + EXPECT_EQ(styled()->height() - 3, styled()->child_at(1)->bounds().bottom()); |
| + 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); |