| 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 "ui/views/controls/button/label_button.h" | 5 #include "ui/views/controls/button/label_button.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 EXPECT_EQ(original_width, button_->GetPreferredSize().width()); | 340 EXPECT_EQ(original_width, button_->GetPreferredSize().width()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 // Ensure the label gets the correct style for default buttons (e.g. bolding) | 343 // Ensure the label gets the correct style for default buttons (e.g. bolding) |
| 344 // and button size updates correctly. Regression test for crbug.com/578722. | 344 // and button size updates correctly. Regression test for crbug.com/578722. |
| 345 TEST_F(LabelButtonTest, ButtonStyleIsDefaultStyle) { | 345 TEST_F(LabelButtonTest, ButtonStyleIsDefaultStyle) { |
| 346 TestLabelButton* button = AddStyledButton("Save", false); | 346 TestLabelButton* button = AddStyledButton("Save", false); |
| 347 gfx::Size non_default_size = button->label()->size(); | 347 gfx::Size non_default_size = button->label()->size(); |
| 348 EXPECT_EQ(button->label()->GetPreferredSize().width(), | 348 EXPECT_EQ(button->label()->GetPreferredSize().width(), |
| 349 non_default_size.width()); | 349 non_default_size.width()); |
| 350 EXPECT_FALSE(button->label()->font_list().GetFontStyle() & gfx::Font::BOLD); | 350 EXPECT_EQ(button->label()->font_list().GetFontWeight(), |
| 351 gfx::Font::Weight::NORMAL); |
| 351 EXPECT_EQ(styled_normal_text_color_, button->label()->enabled_color()); | 352 EXPECT_EQ(styled_normal_text_color_, button->label()->enabled_color()); |
| 352 button->SetIsDefault(true); | 353 button->SetIsDefault(true); |
| 353 button->SizeToPreferredSize(); | 354 button->SizeToPreferredSize(); |
| 354 button->Layout(); | 355 button->Layout(); |
| 355 EXPECT_EQ(styled_highlight_text_color_, button->label()->enabled_color()); | 356 EXPECT_EQ(styled_highlight_text_color_, button->label()->enabled_color()); |
| 356 if (PlatformStyle::kDefaultLabelButtonHasBoldFont) { | 357 if (PlatformStyle::kDefaultLabelButtonHasBoldFont) { |
| 357 EXPECT_NE(non_default_size, button->label()->size()); | 358 EXPECT_NE(non_default_size, button->label()->size()); |
| 358 EXPECT_TRUE(button->label()->font_list().GetFontStyle() & gfx::Font::BOLD); | 359 EXPECT_EQ(button->label()->font_list().GetFontWeight(), |
| 360 gfx::Font::Weight::BOLD); |
| 359 } else { | 361 } else { |
| 360 EXPECT_EQ(non_default_size, button->label()->size()); | 362 EXPECT_EQ(non_default_size, button->label()->size()); |
| 361 EXPECT_FALSE(button->label()->font_list().GetFontStyle() & gfx::Font::BOLD); | 363 EXPECT_EQ(button->label()->font_list().GetFontWeight(), |
| 364 gfx::Font::Weight::NORMAL); |
| 362 } | 365 } |
| 363 } | 366 } |
| 364 | 367 |
| 365 // Ensure the label gets the correct style when pressed or becoming default. | 368 // Ensure the label gets the correct style when pressed or becoming default. |
| 366 TEST_F(LabelButtonTest, HighlightedButtonStyle) { | 369 TEST_F(LabelButtonTest, HighlightedButtonStyle) { |
| 367 #if defined(OS_MACOSX) | 370 #if defined(OS_MACOSX) |
| 368 // On Mac, ensure the normal and highlight colors are different, to ensure the | 371 // On Mac, ensure the normal and highlight colors are different, to ensure the |
| 369 // tests are actually testing something. This might be the case on other | 372 // tests are actually testing something. This might be the case on other |
| 370 // platforms. | 373 // platforms. |
| 371 EXPECT_NE(styled_normal_text_color_, styled_highlight_text_color_); | 374 EXPECT_NE(styled_normal_text_color_, styled_highlight_text_color_); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 509 |
| 507 // Verifies the target event handler View is the |LabelButton| and not any of | 510 // Verifies the target event handler View is the |LabelButton| and not any of |
| 508 // the child Views. | 511 // the child Views. |
| 509 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { | 512 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { |
| 510 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( | 513 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( |
| 511 button_->bounds().CenterPoint()); | 514 button_->bounds().CenterPoint()); |
| 512 EXPECT_EQ(button_, target_view); | 515 EXPECT_EQ(button_, target_view); |
| 513 } | 516 } |
| 514 | 517 |
| 515 } // namespace views | 518 } // namespace views |
| OLD | NEW |