| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "views/border.h" | 10 #include "views/border.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 label.SetText(test_text); | 201 label.SetText(test_text); |
| 202 label.SetMultiLine(true); | 202 label.SetMultiLine(true); |
| 203 | 203 |
| 204 // GetPreferredSize | 204 // GetPreferredSize |
| 205 gfx::Size required_size = label.GetPreferredSize(); | 205 gfx::Size required_size = label.GetPreferredSize(); |
| 206 EXPECT_GT(required_size.height(), kMinTextDimension); | 206 EXPECT_GT(required_size.height(), kMinTextDimension); |
| 207 EXPECT_GT(required_size.width(), kMinTextDimension); | 207 EXPECT_GT(required_size.width(), kMinTextDimension); |
| 208 | 208 |
| 209 // SizeToFit with unlimited width. | 209 // SizeToFit with unlimited width. |
| 210 label.SizeToFit(0); | 210 label.SizeToFit(0); |
| 211 int required_width = label.GetContentsBounds().width(); | 211 int required_width = label.GetLocalBounds().width(); |
| 212 EXPECT_GT(required_width, kMinTextDimension); | 212 EXPECT_GT(required_width, kMinTextDimension); |
| 213 | 213 |
| 214 // SizeToFit with limited width. | 214 // SizeToFit with limited width. |
| 215 label.SizeToFit(required_width - 1); | 215 label.SizeToFit(required_width - 1); |
| 216 int constrained_width = label.GetContentsBounds().width(); | 216 int constrained_width = label.GetLocalBounds().width(); |
| 217 #if defined(OS_WIN) | 217 #if defined(OS_WIN) |
| 218 // Canvas::SizeStringInt (in app/gfx/canvas_linux.cc) | 218 // Canvas::SizeStringInt (in app/gfx/canvas_linux.cc) |
| 219 // has to be fixed to return the size that fits to given width/height. | 219 // has to be fixed to return the size that fits to given width/height. |
| 220 EXPECT_LT(constrained_width, required_width); | 220 EXPECT_LT(constrained_width, required_width); |
| 221 #endif | 221 #endif |
| 222 EXPECT_GT(constrained_width, kMinTextDimension); | 222 EXPECT_GT(constrained_width, kMinTextDimension); |
| 223 | 223 |
| 224 // Change the width back to the desire width. | 224 // Change the width back to the desire width. |
| 225 label.SizeToFit(required_width); | 225 label.SizeToFit(required_width); |
| 226 EXPECT_EQ(required_width, label.GetContentsBounds().width()); | 226 EXPECT_EQ(required_width, label.GetLocalBounds().width()); |
| 227 | 227 |
| 228 // General tests for GetHeightForWidth. | 228 // General tests for GetHeightForWidth. |
| 229 int required_height = label.GetHeightForWidth(required_width); | 229 int required_height = label.GetHeightForWidth(required_width); |
| 230 EXPECT_GT(required_height, kMinTextDimension); | 230 EXPECT_GT(required_height, kMinTextDimension); |
| 231 int height_for_constrained_width = label.GetHeightForWidth(constrained_width); | 231 int height_for_constrained_width = label.GetHeightForWidth(constrained_width); |
| 232 #if defined(OS_WIN) | 232 #if defined(OS_WIN) |
| 233 // Canvas::SizeStringInt (in app/gfx/canvas_linux.cc) | 233 // Canvas::SizeStringInt (in app/gfx/canvas_linux.cc) |
| 234 // has to be fixed to return the size that fits to given width/height. | 234 // has to be fixed to return the size that fits to given width/height. |
| 235 EXPECT_GT(height_for_constrained_width, required_height); | 235 EXPECT_GT(height_for_constrained_width, required_height); |
| 236 #endif | 236 #endif |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 gfx::Canvas::TEXT_ALIGN_LEFT | | 807 gfx::Canvas::TEXT_ALIGN_LEFT | |
| 808 gfx::Canvas::NO_ELLIPSIS, | 808 gfx::Canvas::NO_ELLIPSIS, |
| 809 flags); | 809 flags); |
| 810 #endif | 810 #endif |
| 811 | 811 |
| 812 // Reset Locale | 812 // Reset Locale |
| 813 base::i18n::SetICUDefaultLocale(locale); | 813 base::i18n::SetICUDefaultLocale(locale); |
| 814 } | 814 } |
| 815 | 815 |
| 816 } // namespace views | 816 } // namespace views |
| OLD | NEW |