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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 LabelButton* button_ = nullptr; | 448 LabelButton* button_ = nullptr; |
449 | 449 |
450 // Weak ptr, |button_| owns the instance. | 450 // Weak ptr, |button_| owns the instance. |
451 test::TestInkDrop* test_ink_drop_ = nullptr; | 451 test::TestInkDrop* test_ink_drop_ = nullptr; |
452 | 452 |
453 private: | 453 private: |
454 DISALLOW_COPY_AND_ASSIGN(InkDropLabelButtonTest); | 454 DISALLOW_COPY_AND_ASSIGN(InkDropLabelButtonTest); |
455 }; | 455 }; |
456 | 456 |
457 TEST_F(InkDropLabelButtonTest, HoverStateAfterMouseEnterAndExitEvents) { | 457 TEST_F(InkDropLabelButtonTest, HoverStateAfterMouseEnterAndExitEvents) { |
458 ui::test::EventGenerator event_generator(GetContext(), | 458 ui::test::EventGenerator event_generator(widget_->GetNativeWindow()); |
459 widget_->GetNativeWindow()); | |
460 const gfx::Point out_of_bounds_point(button_->bounds().bottom_right() + | 459 const gfx::Point out_of_bounds_point(button_->bounds().bottom_right() + |
461 gfx::Vector2d(1, 1)); | 460 gfx::Vector2d(1, 1)); |
462 const gfx::Point in_bounds_point(button_->bounds().CenterPoint()); | 461 const gfx::Point in_bounds_point(button_->bounds().CenterPoint()); |
463 | 462 |
464 event_generator.MoveMouseTo(out_of_bounds_point); | 463 event_generator.MoveMouseTo(out_of_bounds_point); |
465 EXPECT_FALSE(test_ink_drop_->is_hovered()); | 464 EXPECT_FALSE(test_ink_drop_->is_hovered()); |
466 | 465 |
467 event_generator.MoveMouseTo(in_bounds_point); | 466 event_generator.MoveMouseTo(in_bounds_point); |
468 EXPECT_TRUE(test_ink_drop_->is_hovered()); | 467 EXPECT_TRUE(test_ink_drop_->is_hovered()); |
469 | 468 |
470 event_generator.MoveMouseTo(out_of_bounds_point); | 469 event_generator.MoveMouseTo(out_of_bounds_point); |
471 EXPECT_FALSE(test_ink_drop_->is_hovered()); | 470 EXPECT_FALSE(test_ink_drop_->is_hovered()); |
472 } | 471 } |
473 | 472 |
474 // Verifies the target event handler View is the |LabelButton| and not any of | 473 // Verifies the target event handler View is the |LabelButton| and not any of |
475 // the child Views. | 474 // the child Views. |
476 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { | 475 TEST_F(InkDropLabelButtonTest, TargetEventHandler) { |
477 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( | 476 View* target_view = widget_->GetRootView()->GetEventHandlerForPoint( |
478 button_->bounds().CenterPoint()); | 477 button_->bounds().CenterPoint()); |
479 EXPECT_EQ(button_, target_view); | 478 EXPECT_EQ(button_, target_view); |
480 } | 479 } |
481 | 480 |
482 } // namespace views | 481 } // namespace views |
OLD | NEW |