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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 gfx::Size label_preferred_size = label.GetPreferredSize(); | 185 gfx::Size label_preferred_size = label.GetPreferredSize(); |
186 EXPECT_EQ(label_preferred_size.height() * 2, | 186 EXPECT_EQ(label_preferred_size.height() * 2, |
187 StyledLabelContentHeightForWidth(label_preferred_size.width())); | 187 StyledLabelContentHeightForWidth(label_preferred_size.width())); |
188 | 188 |
189 styled()->SetBounds( | 189 styled()->SetBounds( |
190 0, 0, styled()->GetInsets().width() + label_preferred_size.width(), | 190 0, 0, styled()->GetInsets().width() + label_preferred_size.width(), |
191 styled()->GetInsets().height() + 2 * label_preferred_size.height()); | 191 styled()->GetInsets().height() + 2 * label_preferred_size.height()); |
192 styled()->Layout(); | 192 styled()->Layout(); |
193 | 193 |
194 ASSERT_EQ(2, styled()->child_count()); | 194 ASSERT_EQ(2, styled()->child_count()); |
195 ASSERT_EQ(gfx::Point(), styled()->bounds().origin()); | 195 ASSERT_EQ(gfx::Point(), styled()->origin()); |
196 EXPECT_EQ(gfx::Point(), styled()->child_at(0)->bounds().origin()); | 196 EXPECT_EQ(gfx::Point(), styled()->child_at(0)->origin()); |
197 EXPECT_EQ(gfx::Point(0, styled()->height() / 2), | 197 EXPECT_EQ(gfx::Point(0, styled()->height() / 2), |
198 styled()->child_at(1)->bounds().origin()); | 198 styled()->child_at(1)->origin()); |
199 | 199 |
200 EXPECT_FALSE(static_cast<Label*>(styled()->child_at(0))->text().empty()); | 200 EXPECT_FALSE(static_cast<Label*>(styled()->child_at(0))->text().empty()); |
201 EXPECT_FALSE(static_cast<Label*>(styled()->child_at(1))->text().empty()); | 201 EXPECT_FALSE(static_cast<Label*>(styled()->child_at(1))->text().empty()); |
202 EXPECT_EQ(ASCIIToUTF16(text), | 202 EXPECT_EQ(ASCIIToUTF16(text), |
203 static_cast<Label*>(styled()->child_at(0))->text() + | 203 static_cast<Label*>(styled()->child_at(0))->text() + |
204 static_cast<Label*>(styled()->child_at(1))->text()); | 204 static_cast<Label*>(styled()->child_at(1))->text()); |
205 } | 205 } |
206 | 206 |
207 TEST_F(StyledLabelTest, CreateLinks) { | 207 TEST_F(StyledLabelTest, CreateLinks) { |
208 const std::string text("This is a test block of text."); | 208 const std::string text("This is a test block of text."); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } // namespace views | 565 } // namespace views |
OLD | NEW |