| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/base/layout.h" | 10 #include "ui/base/layout.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 436 |
| 437 Textfield textfield; | 437 Textfield textfield; |
| 438 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); | 438 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); |
| 439 } | 439 } |
| 440 | 440 |
| 441 // Tests that pressing a button shows the ink drop and releasing the button | 441 // Tests that pressing a button shows the ink drop and releasing the button |
| 442 // does not hide the ink drop. | 442 // does not hide the ink drop. |
| 443 // Note: Ink drop is not hidden upon release because CustomButton descendants | 443 // Note: Ink drop is not hidden upon release because CustomButton descendants |
| 444 // may enter a different ink drop state. | 444 // may enter a different ink drop state. |
| 445 TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) { | 445 TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) { |
| 446 gfx::Point old_cursor = gfx::Screen::GetScreenFor( | 446 gfx::Point old_cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
| 447 widget()->GetNativeView())->GetCursorScreenPoint(); | |
| 448 CreateButtonWithInkDrop(); | 447 CreateButtonWithInkDrop(); |
| 449 | 448 |
| 450 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); | 449 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); |
| 451 generator.set_current_location(gfx::Point(50, 50)); | 450 generator.set_current_location(gfx::Point(50, 50)); |
| 452 generator.PressLeftButton(); | 451 generator.PressLeftButton(); |
| 453 EXPECT_TRUE(ink_shown()); | 452 EXPECT_TRUE(ink_shown()); |
| 454 EXPECT_FALSE(ink_hidden()); | 453 EXPECT_FALSE(ink_hidden()); |
| 455 | 454 |
| 456 generator.ReleaseLeftButton(); | 455 generator.ReleaseLeftButton(); |
| 457 EXPECT_FALSE(ink_hidden()); | 456 EXPECT_FALSE(ink_hidden()); |
| 458 } | 457 } |
| 459 | 458 |
| 460 // Tests that pressing a button shows and releasing capture hides ink drop. | 459 // Tests that pressing a button shows and releasing capture hides ink drop. |
| 461 TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) { | 460 TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) { |
| 462 gfx::Point old_cursor = gfx::Screen::GetScreenFor( | 461 gfx::Point old_cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
| 463 widget()->GetNativeView())->GetCursorScreenPoint(); | |
| 464 CreateButtonWithInkDrop(); | 462 CreateButtonWithInkDrop(); |
| 465 | 463 |
| 466 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); | 464 ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow()); |
| 467 generator.set_current_location(gfx::Point(50, 50)); | 465 generator.set_current_location(gfx::Point(50, 50)); |
| 468 generator.PressLeftButton(); | 466 generator.PressLeftButton(); |
| 469 EXPECT_TRUE(ink_shown()); | 467 EXPECT_TRUE(ink_shown()); |
| 470 EXPECT_FALSE(ink_hidden()); | 468 EXPECT_FALSE(ink_hidden()); |
| 471 | 469 |
| 472 widget()->SetCapture(button()); | 470 widget()->SetCapture(button()); |
| 473 widget()->ReleaseCapture(); | 471 widget()->ReleaseCapture(); |
| 474 EXPECT_TRUE(ink_hidden()); | 472 EXPECT_TRUE(ink_hidden()); |
| 475 } | 473 } |
| 476 | 474 |
| 477 } // namespace views | 475 } // namespace views |
| OLD | NEW |