Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/views/controls/label_unittest.cc

Issue 92004: Fix focus rects for checkboxes and radio buttons:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/views/controls/label.cc ('k') | chrome/views/view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/string_util.h" 5 #include "base/string_util.h"
6 #include "chrome/common/gfx/chrome_canvas.h" 6 #include "chrome/common/gfx/chrome_canvas.h"
7 #include "chrome/common/l10n_util.h" 7 #include "chrome/common/l10n_util.h"
8 #include "chrome/views/border.h" 8 #include "chrome/views/border.h"
9 #include "chrome/views/controls/label.h" 9 #include "chrome/views/controls/label.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 label.SetBounds(0, 0, 0, 0); 186 label.SetBounds(0, 0, 0, 0);
187 gfx::Size required_size_with_border = label.GetPreferredSize(); 187 gfx::Size required_size_with_border = label.GetPreferredSize();
188 EXPECT_EQ(required_size_with_border.height(), 188 EXPECT_EQ(required_size_with_border.height(),
189 required_size.height() + border.height()); 189 required_size.height() + border.height());
190 EXPECT_EQ(required_size_with_border.width(), 190 EXPECT_EQ(required_size_with_border.width(),
191 required_size.width() + border.width()); 191 required_size.width() + border.width());
192 } 192 }
193 193
194 TEST(LabelTest, MultiLineSizing) { 194 TEST(LabelTest, MultiLineSizing) {
195 Label label; 195 Label label;
196 label.SetFocusable(false);
196 std::wstring test_text(L"A random string\nwith multiple lines\nand returns!"); 197 std::wstring test_text(L"A random string\nwith multiple lines\nand returns!");
197 label.SetText(test_text); 198 label.SetText(test_text);
198 label.SetMultiLine(true); 199 label.SetMultiLine(true);
199 200
200 // GetPreferredSize 201 // GetPreferredSize
201 gfx::Size required_size = label.GetPreferredSize(); 202 gfx::Size required_size = label.GetPreferredSize();
202 EXPECT_GT(required_size.height(), kMinTextDimension); 203 EXPECT_GT(required_size.height(), kMinTextDimension);
203 EXPECT_GT(required_size.width(), kMinTextDimension); 204 EXPECT_GT(required_size.width(), kMinTextDimension);
204 205
205 // SizeToFit with unlimited width. 206 // SizeToFit with unlimited width.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 label.SetBounds(0, 0, 0, 0); 257 label.SetBounds(0, 0, 0, 0);
257 gfx::Size required_size_with_border = label.GetPreferredSize(); 258 gfx::Size required_size_with_border = label.GetPreferredSize();
258 EXPECT_EQ(required_size_with_border.height(), 259 EXPECT_EQ(required_size_with_border.height(),
259 required_size.height() + border.height()); 260 required_size.height() + border.height());
260 EXPECT_EQ(required_size_with_border.width(), 261 EXPECT_EQ(required_size_with_border.width(),
261 required_size.width() + border.width()); 262 required_size.width() + border.width());
262 } 263 }
263 264
264 TEST(LabelTest, DrawSingleLineString) { 265 TEST(LabelTest, DrawSingleLineString) {
265 Label label; 266 Label label;
267 label.SetFocusable(false);
266 268
267 // Turn off mirroring so that we don't need to figure out if 269 // Turn off mirroring so that we don't need to figure out if
268 // align right really means align left. 270 // align right really means align left.
269 label.EnableUIMirroringForRTLLanguages(false); 271 label.EnableUIMirroringForRTLLanguages(false);
270 272
271 std::wstring test_text(L"Here's a string with no returns."); 273 std::wstring test_text(L"Here's a string with no returns.");
272 label.SetText(test_text); 274 label.SetText(test_text);
273 gfx::Size required_size(label.GetPreferredSize()); 275 gfx::Size required_size(label.GetPreferredSize());
274 gfx::Size extra(22, 8); 276 gfx::Size extra(22, 8);
275 label.SetBounds(0, 277 label.SetBounds(0,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // The text should be right aligned horizontally and centered vertically. 372 // The text should be right aligned horizontally and centered vertically.
371 EXPECT_EQ(border.left() + extra.width(), text_bounds.x()); 373 EXPECT_EQ(border.left() + extra.width(), text_bounds.x());
372 EXPECT_EQ(border.top() + extra.height() / 2 , text_bounds.y()); 374 EXPECT_EQ(border.top() + extra.height() / 2 , text_bounds.y());
373 EXPECT_EQ(required_size.width(), text_bounds.width()); 375 EXPECT_EQ(required_size.width(), text_bounds.width());
374 EXPECT_EQ(required_size.height(), text_bounds.height()); 376 EXPECT_EQ(required_size.height(), text_bounds.height());
375 EXPECT_EQ(0, flags); 377 EXPECT_EQ(0, flags);
376 } 378 }
377 379
378 TEST(LabelTest, DrawMultiLineString) { 380 TEST(LabelTest, DrawMultiLineString) {
379 Label label; 381 Label label;
382 label.SetFocusable(false);
380 383
381 // Turn off mirroring so that we don't need to figure out if 384 // Turn off mirroring so that we don't need to figure out if
382 // align right really means align left. 385 // align right really means align left.
383 label.EnableUIMirroringForRTLLanguages(false); 386 label.EnableUIMirroringForRTLLanguages(false);
384 387
385 std::wstring test_text(L"Another string\nwith returns\n\n!"); 388 std::wstring test_text(L"Another string\nwith returns\n\n!");
386 label.SetText(test_text); 389 label.SetText(test_text);
387 label.SetMultiLine(true); 390 label.SetMultiLine(true);
388 label.SizeToFit(0); 391 label.SizeToFit(0);
389 392
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags); 438 label.CalculateDrawStringParams(&paint_text, &text_bounds, &flags);
436 EXPECT_STREQ(test_text.c_str(), paint_text.c_str()); 439 EXPECT_STREQ(test_text.c_str(), paint_text.c_str());
437 EXPECT_EQ(center_bounds.x() + border.left(), text_bounds.x()); 440 EXPECT_EQ(center_bounds.x() + border.left(), text_bounds.x());
438 EXPECT_EQ(center_bounds.y() + border.top(), text_bounds.y()); 441 EXPECT_EQ(center_bounds.y() + border.top(), text_bounds.y());
439 EXPECT_EQ(center_bounds.width(), text_bounds.width()); 442 EXPECT_EQ(center_bounds.width(), text_bounds.width());
440 EXPECT_EQ(center_bounds.height(), text_bounds.height()); 443 EXPECT_EQ(center_bounds.height(), text_bounds.height());
441 EXPECT_EQ(ChromeCanvas::MULTI_LINE | ChromeCanvas::TEXT_ALIGN_CENTER, flags); 444 EXPECT_EQ(ChromeCanvas::MULTI_LINE | ChromeCanvas::TEXT_ALIGN_CENTER, flags);
442 } 445 }
443 446
444 } // namespace views 447 } // namespace views
OLDNEW
« no previous file with comments | « chrome/views/controls/label.cc ('k') | chrome/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698