| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/ws/event_dispatcher.h" | 5 #include "components/mus/ws/event_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 309 |
| 310 TEST_F(EventDispatcherTest, ProcessEvent) { | 310 TEST_F(EventDispatcherTest, ProcessEvent) { |
| 311 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 311 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 312 | 312 |
| 313 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 313 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 314 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 314 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 315 | 315 |
| 316 // Send event that is over child. | 316 // Send event that is over child. |
| 317 const ui::PointerEvent ui_event(ui::MouseEvent( | 317 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 318 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 318 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 319 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 319 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 320 event_dispatcher()->ProcessEvent(ui_event); | 320 event_dispatcher()->ProcessEvent(ui_event); |
| 321 | 321 |
| 322 std::unique_ptr<DispatchedEventDetails> details = | 322 std::unique_ptr<DispatchedEventDetails> details = |
| 323 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 323 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 324 ASSERT_TRUE(details); | 324 ASSERT_TRUE(details); |
| 325 ASSERT_EQ(child.get(), details->window); | 325 ASSERT_EQ(child.get(), details->window); |
| 326 | 326 |
| 327 ASSERT_TRUE(details->event); | 327 ASSERT_TRUE(details->event); |
| 328 ASSERT_TRUE(details->event->IsPointerEvent()); | 328 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 329 | 329 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 TEST_F(EventDispatcherTest, Capture) { | 476 TEST_F(EventDispatcherTest, Capture) { |
| 477 ServerWindow* root = root_window(); | 477 ServerWindow* root = root_window(); |
| 478 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 478 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 479 | 479 |
| 480 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 480 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 481 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 481 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 482 | 482 |
| 483 MouseEventTest tests[] = { | 483 MouseEventTest tests[] = { |
| 484 // Send a mouse down event over child. | 484 // Send a mouse down event over child. |
| 485 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 485 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), |
| 486 gfx::Point(20, 25), base::TimeDelta(), | 486 gfx::Point(20, 25), base::TimeTicks(), |
| 487 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 487 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 488 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, | 488 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, |
| 489 gfx::Point(), gfx::Point()}, | 489 gfx::Point(), gfx::Point()}, |
| 490 | 490 |
| 491 // Capture should be activated. Let's send a mouse move outside the bounds | 491 // Capture should be activated. Let's send a mouse move outside the bounds |
| 492 // of the child. | 492 // of the child. |
| 493 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 493 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), |
| 494 gfx::Point(50, 50), base::TimeDelta(), | 494 gfx::Point(50, 50), base::TimeTicks(), |
| 495 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 495 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 496 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 496 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 497 gfx::Point(), gfx::Point()}, | 497 gfx::Point(), gfx::Point()}, |
| 498 // Release the mouse and verify that the mouse up event goes to the child. | 498 // Release the mouse and verify that the mouse up event goes to the child. |
| 499 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), | 499 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), |
| 500 gfx::Point(50, 50), base::TimeDelta(), | 500 gfx::Point(50, 50), base::TimeTicks(), |
| 501 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 501 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 502 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 502 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 503 gfx::Point(), gfx::Point()}, | 503 gfx::Point(), gfx::Point()}, |
| 504 | 504 |
| 505 // A mouse move at (50, 50) should now go to the root window. As the | 505 // A mouse move at (50, 50) should now go to the root window. As the |
| 506 // move crosses between |child| and |root| |child| gets an exit, and | 506 // move crosses between |child| and |root| |child| gets an exit, and |
| 507 // |root| the move. | 507 // |root| the move. |
| 508 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 508 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), |
| 509 gfx::Point(50, 50), base::TimeDelta(), | 509 gfx::Point(50, 50), base::TimeTicks(), |
| 510 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 510 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 511 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), root, | 511 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), root, |
| 512 gfx::Point(50, 50), gfx::Point(50, 50)}, | 512 gfx::Point(50, 50), gfx::Point(50, 50)}, |
| 513 | 513 |
| 514 }; | 514 }; |
| 515 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 515 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 516 tests, arraysize(tests)); | 516 tests, arraysize(tests)); |
| 517 } | 517 } |
| 518 | 518 |
| 519 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { | 519 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { |
| 520 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 520 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 521 | 521 |
| 522 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 522 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 523 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 523 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 524 | 524 |
| 525 MouseEventTest tests[] = { | 525 MouseEventTest tests[] = { |
| 526 // Send a mouse down event over child with a left mouse button | 526 // Send a mouse down event over child with a left mouse button |
| 527 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 527 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), |
| 528 gfx::Point(20, 25), base::TimeDelta(), | 528 gfx::Point(20, 25), base::TimeTicks(), |
| 529 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 529 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 530 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, | 530 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, |
| 531 gfx::Point(), gfx::Point()}, | 531 gfx::Point(), gfx::Point()}, |
| 532 | 532 |
| 533 // Capture should be activated. Let's send a mouse move outside the bounds | 533 // Capture should be activated. Let's send a mouse move outside the bounds |
| 534 // of the child and press the right mouse button too. | 534 // of the child and press the right mouse button too. |
| 535 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 535 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), |
| 536 gfx::Point(50, 50), base::TimeDelta(), | 536 gfx::Point(50, 50), base::TimeTicks(), |
| 537 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), | 537 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), |
| 538 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 538 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 539 gfx::Point(), gfx::Point()}, | 539 gfx::Point(), gfx::Point()}, |
| 540 | 540 |
| 541 // Release the left mouse button and verify that the mouse up event goes | 541 // Release the left mouse button and verify that the mouse up event goes |
| 542 // to the child. | 542 // to the child. |
| 543 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), | 543 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), |
| 544 gfx::Point(50, 50), base::TimeDelta(), | 544 gfx::Point(50, 50), base::TimeTicks(), |
| 545 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 545 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 546 ui::EF_RIGHT_MOUSE_BUTTON), | 546 ui::EF_RIGHT_MOUSE_BUTTON), |
| 547 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 547 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 548 gfx::Point(), gfx::Point()}, | 548 gfx::Point(), gfx::Point()}, |
| 549 | 549 |
| 550 // A mouse move at (50, 50) should still go to the child. | 550 // A mouse move at (50, 50) should still go to the child. |
| 551 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 551 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), |
| 552 gfx::Point(50, 50), base::TimeDelta(), | 552 gfx::Point(50, 50), base::TimeTicks(), |
| 553 ui::EF_LEFT_MOUSE_BUTTON, 0), | 553 ui::EF_LEFT_MOUSE_BUTTON, 0), |
| 554 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, | 554 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, |
| 555 gfx::Point(), gfx::Point()}, | 555 gfx::Point(), gfx::Point()}, |
| 556 | 556 |
| 557 }; | 557 }; |
| 558 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 558 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 559 tests, arraysize(tests)); | 559 tests, arraysize(tests)); |
| 560 } | 560 } |
| 561 | 561 |
| 562 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { | 562 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| 563 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 563 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 564 | 564 |
| 565 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 565 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 566 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 566 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 567 | 567 |
| 568 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 568 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 569 | 569 |
| 570 TestEventDispatcherDelegate* event_dispatcher_delegate = | 570 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 571 test_event_dispatcher_delegate(); | 571 test_event_dispatcher_delegate(); |
| 572 EventDispatcher* dispatcher = event_dispatcher(); | 572 EventDispatcher* dispatcher = event_dispatcher(); |
| 573 | 573 |
| 574 // Start move loop by sending mouse event over non-client area. | 574 // Start move loop by sending mouse event over non-client area. |
| 575 const ui::PointerEvent press_event(ui::MouseEvent( | 575 const ui::PointerEvent press_event(ui::MouseEvent( |
| 576 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 576 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 577 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 577 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 578 dispatcher->ProcessEvent(press_event); | 578 dispatcher->ProcessEvent(press_event); |
| 579 | 579 |
| 580 // Events should target child and be in the non-client area. | 580 // Events should target child and be in the non-client area. |
| 581 std::unique_ptr<DispatchedEventDetails> details = | 581 std::unique_ptr<DispatchedEventDetails> details = |
| 582 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 582 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 583 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 583 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 584 ASSERT_TRUE(details); | 584 ASSERT_TRUE(details); |
| 585 ASSERT_EQ(child.get(), details->window); | 585 ASSERT_EQ(child.get(), details->window); |
| 586 EXPECT_TRUE(details->in_nonclient_area); | 586 EXPECT_TRUE(details->in_nonclient_area); |
| 587 | 587 |
| 588 // Move the mouse 5,6 pixels and target is the same. | 588 // Move the mouse 5,6 pixels and target is the same. |
| 589 const ui::PointerEvent move_event( | 589 const ui::PointerEvent move_event( |
| 590 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18), | 590 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18), |
| 591 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 591 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| 592 dispatcher->ProcessEvent(move_event); | 592 dispatcher->ProcessEvent(move_event); |
| 593 | 593 |
| 594 // Still same target. | 594 // Still same target. |
| 595 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 595 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 596 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 596 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 597 ASSERT_EQ(child.get(), details->window); | 597 ASSERT_EQ(child.get(), details->window); |
| 598 EXPECT_TRUE(details->in_nonclient_area); | 598 EXPECT_TRUE(details->in_nonclient_area); |
| 599 | 599 |
| 600 // Release the mouse. | 600 // Release the mouse. |
| 601 const ui::PointerEvent release_event(ui::MouseEvent( | 601 const ui::PointerEvent release_event(ui::MouseEvent( |
| 602 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18), | 602 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18), |
| 603 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 603 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 604 dispatcher->ProcessEvent(release_event); | 604 dispatcher->ProcessEvent(release_event); |
| 605 | 605 |
| 606 // The event should not have been dispatched to the delegate. | 606 // The event should not have been dispatched to the delegate. |
| 607 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 607 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 608 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 608 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 609 ASSERT_EQ(child.get(), details->window); | 609 ASSERT_EQ(child.get(), details->window); |
| 610 EXPECT_TRUE(details->in_nonclient_area); | 610 EXPECT_TRUE(details->in_nonclient_area); |
| 611 | 611 |
| 612 // Press in the client area and verify target/client area. The non-client area | 612 // Press in the client area and verify target/client area. The non-client area |
| 613 // should get an exit first. | 613 // should get an exit first. |
| 614 const ui::PointerEvent press_event2(ui::MouseEvent( | 614 const ui::PointerEvent press_event2(ui::MouseEvent( |
| 615 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22), | 615 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22), |
| 616 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 616 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 617 dispatcher->ProcessEvent(press_event2); | 617 dispatcher->ProcessEvent(press_event2); |
| 618 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 618 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 619 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); | 619 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); |
| 620 ASSERT_EQ(child.get(), details->window); | 620 ASSERT_EQ(child.get(), details->window); |
| 621 EXPECT_TRUE(details->in_nonclient_area); | 621 EXPECT_TRUE(details->in_nonclient_area); |
| 622 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); | 622 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| 623 | 623 |
| 624 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 624 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 625 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 625 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 626 ASSERT_EQ(child.get(), details->window); | 626 ASSERT_EQ(child.get(), details->window); |
| 627 EXPECT_FALSE(details->in_nonclient_area); | 627 EXPECT_FALSE(details->in_nonclient_area); |
| 628 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); | 628 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); |
| 629 } | 629 } |
| 630 | 630 |
| 631 TEST_F(EventDispatcherTest, AdditionalClientArea) { | 631 TEST_F(EventDispatcherTest, AdditionalClientArea) { |
| 632 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 632 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 633 | 633 |
| 634 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 634 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 635 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 635 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 636 | 636 |
| 637 std::vector<gfx::Rect> additional_client_areas; | 637 std::vector<gfx::Rect> additional_client_areas; |
| 638 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); | 638 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); |
| 639 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); | 639 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); |
| 640 | 640 |
| 641 TestEventDispatcherDelegate* event_dispatcher_delegate = | 641 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 642 test_event_dispatcher_delegate(); | 642 test_event_dispatcher_delegate(); |
| 643 // Press in the additional client area, it should go to the child. | 643 // Press in the additional client area, it should go to the child. |
| 644 const ui::PointerEvent press_event(ui::MouseEvent( | 644 const ui::PointerEvent press_event(ui::MouseEvent( |
| 645 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), | 645 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), |
| 646 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 646 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 647 event_dispatcher()->ProcessEvent(press_event); | 647 event_dispatcher()->ProcessEvent(press_event); |
| 648 | 648 |
| 649 // Events should target child and be in the client area. | 649 // Events should target child and be in the client area. |
| 650 std::unique_ptr<DispatchedEventDetails> details = | 650 std::unique_ptr<DispatchedEventDetails> details = |
| 651 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 651 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 652 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 652 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 653 ASSERT_EQ(child.get(), details->window); | 653 ASSERT_EQ(child.get(), details->window); |
| 654 EXPECT_FALSE(details->in_nonclient_area); | 654 EXPECT_FALSE(details->in_nonclient_area); |
| 655 } | 655 } |
| 656 | 656 |
| 657 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { | 657 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { |
| 658 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 658 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 659 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 659 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 660 | 660 |
| 661 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 661 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 662 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 662 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 663 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 663 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 664 | 664 |
| 665 TestEventDispatcherDelegate* event_dispatcher_delegate = | 665 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 666 test_event_dispatcher_delegate(); | 666 test_event_dispatcher_delegate(); |
| 667 EventDispatcher* dispatcher = event_dispatcher(); | 667 EventDispatcher* dispatcher = event_dispatcher(); |
| 668 | 668 |
| 669 // Press on child1. First press event should change focus. | 669 // Press on child1. First press event should change focus. |
| 670 const ui::PointerEvent press_event(ui::MouseEvent( | 670 const ui::PointerEvent press_event(ui::MouseEvent( |
| 671 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 671 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 672 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 672 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 673 dispatcher->ProcessEvent(press_event); | 673 dispatcher->ProcessEvent(press_event); |
| 674 std::unique_ptr<DispatchedEventDetails> details = | 674 std::unique_ptr<DispatchedEventDetails> details = |
| 675 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 675 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 676 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 676 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 677 EXPECT_EQ(child1.get(), details->window); | 677 EXPECT_EQ(child1.get(), details->window); |
| 678 EXPECT_EQ(child1.get(), | 678 EXPECT_EQ(child1.get(), |
| 679 event_dispatcher_delegate->GetAndClearLastFocusedWindow()); | 679 event_dispatcher_delegate->GetAndClearLastFocusedWindow()); |
| 680 | 680 |
| 681 // Press (with a different pointer id) on child2. Event should go to child2, | 681 // Press (with a different pointer id) on child2. Event should go to child2, |
| 682 // but focus should not change. | 682 // but focus should not change. |
| 683 const ui::PointerEvent touch_event(ui::TouchEvent( | 683 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 684 ui::ET_TOUCH_PRESSED, gfx::Point(53, 54), 2, base::TimeDelta())); | 684 ui::ET_TOUCH_PRESSED, gfx::Point(53, 54), 2, base::TimeTicks())); |
| 685 dispatcher->ProcessEvent(touch_event); | 685 dispatcher->ProcessEvent(touch_event); |
| 686 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 686 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 687 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 687 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 688 EXPECT_EQ(child2.get(), details->window); | 688 EXPECT_EQ(child2.get(), details->window); |
| 689 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); | 689 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); |
| 690 } | 690 } |
| 691 | 691 |
| 692 TEST_F(EventDispatcherTest, TwoPointersActive) { | 692 TEST_F(EventDispatcherTest, TwoPointersActive) { |
| 693 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 693 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 694 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 694 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 695 | 695 |
| 696 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 696 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 697 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 697 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 698 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 698 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 699 | 699 |
| 700 TestEventDispatcherDelegate* event_dispatcher_delegate = | 700 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 701 test_event_dispatcher_delegate(); | 701 test_event_dispatcher_delegate(); |
| 702 EventDispatcher* dispatcher = event_dispatcher(); | 702 EventDispatcher* dispatcher = event_dispatcher(); |
| 703 | 703 |
| 704 // Press on child1. | 704 // Press on child1. |
| 705 const ui::PointerEvent touch_event1(ui::TouchEvent( | 705 const ui::PointerEvent touch_event1(ui::TouchEvent( |
| 706 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); | 706 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); |
| 707 dispatcher->ProcessEvent(touch_event1); | 707 dispatcher->ProcessEvent(touch_event1); |
| 708 std::unique_ptr<DispatchedEventDetails> details = | 708 std::unique_ptr<DispatchedEventDetails> details = |
| 709 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 709 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 710 EXPECT_EQ(child1.get(), details->window); | 710 EXPECT_EQ(child1.get(), details->window); |
| 711 | 711 |
| 712 // Drag over child2, child1 should get the drag. | 712 // Drag over child2, child1 should get the drag. |
| 713 const ui::PointerEvent drag_event1(ui::TouchEvent( | 713 const ui::PointerEvent drag_event1(ui::TouchEvent( |
| 714 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeDelta())); | 714 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeTicks())); |
| 715 dispatcher->ProcessEvent(drag_event1); | 715 dispatcher->ProcessEvent(drag_event1); |
| 716 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 716 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 717 EXPECT_EQ(child1.get(), details->window); | 717 EXPECT_EQ(child1.get(), details->window); |
| 718 | 718 |
| 719 // Press on child2 with a different touch id. | 719 // Press on child2 with a different touch id. |
| 720 const ui::PointerEvent touch_event2(ui::TouchEvent( | 720 const ui::PointerEvent touch_event2(ui::TouchEvent( |
| 721 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeDelta())); | 721 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeTicks())); |
| 722 dispatcher->ProcessEvent(touch_event2); | 722 dispatcher->ProcessEvent(touch_event2); |
| 723 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 723 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 724 EXPECT_EQ(child2.get(), details->window); | 724 EXPECT_EQ(child2.get(), details->window); |
| 725 | 725 |
| 726 // Drag over child1 with id 2, child2 should continue to get the drag. | 726 // Drag over child1 with id 2, child2 should continue to get the drag. |
| 727 const ui::PointerEvent drag_event2(ui::TouchEvent( | 727 const ui::PointerEvent drag_event2(ui::TouchEvent( |
| 728 ui::ET_TOUCH_MOVED, gfx::Point(13, 14), 2, base::TimeDelta())); | 728 ui::ET_TOUCH_MOVED, gfx::Point(13, 14), 2, base::TimeTicks())); |
| 729 dispatcher->ProcessEvent(drag_event2); | 729 dispatcher->ProcessEvent(drag_event2); |
| 730 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 730 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 731 EXPECT_EQ(child2.get(), details->window); | 731 EXPECT_EQ(child2.get(), details->window); |
| 732 | 732 |
| 733 // Drag again with id 1, child1 should continue to get it. | 733 // Drag again with id 1, child1 should continue to get it. |
| 734 dispatcher->ProcessEvent(drag_event1); | 734 dispatcher->ProcessEvent(drag_event1); |
| 735 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 735 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 736 EXPECT_EQ(child1.get(), details->window); | 736 EXPECT_EQ(child1.get(), details->window); |
| 737 | 737 |
| 738 // Release touch id 1, and click on 2. 2 should get it. | 738 // Release touch id 1, and click on 2. 2 should get it. |
| 739 const ui::PointerEvent touch_release(ui::TouchEvent( | 739 const ui::PointerEvent touch_release(ui::TouchEvent( |
| 740 ui::ET_TOUCH_RELEASED, gfx::Point(54, 55), 1, base::TimeDelta())); | 740 ui::ET_TOUCH_RELEASED, gfx::Point(54, 55), 1, base::TimeTicks())); |
| 741 dispatcher->ProcessEvent(touch_release); | 741 dispatcher->ProcessEvent(touch_release); |
| 742 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 742 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 743 EXPECT_EQ(child1.get(), details->window); | 743 EXPECT_EQ(child1.get(), details->window); |
| 744 const ui::PointerEvent touch_event3(ui::TouchEvent( | 744 const ui::PointerEvent touch_event3(ui::TouchEvent( |
| 745 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeDelta())); | 745 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeTicks())); |
| 746 dispatcher->ProcessEvent(touch_event3); | 746 dispatcher->ProcessEvent(touch_event3); |
| 747 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 747 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 748 EXPECT_EQ(child2.get(), details->window); | 748 EXPECT_EQ(child2.get(), details->window); |
| 749 } | 749 } |
| 750 | 750 |
| 751 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { | 751 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { |
| 752 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 752 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 753 | 753 |
| 754 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 754 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 755 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 755 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 756 | 756 |
| 757 TestEventDispatcherDelegate* event_dispatcher_delegate = | 757 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 758 test_event_dispatcher_delegate(); | 758 test_event_dispatcher_delegate(); |
| 759 EventDispatcher* dispatcher = event_dispatcher(); | 759 EventDispatcher* dispatcher = event_dispatcher(); |
| 760 | 760 |
| 761 // Press on child. | 761 // Press on child. |
| 762 const ui::PointerEvent touch_event1(ui::TouchEvent( | 762 const ui::PointerEvent touch_event1(ui::TouchEvent( |
| 763 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); | 763 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); |
| 764 dispatcher->ProcessEvent(touch_event1); | 764 dispatcher->ProcessEvent(touch_event1); |
| 765 std::unique_ptr<DispatchedEventDetails> details = | 765 std::unique_ptr<DispatchedEventDetails> details = |
| 766 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 766 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 767 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 767 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 768 EXPECT_EQ(child.get(), details->window); | 768 EXPECT_EQ(child.get(), details->window); |
| 769 | 769 |
| 770 // Delete child, and continue the drag. Event should not be dispatched. | 770 // Delete child, and continue the drag. Event should not be dispatched. |
| 771 child.reset(); | 771 child.reset(); |
| 772 | 772 |
| 773 const ui::PointerEvent drag_event1(ui::TouchEvent( | 773 const ui::PointerEvent drag_event1(ui::TouchEvent( |
| 774 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeDelta())); | 774 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeTicks())); |
| 775 dispatcher->ProcessEvent(drag_event1); | 775 dispatcher->ProcessEvent(drag_event1); |
| 776 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 776 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 777 EXPECT_EQ(nullptr, details.get()); | 777 EXPECT_EQ(nullptr, details.get()); |
| 778 } | 778 } |
| 779 | 779 |
| 780 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { | 780 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| 781 ServerWindow* root = root_window(); | 781 ServerWindow* root = root_window(); |
| 782 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 782 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 783 | 783 |
| 784 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 784 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 785 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 785 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 786 | 786 |
| 787 TestEventDispatcherDelegate* event_dispatcher_delegate = | 787 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 788 test_event_dispatcher_delegate(); | 788 test_event_dispatcher_delegate(); |
| 789 EventDispatcher* dispatcher = event_dispatcher(); | 789 EventDispatcher* dispatcher = event_dispatcher(); |
| 790 | 790 |
| 791 // Send event that is not over child. | 791 // Send event that is not over child. |
| 792 const ui::PointerEvent ui_event(ui::MouseEvent( | 792 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 793 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), | 793 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), |
| 794 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 794 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 795 dispatcher->ProcessEvent(ui_event); | 795 dispatcher->ProcessEvent(ui_event); |
| 796 std::unique_ptr<DispatchedEventDetails> details = | 796 std::unique_ptr<DispatchedEventDetails> details = |
| 797 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 797 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 798 ASSERT_EQ(root, details->window); | 798 ASSERT_EQ(root, details->window); |
| 799 | 799 |
| 800 // Release the mouse. | 800 // Release the mouse. |
| 801 const ui::PointerEvent release_event(ui::MouseEvent( | 801 const ui::PointerEvent release_event(ui::MouseEvent( |
| 802 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9), | 802 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9), |
| 803 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 803 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 804 dispatcher->ProcessEvent(release_event); | 804 dispatcher->ProcessEvent(release_event); |
| 805 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 805 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 806 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 806 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 807 ASSERT_EQ(root, details->window); | 807 ASSERT_EQ(root, details->window); |
| 808 EXPECT_FALSE(details->in_nonclient_area); | 808 EXPECT_FALSE(details->in_nonclient_area); |
| 809 | 809 |
| 810 // Change the extended hit test region and send event in extended hit test | 810 // Change the extended hit test region and send event in extended hit test |
| 811 // region. Should result in exit for root, followed by press for child. | 811 // region. Should result in exit for root, followed by press for child. |
| 812 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); | 812 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); |
| 813 dispatcher->ProcessEvent(ui_event); | 813 dispatcher->ProcessEvent(ui_event); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 830 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 830 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 831 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 831 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 832 | 832 |
| 833 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 833 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 834 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 834 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 835 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 835 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 836 | 836 |
| 837 MouseEventTest tests[] = { | 837 MouseEventTest tests[] = { |
| 838 // Send a mouse down event over child1. | 838 // Send a mouse down event over child1. |
| 839 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), | 839 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), |
| 840 gfx::Point(15, 15), base::TimeDelta(), | 840 gfx::Point(15, 15), base::TimeTicks(), |
| 841 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 841 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 842 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr, | 842 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr, |
| 843 gfx::Point(), gfx::Point()}, | 843 gfx::Point(), gfx::Point()}, |
| 844 // Send mouse wheel over child2, should go to child1 as it has capture. | 844 // Send mouse wheel over child2, should go to child1 as it has capture. |
| 845 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54), | 845 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54), |
| 846 gfx::Point(53, 54), base::TimeDelta(), ui::EF_NONE, | 846 gfx::Point(53, 54), base::TimeTicks(), ui::EF_NONE, |
| 847 ui::EF_NONE), | 847 ui::EF_NONE), |
| 848 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr, | 848 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr, |
| 849 gfx::Point(), gfx::Point()}, | 849 gfx::Point(), gfx::Point()}, |
| 850 }; | 850 }; |
| 851 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 851 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 852 tests, arraysize(tests)); | 852 tests, arraysize(tests)); |
| 853 } | 853 } |
| 854 | 854 |
| 855 // Tests that when explicit capture has been set that all events go to the | 855 // Tests that when explicit capture has been set that all events go to the |
| 856 // designated window, and that when capture is cleared, events find the | 856 // designated window, and that when capture is cleared, events find the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 867 EventDispatcher* dispatcher = event_dispatcher(); | 867 EventDispatcher* dispatcher = event_dispatcher(); |
| 868 | 868 |
| 869 { | 869 { |
| 870 // Send all pointer events to the child. | 870 // Send all pointer events to the child. |
| 871 dispatcher->SetCaptureWindow(child.get(), false); | 871 dispatcher->SetCaptureWindow(child.get(), false); |
| 872 | 872 |
| 873 // The mouse press should go to the child even though its outside its | 873 // The mouse press should go to the child even though its outside its |
| 874 // bounds. | 874 // bounds. |
| 875 const ui::PointerEvent left_press_event(ui::MouseEvent( | 875 const ui::PointerEvent left_press_event(ui::MouseEvent( |
| 876 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 876 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 877 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 877 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 878 dispatcher->ProcessEvent(left_press_event); | 878 dispatcher->ProcessEvent(left_press_event); |
| 879 | 879 |
| 880 // Events should target child. | 880 // Events should target child. |
| 881 std::unique_ptr<DispatchedEventDetails> details = | 881 std::unique_ptr<DispatchedEventDetails> details = |
| 882 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 882 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 883 | 883 |
| 884 ASSERT_TRUE(details); | 884 ASSERT_TRUE(details); |
| 885 ASSERT_EQ(child.get(), details->window); | 885 ASSERT_EQ(child.get(), details->window); |
| 886 EXPECT_FALSE(details->in_nonclient_area); | 886 EXPECT_FALSE(details->in_nonclient_area); |
| 887 EXPECT_TRUE(IsMouseButtonDown()); | 887 EXPECT_TRUE(IsMouseButtonDown()); |
| 888 | 888 |
| 889 // The mouse down state should update while capture is set. | 889 // The mouse down state should update while capture is set. |
| 890 const ui::PointerEvent right_press_event(ui::MouseEvent( | 890 const ui::PointerEvent right_press_event(ui::MouseEvent( |
| 891 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 891 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 892 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 892 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 893 ui::EF_RIGHT_MOUSE_BUTTON)); | 893 ui::EF_RIGHT_MOUSE_BUTTON)); |
| 894 dispatcher->ProcessEvent(right_press_event); | 894 dispatcher->ProcessEvent(right_press_event); |
| 895 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 895 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 896 EXPECT_TRUE(IsMouseButtonDown()); | 896 EXPECT_TRUE(IsMouseButtonDown()); |
| 897 | 897 |
| 898 // One button released should not clear mouse down | 898 // One button released should not clear mouse down |
| 899 const ui::PointerEvent left_release_event(ui::MouseEvent( | 899 const ui::PointerEvent left_release_event(ui::MouseEvent( |
| 900 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), | 900 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 901 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 901 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 902 ui::EF_LEFT_MOUSE_BUTTON)); | 902 ui::EF_LEFT_MOUSE_BUTTON)); |
| 903 dispatcher->ProcessEvent(left_release_event); | 903 dispatcher->ProcessEvent(left_release_event); |
| 904 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 904 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 905 EXPECT_TRUE(IsMouseButtonDown()); | 905 EXPECT_TRUE(IsMouseButtonDown()); |
| 906 | 906 |
| 907 // Touch Event while mouse is down should not affect state. | 907 // Touch Event while mouse is down should not affect state. |
| 908 const ui::PointerEvent touch_event(ui::TouchEvent( | 908 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 909 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), 2, base::TimeDelta())); | 909 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), 2, base::TimeTicks())); |
| 910 dispatcher->ProcessEvent(touch_event); | 910 dispatcher->ProcessEvent(touch_event); |
| 911 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 911 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 912 EXPECT_TRUE(IsMouseButtonDown()); | 912 EXPECT_TRUE(IsMouseButtonDown()); |
| 913 | 913 |
| 914 // Move event should not affect down | 914 // Move event should not affect down |
| 915 const ui::PointerEvent move_event( | 915 const ui::PointerEvent move_event( |
| 916 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5), | 916 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5), |
| 917 base::TimeDelta(), ui::EF_RIGHT_MOUSE_BUTTON, | 917 base::TimeTicks(), ui::EF_RIGHT_MOUSE_BUTTON, |
| 918 ui::EF_RIGHT_MOUSE_BUTTON)); | 918 ui::EF_RIGHT_MOUSE_BUTTON)); |
| 919 dispatcher->ProcessEvent(move_event); | 919 dispatcher->ProcessEvent(move_event); |
| 920 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 920 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 921 EXPECT_TRUE(IsMouseButtonDown()); | 921 EXPECT_TRUE(IsMouseButtonDown()); |
| 922 | 922 |
| 923 // All mouse buttons up should clear mouse down. | 923 // All mouse buttons up should clear mouse down. |
| 924 const ui::PointerEvent right_release_event( | 924 const ui::PointerEvent right_release_event( |
| 925 ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), | 925 ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), |
| 926 gfx::Point(5, 5), base::TimeDelta(), | 926 gfx::Point(5, 5), base::TimeTicks(), |
| 927 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); | 927 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); |
| 928 dispatcher->ProcessEvent(right_release_event); | 928 dispatcher->ProcessEvent(right_release_event); |
| 929 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 929 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 930 EXPECT_FALSE(IsMouseButtonDown()); | 930 EXPECT_FALSE(IsMouseButtonDown()); |
| 931 } | 931 } |
| 932 | 932 |
| 933 { | 933 { |
| 934 // Releasing capture and sending the same event will go to the root. | 934 // Releasing capture and sending the same event will go to the root. |
| 935 dispatcher->SetCaptureWindow(nullptr, false); | 935 dispatcher->SetCaptureWindow(nullptr, false); |
| 936 const ui::PointerEvent press_event(ui::MouseEvent( | 936 const ui::PointerEvent press_event(ui::MouseEvent( |
| 937 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 937 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 938 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 938 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 939 dispatcher->ProcessEvent(press_event); | 939 dispatcher->ProcessEvent(press_event); |
| 940 | 940 |
| 941 // Events should target the root. | 941 // Events should target the root. |
| 942 std::unique_ptr<DispatchedEventDetails> details = | 942 std::unique_ptr<DispatchedEventDetails> details = |
| 943 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 943 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 944 | 944 |
| 945 ASSERT_TRUE(details); | 945 ASSERT_TRUE(details); |
| 946 ASSERT_EQ(root, details->window); | 946 ASSERT_EQ(root, details->window); |
| 947 } | 947 } |
| 948 } | 948 } |
| 949 | 949 |
| 950 // This test verifies that explicit capture overrides and resets implicit | 950 // This test verifies that explicit capture overrides and resets implicit |
| 951 // capture. | 951 // capture. |
| 952 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { | 952 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| 953 ServerWindow* root = root_window(); | 953 ServerWindow* root = root_window(); |
| 954 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 954 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 955 | 955 |
| 956 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 956 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 957 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 957 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 958 | 958 |
| 959 TestEventDispatcherDelegate* event_dispatcher_delegate = | 959 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 960 test_event_dispatcher_delegate(); | 960 test_event_dispatcher_delegate(); |
| 961 EventDispatcher* dispatcher = event_dispatcher(); | 961 EventDispatcher* dispatcher = event_dispatcher(); |
| 962 | 962 |
| 963 // Run some implicit capture tests. | 963 // Run some implicit capture tests. |
| 964 MouseEventTest tests[] = { | 964 MouseEventTest tests[] = { |
| 965 // Send a mouse down event over child with a left mouse button | 965 // Send a mouse down event over child with a left mouse button |
| 966 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 966 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), |
| 967 gfx::Point(20, 25), base::TimeDelta(), | 967 gfx::Point(20, 25), base::TimeTicks(), |
| 968 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 968 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 969 child.get(), gfx::Point(20, 25), gfx::Point(10, 15)}, | 969 child.get(), gfx::Point(20, 25), gfx::Point(10, 15)}, |
| 970 // Capture should be activated. Let's send a mouse move outside the bounds | 970 // Capture should be activated. Let's send a mouse move outside the bounds |
| 971 // of the child and press the right mouse button too. | 971 // of the child and press the right mouse button too. |
| 972 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 972 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), |
| 973 gfx::Point(50, 50), base::TimeDelta(), | 973 gfx::Point(50, 50), base::TimeTicks(), |
| 974 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), | 974 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), |
| 975 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, | 975 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, |
| 976 // Release the left mouse button and verify that the mouse up event goes | 976 // Release the left mouse button and verify that the mouse up event goes |
| 977 // to the child. | 977 // to the child. |
| 978 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), | 978 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), |
| 979 gfx::Point(50, 50), base::TimeDelta(), | 979 gfx::Point(50, 50), base::TimeTicks(), |
| 980 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, | 980 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, |
| 981 ui::EF_RIGHT_MOUSE_BUTTON), | 981 ui::EF_RIGHT_MOUSE_BUTTON), |
| 982 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, | 982 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, |
| 983 // A mouse move at (50, 50) should still go to the child. | 983 // A mouse move at (50, 50) should still go to the child. |
| 984 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), | 984 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), |
| 985 gfx::Point(50, 50), base::TimeDelta(), | 985 gfx::Point(50, 50), base::TimeTicks(), |
| 986 ui::EF_LEFT_MOUSE_BUTTON, 0), | 986 ui::EF_LEFT_MOUSE_BUTTON, 0), |
| 987 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, | 987 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, |
| 988 | 988 |
| 989 }; | 989 }; |
| 990 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests, | 990 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests, |
| 991 arraysize(tests)); | 991 arraysize(tests)); |
| 992 | 992 |
| 993 // Add a second pointer target to the child. | 993 // Add a second pointer target to the child. |
| 994 { | 994 { |
| 995 const ui::PointerEvent touch_event(ui::TouchEvent( | 995 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 996 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); | 996 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); |
| 997 dispatcher->ProcessEvent(touch_event); | 997 dispatcher->ProcessEvent(touch_event); |
| 998 } | 998 } |
| 999 | 999 |
| 1000 std::unique_ptr<DispatchedEventDetails> details = | 1000 std::unique_ptr<DispatchedEventDetails> details = |
| 1001 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1001 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1002 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1002 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1003 EXPECT_EQ(child.get(), details->window); | 1003 EXPECT_EQ(child.get(), details->window); |
| 1004 | 1004 |
| 1005 // Verify that no window has explicit capture and hence we did indeed do | 1005 // Verify that no window has explicit capture and hence we did indeed do |
| 1006 // implicit capture. | 1006 // implicit capture. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1018 EXPECT_EQ(ui::ET_POINTER_CANCELLED, details->event->type()); | 1018 EXPECT_EQ(ui::ET_POINTER_CANCELLED, details->event->type()); |
| 1019 | 1019 |
| 1020 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1020 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1021 ASSERT_TRUE(details); | 1021 ASSERT_TRUE(details); |
| 1022 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1022 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1023 EXPECT_EQ(child.get(), details->window); | 1023 EXPECT_EQ(child.get(), details->window); |
| 1024 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); | 1024 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); |
| 1025 | 1025 |
| 1026 const ui::PointerEvent press_event(ui::MouseEvent( | 1026 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1027 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1027 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1028 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1028 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1029 dispatcher->ProcessEvent(press_event); | 1029 dispatcher->ProcessEvent(press_event); |
| 1030 | 1030 |
| 1031 // Events should target the root. | 1031 // Events should target the root. |
| 1032 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1032 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1033 ASSERT_TRUE(details); | 1033 ASSERT_TRUE(details); |
| 1034 ASSERT_EQ(root, details->window); | 1034 ASSERT_EQ(root, details->window); |
| 1035 ASSERT_TRUE(details->in_nonclient_area); | 1035 ASSERT_TRUE(details->in_nonclient_area); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 // Tests that setting capture does delete active pointer targets for the capture | 1038 // Tests that setting capture does delete active pointer targets for the capture |
| 1039 // window. | 1039 // window. |
| 1040 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { | 1040 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| 1041 ServerWindow* root = root_window(); | 1041 ServerWindow* root = root_window(); |
| 1042 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1042 root->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1043 | 1043 |
| 1044 EventDispatcher* dispatcher = event_dispatcher(); | 1044 EventDispatcher* dispatcher = event_dispatcher(); |
| 1045 { | 1045 { |
| 1046 const ui::PointerEvent press_event(ui::MouseEvent( | 1046 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1047 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1047 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1048 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1048 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1049 dispatcher->ProcessEvent(press_event); | 1049 dispatcher->ProcessEvent(press_event); |
| 1050 | 1050 |
| 1051 std::unique_ptr<DispatchedEventDetails> details = | 1051 std::unique_ptr<DispatchedEventDetails> details = |
| 1052 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1052 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1053 ASSERT_TRUE(details); | 1053 ASSERT_TRUE(details); |
| 1054 ASSERT_EQ(root, details->window); | 1054 ASSERT_EQ(root, details->window); |
| 1055 } | 1055 } |
| 1056 { | 1056 { |
| 1057 const ui::PointerEvent touch_event(ui::TouchEvent( | 1057 const ui::PointerEvent touch_event(ui::TouchEvent( |
| 1058 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); | 1058 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); |
| 1059 dispatcher->ProcessEvent(touch_event); | 1059 dispatcher->ProcessEvent(touch_event); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 ASSERT_TRUE(AreAnyPointersDown()); | 1062 ASSERT_TRUE(AreAnyPointersDown()); |
| 1063 ASSERT_TRUE(IsWindowPointerTarget(root)); | 1063 ASSERT_TRUE(IsWindowPointerTarget(root)); |
| 1064 EXPECT_EQ(2, NumberPointerTargetsForWindow(root)); | 1064 EXPECT_EQ(2, NumberPointerTargetsForWindow(root)); |
| 1065 | 1065 |
| 1066 // Setting the capture should clear the implicit pointers for the specified | 1066 // Setting the capture should clear the implicit pointers for the specified |
| 1067 // window. | 1067 // window. |
| 1068 dispatcher->SetCaptureWindow(root, true); | 1068 dispatcher->SetCaptureWindow(root, true); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 | 1119 |
| 1120 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 1120 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 1121 EventDispatcher* dispatcher = event_dispatcher(); | 1121 EventDispatcher* dispatcher = event_dispatcher(); |
| 1122 dispatcher->SetCaptureWindow(root, true); | 1122 dispatcher->SetCaptureWindow(root, true); |
| 1123 | 1123 |
| 1124 TestEventDispatcherDelegate* event_dispatcher_delegate = | 1124 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 1125 test_event_dispatcher_delegate(); | 1125 test_event_dispatcher_delegate(); |
| 1126 // Press in the client area, it should be marked as non client. | 1126 // Press in the client area, it should be marked as non client. |
| 1127 const ui::PointerEvent press_event(ui::MouseEvent( | 1127 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1128 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), | 1128 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), |
| 1129 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1129 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1130 event_dispatcher()->ProcessEvent(press_event); | 1130 event_dispatcher()->ProcessEvent(press_event); |
| 1131 | 1131 |
| 1132 // Events should target child and be in the client area. | 1132 // Events should target child and be in the client area. |
| 1133 std::unique_ptr<DispatchedEventDetails> details = | 1133 std::unique_ptr<DispatchedEventDetails> details = |
| 1134 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1134 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1135 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1135 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1136 ASSERT_EQ(root, details->window); | 1136 ASSERT_EQ(root, details->window); |
| 1137 EXPECT_TRUE(details->in_nonclient_area); | 1137 EXPECT_TRUE(details->in_nonclient_area); |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 TEST_F(EventDispatcherTest, ProcessPointerEvents) { | 1140 TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| 1141 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1141 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1142 | 1142 |
| 1143 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1143 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1144 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1144 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1145 | 1145 |
| 1146 { | 1146 { |
| 1147 const ui::PointerEvent pointer_event(ui::MouseEvent( | 1147 const ui::PointerEvent pointer_event(ui::MouseEvent( |
| 1148 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1148 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1149 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1149 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1150 event_dispatcher()->ProcessEvent(pointer_event); | 1150 event_dispatcher()->ProcessEvent(pointer_event); |
| 1151 | 1151 |
| 1152 std::unique_ptr<DispatchedEventDetails> details = | 1152 std::unique_ptr<DispatchedEventDetails> details = |
| 1153 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1153 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1154 ASSERT_TRUE(details); | 1154 ASSERT_TRUE(details); |
| 1155 ASSERT_EQ(child.get(), details->window); | 1155 ASSERT_EQ(child.get(), details->window); |
| 1156 | 1156 |
| 1157 ASSERT_TRUE(details->event); | 1157 ASSERT_TRUE(details->event); |
| 1158 ASSERT_TRUE(details->event->IsPointerEvent()); | 1158 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1159 | 1159 |
| 1160 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1160 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1161 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location()); | 1161 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location()); |
| 1162 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); | 1162 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 { | 1165 { |
| 1166 const int touch_id = 3; | 1166 const int touch_id = 3; |
| 1167 const ui::PointerEvent pointer_event( | 1167 const ui::PointerEvent pointer_event( |
| 1168 ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(25, 20), touch_id, | 1168 ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(25, 20), touch_id, |
| 1169 base::TimeDelta())); | 1169 base::TimeTicks())); |
| 1170 event_dispatcher()->ProcessEvent(pointer_event); | 1170 event_dispatcher()->ProcessEvent(pointer_event); |
| 1171 | 1171 |
| 1172 std::unique_ptr<DispatchedEventDetails> details = | 1172 std::unique_ptr<DispatchedEventDetails> details = |
| 1173 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1173 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1174 ASSERT_TRUE(details); | 1174 ASSERT_TRUE(details); |
| 1175 ASSERT_EQ(child.get(), details->window); | 1175 ASSERT_EQ(child.get(), details->window); |
| 1176 | 1176 |
| 1177 ASSERT_TRUE(details->event); | 1177 ASSERT_TRUE(details->event); |
| 1178 ASSERT_TRUE(details->event->IsPointerEvent()); | 1178 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1179 | 1179 |
| 1180 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1180 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1181 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); | 1181 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); |
| 1182 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); | 1182 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); |
| 1183 EXPECT_EQ(touch_id, dispatched_event->pointer_id()); | 1183 EXPECT_EQ(touch_id, dispatched_event->pointer_id()); |
| 1184 } | 1184 } |
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { | 1187 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { |
| 1188 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1188 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1189 | 1189 |
| 1190 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1190 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1191 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1191 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 1192 | 1192 |
| 1193 // Send event that is over child. | 1193 // Send event that is over child. |
| 1194 const ui::PointerEvent ui_event(ui::MouseEvent( | 1194 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 1195 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1195 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1196 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1196 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1197 event_dispatcher()->ProcessEvent(ui_event); | 1197 event_dispatcher()->ProcessEvent(ui_event); |
| 1198 | 1198 |
| 1199 std::unique_ptr<DispatchedEventDetails> details = | 1199 std::unique_ptr<DispatchedEventDetails> details = |
| 1200 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1200 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1201 ASSERT_TRUE(details); | 1201 ASSERT_TRUE(details); |
| 1202 ASSERT_EQ(child.get(), details->window); | 1202 ASSERT_EQ(child.get(), details->window); |
| 1203 | 1203 |
| 1204 EXPECT_TRUE(AreAnyPointersDown()); | 1204 EXPECT_TRUE(AreAnyPointersDown()); |
| 1205 | 1205 |
| 1206 event_dispatcher()->Reset(); | 1206 event_dispatcher()->Reset(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1229 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1229 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1230 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1230 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1231 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1231 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1232 | 1232 |
| 1233 w1->AddTransientWindow(w2.get()); | 1233 w1->AddTransientWindow(w2.get()); |
| 1234 w2->SetModal(); | 1234 w2->SetModal(); |
| 1235 | 1235 |
| 1236 // Send event that is over |w1|. | 1236 // Send event that is over |w1|. |
| 1237 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1237 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1238 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1238 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1239 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1239 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1240 event_dispatcher()->ProcessEvent(mouse_pressed); | 1240 event_dispatcher()->ProcessEvent(mouse_pressed); |
| 1241 | 1241 |
| 1242 std::unique_ptr<DispatchedEventDetails> details = | 1242 std::unique_ptr<DispatchedEventDetails> details = |
| 1243 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1243 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1244 ASSERT_TRUE(details); | 1244 ASSERT_TRUE(details); |
| 1245 EXPECT_EQ(w2.get(), details->window); | 1245 EXPECT_EQ(w2.get(), details->window); |
| 1246 EXPECT_TRUE(details->in_nonclient_area); | 1246 EXPECT_TRUE(details->in_nonclient_area); |
| 1247 | 1247 |
| 1248 ASSERT_TRUE(details->event); | 1248 ASSERT_TRUE(details->event); |
| 1249 ASSERT_TRUE(details->event->IsPointerEvent()); | 1249 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1261 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1261 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1262 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1262 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1263 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1263 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1264 | 1264 |
| 1265 w1->AddTransientWindow(w2.get()); | 1265 w1->AddTransientWindow(w2.get()); |
| 1266 w2->SetModal(); | 1266 w2->SetModal(); |
| 1267 | 1267 |
| 1268 // Send event that is over |w2|. | 1268 // Send event that is over |w2|. |
| 1269 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1269 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1270 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), | 1270 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), |
| 1271 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1271 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1272 event_dispatcher()->ProcessEvent(mouse_pressed); | 1272 event_dispatcher()->ProcessEvent(mouse_pressed); |
| 1273 | 1273 |
| 1274 std::unique_ptr<DispatchedEventDetails> details = | 1274 std::unique_ptr<DispatchedEventDetails> details = |
| 1275 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1275 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1276 ASSERT_TRUE(details); | 1276 ASSERT_TRUE(details); |
| 1277 EXPECT_EQ(w2.get(), details->window); | 1277 EXPECT_EQ(w2.get(), details->window); |
| 1278 EXPECT_FALSE(details->in_nonclient_area); | 1278 EXPECT_FALSE(details->in_nonclient_area); |
| 1279 | 1279 |
| 1280 ASSERT_TRUE(details->event); | 1280 ASSERT_TRUE(details->event); |
| 1281 ASSERT_TRUE(details->event->IsPointerEvent()); | 1281 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1296 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1296 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1297 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1297 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1298 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 1298 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); |
| 1299 | 1299 |
| 1300 w1->AddTransientWindow(w2.get()); | 1300 w1->AddTransientWindow(w2.get()); |
| 1301 w2->SetModal(); | 1301 w2->SetModal(); |
| 1302 | 1302 |
| 1303 // Send event that is over |w3|. | 1303 // Send event that is over |w3|. |
| 1304 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1304 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1305 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), | 1305 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), |
| 1306 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1306 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1307 event_dispatcher()->ProcessEvent(mouse_pressed); | 1307 event_dispatcher()->ProcessEvent(mouse_pressed); |
| 1308 | 1308 |
| 1309 std::unique_ptr<DispatchedEventDetails> details = | 1309 std::unique_ptr<DispatchedEventDetails> details = |
| 1310 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1310 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1311 ASSERT_TRUE(details); | 1311 ASSERT_TRUE(details); |
| 1312 EXPECT_EQ(w3.get(), details->window); | 1312 EXPECT_EQ(w3.get(), details->window); |
| 1313 EXPECT_FALSE(details->in_nonclient_area); | 1313 EXPECT_FALSE(details->in_nonclient_area); |
| 1314 | 1314 |
| 1315 ASSERT_TRUE(details->event); | 1315 ASSERT_TRUE(details->event); |
| 1316 ASSERT_TRUE(details->event->IsPointerEvent()); | 1316 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1332 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1332 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1333 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1333 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); |
| 1334 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1334 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); |
| 1335 | 1335 |
| 1336 w1->AddTransientWindow(w2.get()); | 1336 w1->AddTransientWindow(w2.get()); |
| 1337 w2->SetModal(); | 1337 w2->SetModal(); |
| 1338 | 1338 |
| 1339 // Send event that is over |w11|. | 1339 // Send event that is over |w11|. |
| 1340 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1340 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1341 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), | 1341 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), |
| 1342 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1342 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1343 event_dispatcher()->ProcessEvent(mouse_pressed); | 1343 event_dispatcher()->ProcessEvent(mouse_pressed); |
| 1344 | 1344 |
| 1345 std::unique_ptr<DispatchedEventDetails> details = | 1345 std::unique_ptr<DispatchedEventDetails> details = |
| 1346 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1346 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1347 ASSERT_TRUE(details); | 1347 ASSERT_TRUE(details); |
| 1348 EXPECT_EQ(w2.get(), details->window); | 1348 EXPECT_EQ(w2.get(), details->window); |
| 1349 EXPECT_TRUE(details->in_nonclient_area); | 1349 EXPECT_TRUE(details->in_nonclient_area); |
| 1350 | 1350 |
| 1351 ASSERT_TRUE(details->event); | 1351 ASSERT_TRUE(details->event); |
| 1352 ASSERT_TRUE(details->event->IsPointerEvent()); | 1352 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1353 | 1353 |
| 1354 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1354 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1355 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); | 1355 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); |
| 1356 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); | 1356 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); |
| 1357 } | 1357 } |
| 1358 | 1358 |
| 1359 // Tests that events on a system modal window target the modal window itself. | 1359 // Tests that events on a system modal window target the modal window itself. |
| 1360 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { | 1360 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| 1361 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1361 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1362 | 1362 |
| 1363 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1363 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1364 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1364 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1365 w1->SetModal(); | 1365 w1->SetModal(); |
| 1366 | 1366 |
| 1367 // Send event that is over |w1|. | 1367 // Send event that is over |w1|. |
| 1368 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1368 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1369 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1369 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1370 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1370 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1371 event_dispatcher()->ProcessEvent(mouse_pressed); | 1371 event_dispatcher()->ProcessEvent(mouse_pressed); |
| 1372 | 1372 |
| 1373 std::unique_ptr<DispatchedEventDetails> details = | 1373 std::unique_ptr<DispatchedEventDetails> details = |
| 1374 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1374 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1375 ASSERT_TRUE(details); | 1375 ASSERT_TRUE(details); |
| 1376 EXPECT_EQ(w1.get(), details->window); | 1376 EXPECT_EQ(w1.get(), details->window); |
| 1377 EXPECT_FALSE(details->in_nonclient_area); | 1377 EXPECT_FALSE(details->in_nonclient_area); |
| 1378 | 1378 |
| 1379 ASSERT_TRUE(details->event); | 1379 ASSERT_TRUE(details->event); |
| 1380 ASSERT_TRUE(details->event->IsPointerEvent()); | 1380 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1381 | 1381 |
| 1382 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1382 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1383 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); | 1383 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); |
| 1384 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); | 1384 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 // Tests that events outside of system modal window target the modal window. | 1387 // Tests that events outside of system modal window target the modal window. |
| 1388 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { | 1388 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| 1389 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1389 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1390 | 1390 |
| 1391 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1391 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1392 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1392 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); |
| 1393 w1->SetModal(); | 1393 w1->SetModal(); |
| 1394 event_dispatcher()->AddSystemModalWindow(w1.get()); | 1394 event_dispatcher()->AddSystemModalWindow(w1.get()); |
| 1395 | 1395 |
| 1396 // Send event that is over |w1|. | 1396 // Send event that is over |w1|. |
| 1397 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1397 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1398 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), | 1398 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), |
| 1399 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1399 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1400 event_dispatcher()->ProcessEvent(mouse_pressed); | 1400 event_dispatcher()->ProcessEvent(mouse_pressed); |
| 1401 | 1401 |
| 1402 std::unique_ptr<DispatchedEventDetails> details = | 1402 std::unique_ptr<DispatchedEventDetails> details = |
| 1403 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1403 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1404 ASSERT_TRUE(details); | 1404 ASSERT_TRUE(details); |
| 1405 EXPECT_EQ(w1.get(), details->window); | 1405 EXPECT_EQ(w1.get(), details->window); |
| 1406 EXPECT_TRUE(details->in_nonclient_area); | 1406 EXPECT_TRUE(details->in_nonclient_area); |
| 1407 | 1407 |
| 1408 ASSERT_TRUE(details->event); | 1408 ASSERT_TRUE(details->event); |
| 1409 ASSERT_TRUE(details->event->IsPointerEvent()); | 1409 ASSERT_TRUE(details->event->IsPointerEvent()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 | 1504 |
| 1505 // Remove the last remaining system modal window. There should be no active | 1505 // Remove the last remaining system modal window. There should be no active |
| 1506 // one anymore. | 1506 // one anymore. |
| 1507 w3.reset(); | 1507 w3.reset(); |
| 1508 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); | 1508 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 } // namespace test | 1511 } // namespace test |
| 1512 } // namespace ws | 1512 } // namespace ws |
| 1513 } // namespace mus | 1513 } // namespace mus |
| OLD | NEW |