| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 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 "base/i18n/rtl.h" |    5 #include "base/i18n/rtl.h" | 
|    6 #include "base/utf_string_conversions.h" |    6 #include "base/utf_string_conversions.h" | 
|    7 #include "testing/gtest/include/gtest/gtest.h" |    7 #include "testing/gtest/include/gtest/gtest.h" | 
|    8 #include "ui/base/accessibility/accessible_view_state.h" |    8 #include "ui/base/accessibility/accessible_view_state.h" | 
|    9 #include "ui/base/l10n/l10n_util.h" |    9 #include "ui/base/l10n/l10n_util.h" | 
|   10 #include "ui/gfx/canvas.h" |   10 #include "ui/gfx/canvas.h" | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  177  |  177  | 
|  178   // GetPreferredSize and borders. |  178   // GetPreferredSize and borders. | 
|  179   label.SetBounds(0, 0, 0, 0); |  179   label.SetBounds(0, 0, 0, 0); | 
|  180   gfx::Size required_size_with_border = label.GetPreferredSize(); |  180   gfx::Size required_size_with_border = label.GetPreferredSize(); | 
|  181   EXPECT_EQ(required_size_with_border.height(), |  181   EXPECT_EQ(required_size_with_border.height(), | 
|  182             required_size.height() + border.height()); |  182             required_size.height() + border.height()); | 
|  183   EXPECT_EQ(required_size_with_border.width(), |  183   EXPECT_EQ(required_size_with_border.width(), | 
|  184             required_size.width() + border.width()); |  184             required_size.width() + border.width()); | 
|  185 } |  185 } | 
|  186  |  186  | 
 |  187 TEST(LabelTest, MultilineSmallAvailableWidthSizing) { | 
 |  188   Label label; | 
 |  189   string16 test_text(ASCIIToUTF16("Too Wide.")); | 
 |  190  | 
 |  191   label.SetMultiLine(true); | 
 |  192   label.SetAllowCharacterBreak(true); | 
 |  193   label.SetElideBehavior(Label::ELIDE_AT_END); | 
 |  194   label.SetText(test_text); | 
 |  195  | 
 |  196   // Check that Label can be laid out at a variety of small sizes, | 
 |  197   // splitting the words into up to one character per line if necessary. | 
 |  198   // Incorrect word splitting may cause infinite loops in text layout. | 
 |  199   gfx::Size required_size = label.GetPreferredSize(); | 
 |  200   for (int i = 1; i < required_size.width(); ++i) { | 
 |  201     EXPECT_GT(label.GetHeightForWidth(i), 0); | 
 |  202   } | 
 |  203 } | 
 |  204  | 
|  187 TEST(LabelTest, MultiLineSizing) { |  205 TEST(LabelTest, MultiLineSizing) { | 
|  188   Label label; |  206   Label label; | 
|  189   label.set_focusable(false); |  207   label.set_focusable(false); | 
|  190   string16 test_text( |  208   string16 test_text( | 
|  191       ASCIIToUTF16("A random string\nwith multiple lines\nand returns!")); |  209       ASCIIToUTF16("A random string\nwith multiple lines\nand returns!")); | 
|  192   label.SetText(test_text); |  210   label.SetText(test_text); | 
|  193   label.SetMultiLine(true); |  211   label.SetMultiLine(true); | 
|  194  |  212  | 
|  195   // GetPreferredSize |  213   // GetPreferredSize | 
|  196   gfx::Size required_size = label.GetPreferredSize(); |  214   gfx::Size required_size = label.GetPreferredSize(); | 
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  871   EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51))); |  889   EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(2, 51))); | 
|  872   EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20))); |  890   EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(-1, 20))); | 
|  873  |  891  | 
|  874   // GetTooltipHandlerForPoint works should work in child bounds. |  892   // GetTooltipHandlerForPoint works should work in child bounds. | 
|  875   label.SetBounds(2, 2, 10, 10); |  893   label.SetBounds(2, 2, 10, 10); | 
|  876   EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5))); |  894   EXPECT_EQ(&label, label.GetTooltipHandlerForPoint(gfx::Point(1, 5))); | 
|  877   EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11))); |  895   EXPECT_FALSE(label.GetTooltipHandlerForPoint(gfx::Point(3, 11))); | 
|  878 } |  896 } | 
|  879  |  897  | 
|  880 }  // namespace views |  898 }  // namespace views | 
| OLD | NEW |