| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 TEST_F(StyledLabelTest, BasicWrapping) { | 103 TEST_F(StyledLabelTest, BasicWrapping) { |
| 104 const std::string text("This is a test block of text"); | 104 const std::string text("This is a test block of text"); |
| 105 InitStyledLabel(text); | 105 InitStyledLabel(text); |
| 106 Label label(ASCIIToUTF16(text.substr(0, text.size() * 2 / 3))); | 106 Label label(ASCIIToUTF16(text.substr(0, text.size() * 2 / 3))); |
| 107 gfx::Size label_preferred_size = label.GetPreferredSize(); | 107 gfx::Size label_preferred_size = label.GetPreferredSize(); |
| 108 EXPECT_EQ(label_preferred_size.height() * 2, | 108 EXPECT_EQ(label_preferred_size.height() * 2, |
| 109 StyledLabelContentHeightForWidth(label_preferred_size.width())); | 109 StyledLabelContentHeightForWidth(label_preferred_size.width())); |
| 110 | 110 |
| 111 // Also respect the border. | 111 // Also respect the border. |
| 112 styled()->set_border(Border::CreateEmptyBorder(3, 3, 3, 3)); | 112 styled()->SetBorder(Border::CreateEmptyBorder(3, 3, 3, 3)); |
| 113 styled()->SetBounds( | 113 styled()->SetBounds( |
| 114 0, | 114 0, |
| 115 0, | 115 0, |
| 116 styled()->GetInsets().width() + label_preferred_size.width(), | 116 styled()->GetInsets().width() + label_preferred_size.width(), |
| 117 styled()->GetInsets().height() + 2 * label_preferred_size.height()); | 117 styled()->GetInsets().height() + 2 * label_preferred_size.height()); |
| 118 styled()->Layout(); | 118 styled()->Layout(); |
| 119 ASSERT_EQ(2, styled()->child_count()); | 119 ASSERT_EQ(2, styled()->child_count()); |
| 120 EXPECT_EQ(3, styled()->child_at(0)->x()); | 120 EXPECT_EQ(3, styled()->child_at(0)->x()); |
| 121 EXPECT_EQ(3, styled()->child_at(0)->y()); | 121 EXPECT_EQ(3, styled()->child_at(0)->y()); |
| 122 EXPECT_EQ(styled()->height() - 3, styled()->child_at(1)->bounds().bottom()); | 122 EXPECT_EQ(styled()->height() - 3, styled()->child_at(1)->bounds().bottom()); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 383 } |
| 384 | 384 |
| 385 TEST_F(StyledLabelTest, HandleEmptyLayout) { | 385 TEST_F(StyledLabelTest, HandleEmptyLayout) { |
| 386 const std::string text("This is a test block of text."); | 386 const std::string text("This is a test block of text."); |
| 387 InitStyledLabel(text); | 387 InitStyledLabel(text); |
| 388 styled()->Layout(); | 388 styled()->Layout(); |
| 389 EXPECT_EQ(0, styled()->child_count()); | 389 EXPECT_EQ(0, styled()->child_count()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace | 392 } // namespace |
| OLD | NEW |