Chromium Code Reviews| 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/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 | 577 |
| 578 button()->OnMouseDragged(ui::MouseEvent( | 578 button()->OnMouseDragged(ui::MouseEvent( |
| 579 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 579 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 580 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 580 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 581 | 581 |
| 582 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_delegate->GetTargetInkDropState()); | 582 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_delegate->GetTargetInkDropState()); |
| 583 | 583 |
| 584 SetDraggedView(nullptr); | 584 SetDraggedView(nullptr); |
| 585 } | 585 } |
| 586 | 586 |
| 587 // Todo(karandeepb): On Mac, button should get clicked on a Space key press (and | |
|
tapted
2016/06/07 04:59:35
nit: button -> a button
karandeepb
2016/06/07 08:39:29
Done.
| |
| 588 // not release). Modify this test after fixing crbug.com/607429. | |
| 589 // Test that Space Key behaves correctly on a focused button. | |
| 590 TEST_F(CustomButtonTest, ClickOnSpace) { | |
| 591 button()->RequestFocus(); | |
| 592 EXPECT_EQ(button(), widget()->GetFocusManager()->GetFocusedView()); | |
| 593 | |
| 594 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); | |
| 595 generator.PressKey(ui::VKEY_SPACE, ui::EF_NONE); | |
| 596 EXPECT_EQ(CustomButton::STATE_PRESSED, button()->state()); | |
| 597 EXPECT_FALSE(button()->pressed()); | |
| 598 | |
| 599 generator.ReleaseKey(ui::VKEY_SPACE, ui::EF_NONE); | |
| 600 EXPECT_EQ(CustomButton::STATE_NORMAL, button()->state()); | |
| 601 EXPECT_TRUE(button()->pressed()); | |
| 602 } | |
| 603 | |
| 587 } // namespace views | 604 } // namespace views |
| OLD | NEW |