| 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/macros.h" | 8 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 11 #include "ui/accessibility/ax_view_state.h" |
| 11 #include "ui/base/material_design/material_design_controller.h" | 12 #include "ui/base/material_design/material_design_controller.h" |
| 12 #include "ui/base/test/material_design_controller_test_api.h" | 13 #include "ui/base/test/material_design_controller_test_api.h" |
| 14 #include "ui/base/ui_base_switches.h" |
| 13 #include "ui/events/test/event_generator.h" | 15 #include "ui/events/test/event_generator.h" |
| 14 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/font_list.h" | 17 #include "ui/gfx/font_list.h" |
| 16 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/geometry/vector2d.h" | 19 #include "ui/gfx/geometry/vector2d.h" |
| 18 #include "ui/gfx/text_utils.h" | 20 #include "ui/gfx/text_utils.h" |
| 19 #include "ui/views/animation/button_ink_drop_delegate.h" | 21 #include "ui/views/animation/button_ink_drop_delegate.h" |
| 20 #include "ui/views/test/views_test_base.h" | 22 #include "ui/views/test/views_test_base.h" |
| 21 #include "ui/views/test/widget_test.h" | 23 #include "ui/views/test/widget_test.h" |
| 22 | 24 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 DISALLOW_COPY_AND_ASSIGN(InkDropLabelButton); | 353 DISALLOW_COPY_AND_ASSIGN(InkDropLabelButton); |
| 352 }; | 354 }; |
| 353 | 355 |
| 354 // Test fixture for a LabelButton that has an ink drop configured. | 356 // Test fixture for a LabelButton that has an ink drop configured. |
| 355 class InkDropLabelButtonTest : public ViewsTestBase { | 357 class InkDropLabelButtonTest : public ViewsTestBase { |
| 356 public: | 358 public: |
| 357 InkDropLabelButtonTest() {} | 359 InkDropLabelButtonTest() {} |
| 358 | 360 |
| 359 // ViewsTestBase: | 361 // ViewsTestBase: |
| 360 void SetUp() override { | 362 void SetUp() override { |
| 361 ui::test::MaterialDesignControllerTestAPI::SetMode( | 363 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 362 ui::MaterialDesignController::MATERIAL_NORMAL); | 364 switches::kTopChromeMD, switches::kTopChromeMDMaterial); |
| 363 | |
| 364 ViewsTestBase::SetUp(); | 365 ViewsTestBase::SetUp(); |
| 365 | 366 |
| 366 // Create a widget so that the CustomButton can query the hover state | 367 // Create a widget so that the CustomButton can query the hover state |
| 367 // correctly. | 368 // correctly. |
| 368 widget_.reset(new Widget); | 369 widget_.reset(new Widget); |
| 369 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 370 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 370 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 371 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 371 params.bounds = gfx::Rect(0, 0, 20, 20); | 372 params.bounds = gfx::Rect(0, 0, 20, 20); |
| 372 widget_->Init(params); | 373 widget_->Init(params); |
| 373 widget_->Show(); | 374 widget_->Show(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 413 |
| 413 // Verifies the target event handler View is the |LabelButton| and not any of | 414 // Verifies the target event handler View is the |LabelButton| and not any of |
| 414 // the child Views. | 415 // the child Views. |
| 415 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { | 416 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { |
| 416 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( | 417 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( |
| 417 button_->bounds().CenterPoint()); | 418 button_->bounds().CenterPoint()); |
| 418 EXPECT_EQ(button_, target_view); | 419 EXPECT_EQ(button_, target_view); |
| 419 } | 420 } |
| 420 | 421 |
| 421 } // namespace views | 422 } // namespace views |
| OLD | NEW |