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