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