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 c12a08d370276361672cab960438c41b8d8aed07..189f75872a6a6b5829701abe95e640925413faab 100644 |
| --- a/ui/views/controls/styled_label_unittest.cc |
| +++ b/ui/views/controls/styled_label_unittest.cc |
| @@ -89,6 +89,19 @@ TEST_F(StyledLabelTest, RespectLeadingWhitespace) { |
| static_cast<Label*>(styled()->child_at(0))->text()); |
| } |
| +TEST_F(StyledLabelTest, RespectLeadingSpacesInNonFirstLine) { |
| + const std::string indented_line = " indented with space line"; |
| + const std::string text(std::string("First line\n") + indented_line); |
| + InitStyledLabel(text); |
| + styled()->SetBounds(0, 0, 1000, 1000); |
| + styled()->Layout(); |
| + ASSERT_EQ(2, styled()->child_count()); |
| + ASSERT_EQ(std::string(Label::kViewClassName), |
| + styled()->child_at(0)->GetClassName()); |
| + EXPECT_EQ(ASCIIToUTF16(indented_line), |
|
Evan Stade
2016/12/05 17:12:14
can you test what would happen if we naturally wra
|
| + static_cast<Label*>(styled()->child_at(1))->text()); |
| +} |
| + |
| TEST_F(StyledLabelTest, FirstLineNotEmptyWhenLeadingWhitespaceTooLong) { |
| const std::string text(" a"); |
| InitStyledLabel(text); |
| @@ -128,6 +141,20 @@ TEST_F(StyledLabelTest, BasicWrapping) { |
| EXPECT_EQ(styled()->height() - 3, styled()->child_at(1)->bounds().bottom()); |
| } |
| +TEST_F(StyledLabelTest, AllowEmptyLines) { |
| + const std::string text("one"); |
| + InitStyledLabel(text); |
| + int default_height = styled()->GetHeightForWidth(1000); |
| + const std::string multiline_text("one\n\nthree"); |
| + InitStyledLabel(multiline_text); |
| + styled()->SetBounds(0, 0, 1000, 1000); |
| + styled()->Layout(); |
| + EXPECT_EQ(3 * default_height, styled()->GetHeightForWidth(1000)); |
| + ASSERT_EQ(2, styled()->child_count()); |
| + EXPECT_EQ(styled()->GetHeightForWidth(1000), |
| + styled()->child_at(1)->bounds().bottom()); |
| +} |
| + |
| TEST_F(StyledLabelTest, WrapLongWords) { |
| const std::string text("ThisIsTextAsASingleWord"); |
| InitStyledLabel(text); |