| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/styled_label.h" | 5 #include "ui/views/controls/styled_label.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // layout should be recalculated | 555 // layout should be recalculated |
| 556 // all controls should be recreated | 556 // all controls should be recreated |
| 557 styled()->SetText(another_text); | 557 styled()->SetText(another_text); |
| 558 int updated_height = styled()->GetHeightForWidth(styled()->width()); | 558 int updated_height = styled()->GetHeightForWidth(styled()->width()); |
| 559 EXPECT_NE(updated_height, real_height); | 559 EXPECT_NE(updated_height, real_height); |
| 560 View* first_child_after_text_update = styled()->has_children() ? | 560 View* first_child_after_text_update = styled()->has_children() ? |
| 561 styled()->child_at(0) : nullptr; | 561 styled()->child_at(0) : nullptr; |
| 562 EXPECT_NE(first_child_after_text_update, first_child_after_layout); | 562 EXPECT_NE(first_child_after_text_update, first_child_after_layout); |
| 563 } | 563 } |
| 564 | 564 |
| 565 TEST_F(StyledLabelTest, Border) { |
| 566 const std::string text("One line"); |
| 567 InitStyledLabel(text); |
| 568 Label label(ASCIIToUTF16(text)); |
| 569 gfx::Size label_preferred_size = label.GetPreferredSize(); |
| 570 styled()->SetBorder( |
| 571 CreateEmptyBorder(5 /*top*/, 10 /*left*/, 6 /*bottom*/, 20 /*right*/)); |
| 572 styled()->SetBounds(0, 0, 1000, 0); |
| 573 styled()->Layout(); |
| 574 EXPECT_EQ( |
| 575 label_preferred_size.height() + 5 /*top border*/ + 6 /*bottom border*/, |
| 576 styled()->GetPreferredSize().height()); |
| 577 EXPECT_EQ( |
| 578 label_preferred_size.width() + 10 /*left border*/ + 20 /*right border*/, |
| 579 styled()->GetPreferredSize().width()); |
| 580 } |
| 581 |
| 565 } // namespace views | 582 } // namespace views |
| OLD | NEW |