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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 void ShowContextMenuForView(View* source, | 50 void ShowContextMenuForView(View* source, |
| 51 const gfx::Point& point, | 51 const gfx::Point& point, |
| 52 ui::MenuSourceType source_type) override {} | 52 ui::MenuSourceType source_type) override {} |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(TestContextMenuController); | 55 DISALLOW_COPY_AND_ASSIGN(TestContextMenuController); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class TestCustomButton : public CustomButton, public ButtonListener { | 58 class TestCustomButton : public CustomButton, public ButtonListener { |
| 59 public: | 59 public: |
| 60 explicit TestCustomButton() | 60 explicit TestCustomButton(bool has_ink_drop_action_on_click) |
| 61 : CustomButton(this) { | 61 : CustomButton(this) { |
| 62 set_has_ink_drop_action_on_click(has_ink_drop_action_on_click); | |
| 62 } | 63 } |
| 63 | 64 |
| 64 ~TestCustomButton() override {} | 65 ~TestCustomButton() override {} |
| 65 | 66 |
| 66 void ButtonPressed(Button* sender, const ui::Event& event) override { | 67 void ButtonPressed(Button* sender, const ui::Event& event) override { |
| 67 pressed_ = true; | 68 pressed_ = true; |
| 68 } | 69 } |
| 69 | 70 |
| 70 void OnClickCanceled(const ui::Event& event) override { | 71 void OnClickCanceled(const ui::Event& event) override { |
| 71 canceled_ = true; | 72 canceled_ = true; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 101 | 102 |
| 102 // Create a widget so that the CustomButton can query the hover state | 103 // Create a widget so that the CustomButton can query the hover state |
| 103 // correctly. | 104 // correctly. |
| 104 widget_.reset(new Widget); | 105 widget_.reset(new Widget); |
| 105 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 106 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 106 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 107 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 107 params.bounds = gfx::Rect(0, 0, 650, 650); | 108 params.bounds = gfx::Rect(0, 0, 650, 650); |
| 108 widget_->Init(params); | 109 widget_->Init(params); |
| 109 widget_->Show(); | 110 widget_->Show(); |
| 110 | 111 |
| 111 button_ = new TestCustomButton(); | 112 button_ = new TestCustomButton(false); |
| 112 widget_->SetContentsView(button_); | 113 widget_->SetContentsView(button_); |
| 113 } | 114 } |
| 114 | 115 |
| 115 void TearDown() override { | 116 void TearDown() override { |
| 116 widget_.reset(); | 117 widget_.reset(); |
| 117 ViewsTestBase::TearDown(); | 118 ViewsTestBase::TearDown(); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void CreateButtonWithInkDrop(std::unique_ptr<InkDrop> ink_drop) { | 121 void CreateButtonWithInkDrop(std::unique_ptr<InkDrop> ink_drop, |
| 122 bool has_ink_drop_action_on_click) { | |
| 121 delete button_; | 123 delete button_; |
| 122 button_ = new TestCustomButton(); | 124 button_ = new TestCustomButton(has_ink_drop_action_on_click); |
| 123 InkDropHostViewTestApi(button_).SetInkDrop(std::move(ink_drop)); | 125 InkDropHostViewTestApi(button_).SetInkDrop(std::move(ink_drop)); |
| 124 widget_->SetContentsView(button_); | 126 widget_->SetContentsView(button_); |
| 125 } | 127 } |
| 126 | 128 |
| 127 protected: | 129 protected: |
| 128 Widget* widget() { return widget_.get(); } | 130 Widget* widget() { return widget_.get(); } |
| 129 TestCustomButton* button() { return button_; } | 131 TestCustomButton* button() { return button_; } |
| 130 void SetDraggedView(View* dragged_view) { | 132 void SetDraggedView(View* dragged_view) { |
| 131 widget_->dragged_view_ = dragged_view; | 133 widget_->dragged_view_ = dragged_view; |
| 132 } | 134 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 Textfield textfield; | 343 Textfield textfield; |
| 342 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); | 344 EXPECT_FALSE(CustomButton::AsCustomButton(&textfield)); |
| 343 } | 345 } |
| 344 | 346 |
| 345 // Tests that pressing a button shows the ink drop and releasing the button | 347 // Tests that pressing a button shows the ink drop and releasing the button |
| 346 // does not hide the ink drop. | 348 // does not hide the ink drop. |
| 347 // Note: Ink drop is not hidden upon release because CustomButton descendants | 349 // Note: Ink drop is not hidden upon release because CustomButton descendants |
| 348 // may enter a different ink drop state. | 350 // may enter a different ink drop state. |
| 349 TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) { | 351 TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) { |
| 350 TestInkDrop* ink_drop = new TestInkDrop(); | 352 TestInkDrop* ink_drop = new TestInkDrop(); |
| 351 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 353 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 352 | 354 |
| 353 ui::test::EventGenerator generator(widget()->GetNativeWindow()); | 355 ui::test::EventGenerator generator(widget()->GetNativeWindow()); |
| 354 generator.set_current_location(gfx::Point(50, 50)); | 356 generator.set_current_location(gfx::Point(50, 50)); |
| 355 generator.PressLeftButton(); | 357 generator.PressLeftButton(); |
| 356 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 358 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 357 | 359 |
| 358 generator.ReleaseLeftButton(); | 360 generator.ReleaseLeftButton(); |
| 359 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 361 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 360 } | 362 } |
| 361 | 363 |
| 362 // Tests that pressing a button shows and releasing capture hides ink drop. | 364 // Tests that pressing a button shows and releasing capture hides ink drop. |
| 363 // Releasing capture should also reset PRESSED button state to NORMAL. | 365 // Releasing capture should also reset PRESSED button state to NORMAL. |
| 364 TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) { | 366 TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) { |
| 365 TestInkDrop* ink_drop = new TestInkDrop(); | 367 TestInkDrop* ink_drop = new TestInkDrop(); |
| 366 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 368 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 367 | 369 |
| 368 ui::test::EventGenerator generator(widget()->GetNativeWindow()); | 370 ui::test::EventGenerator generator(widget()->GetNativeWindow()); |
| 369 generator.set_current_location(gfx::Point(50, 50)); | 371 generator.set_current_location(gfx::Point(50, 50)); |
| 370 generator.PressLeftButton(); | 372 generator.PressLeftButton(); |
| 371 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 373 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 372 | 374 |
| 373 EXPECT_EQ(Button::ButtonState::STATE_PRESSED, button()->state()); | 375 EXPECT_EQ(Button::ButtonState::STATE_PRESSED, button()->state()); |
| 374 SetDraggedView(button()); | 376 SetDraggedView(button()); |
| 375 widget()->SetCapture(button()); | 377 widget()->SetCapture(button()); |
| 376 widget()->ReleaseCapture(); | 378 widget()->ReleaseCapture(); |
| 377 SetDraggedView(nullptr); | 379 SetDraggedView(nullptr); |
| 378 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); | 380 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); |
| 379 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial() | 381 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial() |
| 380 ? Button::ButtonState::STATE_NORMAL | 382 ? Button::ButtonState::STATE_NORMAL |
| 381 : Button::ButtonState::STATE_PRESSED, | 383 : Button::ButtonState::STATE_PRESSED, |
| 382 button()->state()); | 384 button()->state()); |
| 383 } | 385 } |
| 384 | 386 |
| 385 TEST_F(CustomButtonTest, HideInkDropWhenShowingContextMenu) { | 387 TEST_F(CustomButtonTest, HideInkDropWhenShowingContextMenu) { |
| 386 TestInkDrop* ink_drop = new TestInkDrop(); | 388 TestInkDrop* ink_drop = new TestInkDrop(); |
| 387 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 389 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 388 TestContextMenuController context_menu_controller; | 390 TestContextMenuController context_menu_controller; |
| 389 button()->set_context_menu_controller(&context_menu_controller); | 391 button()->set_context_menu_controller(&context_menu_controller); |
| 390 button()->set_hide_ink_drop_when_showing_context_menu(true); | 392 button()->set_hide_ink_drop_when_showing_context_menu(true); |
| 391 | 393 |
| 392 ink_drop->SetHovered(true); | 394 ink_drop->SetHovered(true); |
| 393 ink_drop->AnimateToState(InkDropState::ACTION_PENDING); | 395 ink_drop->AnimateToState(InkDropState::ACTION_PENDING); |
| 394 | 396 |
| 395 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); | 397 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); |
| 396 | 398 |
| 397 EXPECT_FALSE(ink_drop->is_hovered()); | 399 EXPECT_FALSE(ink_drop->is_hovered()); |
| 398 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); | 400 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); |
| 399 } | 401 } |
| 400 | 402 |
| 401 TEST_F(CustomButtonTest, DontHideInkDropWhenShowingContextMenu) { | 403 TEST_F(CustomButtonTest, DontHideInkDropWhenShowingContextMenu) { |
| 402 TestInkDrop* ink_drop = new TestInkDrop(); | 404 TestInkDrop* ink_drop = new TestInkDrop(); |
| 403 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 405 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 404 TestContextMenuController context_menu_controller; | 406 TestContextMenuController context_menu_controller; |
| 405 button()->set_context_menu_controller(&context_menu_controller); | 407 button()->set_context_menu_controller(&context_menu_controller); |
| 406 button()->set_hide_ink_drop_when_showing_context_menu(false); | 408 button()->set_hide_ink_drop_when_showing_context_menu(false); |
| 407 | 409 |
| 408 ink_drop->SetHovered(true); | 410 ink_drop->SetHovered(true); |
| 409 ink_drop->AnimateToState(InkDropState::ACTION_PENDING); | 411 ink_drop->AnimateToState(InkDropState::ACTION_PENDING); |
| 410 | 412 |
| 411 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); | 413 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); |
| 412 | 414 |
| 413 EXPECT_TRUE(ink_drop->is_hovered()); | 415 EXPECT_TRUE(ink_drop->is_hovered()); |
| 414 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 416 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 415 } | 417 } |
| 416 | 418 |
| 417 TEST_F(CustomButtonTest, HideInkDropOnBlur) { | 419 TEST_F(CustomButtonTest, HideInkDropOnBlur) { |
| 418 gfx::Point center(10, 10); | 420 gfx::Point center(10, 10); |
| 419 | 421 |
| 420 TestInkDrop* ink_drop = new TestInkDrop(); | 422 TestInkDrop* ink_drop = new TestInkDrop(); |
| 421 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 423 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 422 | 424 |
| 423 button()->OnFocus(); | 425 button()->OnFocus(); |
| 424 | 426 |
| 425 button()->OnMousePressed(ui::MouseEvent( | 427 button()->OnMousePressed(ui::MouseEvent( |
| 426 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 428 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 427 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 429 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 428 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 430 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 429 | 431 |
| 430 button()->OnBlur(); | 432 button()->OnBlur(); |
| 431 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); | 433 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); |
| 432 | 434 |
| 433 button()->OnMouseReleased(ui::MouseEvent( | 435 button()->OnMouseReleased(ui::MouseEvent( |
| 434 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 436 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 435 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 437 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 436 EXPECT_TRUE(button()->pressed()); | 438 EXPECT_TRUE(button()->pressed()); |
| 437 } | 439 } |
| 438 | 440 |
| 439 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) { | 441 TEST_F(CustomButtonTest, InkDropAfterTryingToShowContextMenu) { |
| 440 TestInkDrop* ink_drop = new TestInkDrop(); | 442 TestInkDrop* ink_drop = new TestInkDrop(); |
| 441 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 443 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 442 button()->set_context_menu_controller(nullptr); | 444 button()->set_context_menu_controller(nullptr); |
| 443 | 445 |
| 444 ink_drop->SetHovered(true); | 446 ink_drop->SetHovered(true); |
| 445 ink_drop->AnimateToState(InkDropState::ACTION_PENDING); | 447 ink_drop->AnimateToState(InkDropState::ACTION_PENDING); |
| 446 | 448 |
| 447 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); | 449 button()->ShowContextMenu(gfx::Point(), ui::MENU_SOURCE_MOUSE); |
| 448 | 450 |
| 449 EXPECT_TRUE(ink_drop->is_hovered()); | 451 EXPECT_TRUE(ink_drop->is_hovered()); |
| 450 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 452 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 451 } | 453 } |
| 452 | 454 |
| 453 TEST_F(CustomButtonTest, InkDropShowHideOnMouseDragged) { | 455 TEST_F(CustomButtonTest, InkDropShowHideOnMouseDragged) { |
|
bruthig
2016/06/22 19:07:29
nit: Can you add the suffix 'NotifyOnRelease'.
mohsen
2016/06/23 15:49:56
Done.
| |
| 454 gfx::Point center(10, 10); | 456 gfx::Point center(10, 10); |
| 455 gfx::Point oob(-1, -1); | 457 gfx::Point oob(-1, -1); |
| 456 | 458 |
| 457 TestInkDrop* ink_drop = new TestInkDrop(); | 459 TestInkDrop* ink_drop = new TestInkDrop(); |
| 458 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 460 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 459 | 461 |
|
bruthig
2016/06/22 19:07:29
nit: Can you add 'button()->set_notify_action(Cust
mohsen
2016/06/23 15:49:56
Done.
| |
| 460 button()->OnMousePressed(ui::MouseEvent( | 462 button()->OnMousePressed(ui::MouseEvent( |
| 461 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 463 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 462 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 464 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 463 | 465 |
| 464 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 466 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 465 | 467 |
| 466 button()->OnMouseDragged( | 468 button()->OnMouseDragged( |
| 467 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), | 469 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), |
| 468 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 470 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 469 | 471 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 481 | 483 |
| 482 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); | 484 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); |
| 483 | 485 |
| 484 button()->OnMouseReleased( | 486 button()->OnMouseReleased( |
| 485 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), | 487 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), |
| 486 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 488 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 487 | 489 |
| 488 EXPECT_FALSE(button()->pressed()); | 490 EXPECT_FALSE(button()->pressed()); |
| 489 } | 491 } |
| 490 | 492 |
| 493 // Tests that when button is set to notify on press, dragging mouse out and back | |
| 494 // does not change the ink drop state. | |
| 495 TEST_F(CustomButtonTest, InkDropShowHideOnMouseDraggedNotifyOnPress) { | |
| 496 gfx::Point center(10, 10); | |
| 497 gfx::Point oob(-1, -1); | |
| 498 | |
| 499 TestInkDrop* ink_drop = new TestInkDrop(); | |
| 500 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), true); | |
| 501 button()->set_notify_action(CustomButton::NOTIFY_ON_PRESS); | |
| 502 | |
| 503 button()->OnMousePressed(ui::MouseEvent( | |
| 504 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | |
| 505 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | |
| 506 | |
| 507 EXPECT_EQ(InkDropState::ACTION_TRIGGERED, ink_drop->GetTargetInkDropState()); | |
| 508 EXPECT_TRUE(button()->pressed()); | |
| 509 | |
| 510 button()->OnMouseDragged( | |
| 511 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), | |
| 512 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | |
| 513 | |
| 514 EXPECT_EQ(InkDropState::ACTION_TRIGGERED, ink_drop->GetTargetInkDropState()); | |
| 515 | |
| 516 button()->OnMouseDragged(ui::MouseEvent( | |
| 517 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | |
| 518 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | |
| 519 | |
| 520 EXPECT_EQ(InkDropState::ACTION_TRIGGERED, ink_drop->GetTargetInkDropState()); | |
| 521 | |
| 522 button()->OnMouseDragged( | |
| 523 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), | |
| 524 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | |
| 525 | |
| 526 EXPECT_EQ(InkDropState::ACTION_TRIGGERED, ink_drop->GetTargetInkDropState()); | |
| 527 | |
| 528 button()->OnMouseReleased( | |
| 529 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), | |
| 530 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | |
| 531 | |
| 532 EXPECT_EQ(InkDropState::ACTION_TRIGGERED, ink_drop->GetTargetInkDropState()); | |
| 533 } | |
| 534 | |
| 491 TEST_F(CustomButtonTest, InkDropStaysHiddenWhileDragging) { | 535 TEST_F(CustomButtonTest, InkDropStaysHiddenWhileDragging) { |
| 492 gfx::Point center(10, 10); | 536 gfx::Point center(10, 10); |
| 493 gfx::Point oob(-1, -1); | 537 gfx::Point oob(-1, -1); |
| 494 | 538 |
| 495 TestInkDrop* ink_drop = new TestInkDrop(); | 539 TestInkDrop* ink_drop = new TestInkDrop(); |
| 496 CreateButtonWithInkDrop(base::WrapUnique(ink_drop)); | 540 CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false); |
| 497 | 541 |
| 498 button()->OnMousePressed(ui::MouseEvent( | 542 button()->OnMousePressed(ui::MouseEvent( |
| 499 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 543 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 500 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 544 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 501 | 545 |
| 502 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); | 546 EXPECT_EQ(InkDropState::ACTION_PENDING, ink_drop->GetTargetInkDropState()); |
| 503 | 547 |
| 504 SetDraggedView(button()); | 548 SetDraggedView(button()); |
| 505 widget()->SetCapture(button()); | 549 widget()->SetCapture(button()); |
| 506 widget()->ReleaseCapture(); | 550 widget()->ReleaseCapture(); |
| 507 | 551 |
| 508 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); | 552 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); |
| 509 | 553 |
| 510 button()->OnMouseDragged( | 554 button()->OnMouseDragged( |
| 511 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), | 555 ui::MouseEvent(ui::ET_MOUSE_PRESSED, oob, oob, ui::EventTimeForNow(), |
| 512 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 556 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 513 | 557 |
| 514 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); | 558 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); |
| 515 | 559 |
| 516 button()->OnMouseDragged(ui::MouseEvent( | 560 button()->OnMouseDragged(ui::MouseEvent( |
| 517 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 561 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 518 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 562 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 519 | 563 |
| 520 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); | 564 EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState()); |
| 521 | 565 |
| 522 SetDraggedView(nullptr); | 566 SetDraggedView(nullptr); |
| 523 } | 567 } |
| 524 | 568 |
| 525 } // namespace views | 569 } // namespace views |
| OLD | NEW |