Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: components/mus/ws/event_dispatcher_unittest.cc

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/ws/display_unittest.cc ('k') | components/mus/ws/event_matcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 TEST_F(EventDispatcherTest, ProcessEvent) { 307 TEST_F(EventDispatcherTest, ProcessEvent) {
308 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 308 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
309 309
310 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 310 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
311 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 311 child->SetBounds(gfx::Rect(10, 10, 20, 20));
312 312
313 // Send event that is over child. 313 // Send event that is over child.
314 const ui::PointerEvent ui_event(ui::MouseEvent( 314 const ui::PointerEvent ui_event(ui::MouseEvent(
315 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), 315 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25),
316 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 316 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
317 event_dispatcher()->ProcessEvent(ui_event); 317 event_dispatcher()->ProcessEvent(ui_event);
318 318
319 std::unique_ptr<DispatchedEventDetails> details = 319 std::unique_ptr<DispatchedEventDetails> details =
320 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 320 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
321 ASSERT_TRUE(details); 321 ASSERT_TRUE(details);
322 ASSERT_EQ(child.get(), details->window); 322 ASSERT_EQ(child.get(), details->window);
323 323
324 ASSERT_TRUE(details->event); 324 ASSERT_TRUE(details->event);
325 ASSERT_TRUE(details->event->IsPointerEvent()); 325 ASSERT_TRUE(details->event->IsPointerEvent());
326 326
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 TEST_F(EventDispatcherTest, Capture) { 473 TEST_F(EventDispatcherTest, Capture) {
474 ServerWindow* root = root_window(); 474 ServerWindow* root = root_window();
475 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 475 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
476 476
477 root->SetBounds(gfx::Rect(0, 0, 100, 100)); 477 root->SetBounds(gfx::Rect(0, 0, 100, 100));
478 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 478 child->SetBounds(gfx::Rect(10, 10, 20, 20));
479 479
480 MouseEventTest tests[] = { 480 MouseEventTest tests[] = {
481 // Send a mouse down event over child. 481 // Send a mouse down event over child.
482 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), 482 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25),
483 gfx::Point(20, 25), base::TimeDelta(), 483 gfx::Point(20, 25), base::TimeTicks(),
484 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), 484 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON),
485 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, 485 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr,
486 gfx::Point(), gfx::Point()}, 486 gfx::Point(), gfx::Point()},
487 487
488 // Capture should be activated. Let's send a mouse move outside the bounds 488 // Capture should be activated. Let's send a mouse move outside the bounds
489 // of the child. 489 // of the child.
490 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), 490 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50),
491 gfx::Point(50, 50), base::TimeDelta(), 491 gfx::Point(50, 50), base::TimeTicks(),
492 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), 492 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON),
493 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, 493 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr,
494 gfx::Point(), gfx::Point()}, 494 gfx::Point(), gfx::Point()},
495 // Release the mouse and verify that the mouse up event goes to the child. 495 // Release the mouse and verify that the mouse up event goes to the child.
496 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), 496 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50),
497 gfx::Point(50, 50), base::TimeDelta(), 497 gfx::Point(50, 50), base::TimeTicks(),
498 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), 498 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON),
499 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, 499 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr,
500 gfx::Point(), gfx::Point()}, 500 gfx::Point(), gfx::Point()},
501 501
502 // A mouse move at (50, 50) should now go to the root window. As the 502 // A mouse move at (50, 50) should now go to the root window. As the
503 // move crosses between |child| and |root| |child| gets an exit, and 503 // move crosses between |child| and |root| |child| gets an exit, and
504 // |root| the move. 504 // |root| the move.
505 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), 505 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50),
506 gfx::Point(50, 50), base::TimeDelta(), 506 gfx::Point(50, 50), base::TimeTicks(),
507 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), 507 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON),
508 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), root, 508 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), root,
509 gfx::Point(50, 50), gfx::Point(50, 50)}, 509 gfx::Point(50, 50), gfx::Point(50, 50)},
510 510
511 }; 511 };
512 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), 512 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(),
513 tests, arraysize(tests)); 513 tests, arraysize(tests));
514 } 514 }
515 515
516 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { 516 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) {
517 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 517 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
518 518
519 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 519 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
520 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 520 child->SetBounds(gfx::Rect(10, 10, 20, 20));
521 521
522 MouseEventTest tests[] = { 522 MouseEventTest tests[] = {
523 // Send a mouse down event over child with a left mouse button 523 // Send a mouse down event over child with a left mouse button
524 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), 524 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25),
525 gfx::Point(20, 25), base::TimeDelta(), 525 gfx::Point(20, 25), base::TimeTicks(),
526 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), 526 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON),
527 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, 527 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr,
528 gfx::Point(), gfx::Point()}, 528 gfx::Point(), gfx::Point()},
529 529
530 // Capture should be activated. Let's send a mouse move outside the bounds 530 // Capture should be activated. Let's send a mouse move outside the bounds
531 // of the child and press the right mouse button too. 531 // of the child and press the right mouse button too.
532 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), 532 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50),
533 gfx::Point(50, 50), base::TimeDelta(), 533 gfx::Point(50, 50), base::TimeTicks(),
534 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), 534 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0),
535 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, 535 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr,
536 gfx::Point(), gfx::Point()}, 536 gfx::Point(), gfx::Point()},
537 537
538 // Release the left mouse button and verify that the mouse up event goes 538 // Release the left mouse button and verify that the mouse up event goes
539 // to the child. 539 // to the child.
540 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), 540 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50),
541 gfx::Point(50, 50), base::TimeDelta(), 541 gfx::Point(50, 50), base::TimeTicks(),
542 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 542 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
543 ui::EF_RIGHT_MOUSE_BUTTON), 543 ui::EF_RIGHT_MOUSE_BUTTON),
544 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, 544 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr,
545 gfx::Point(), gfx::Point()}, 545 gfx::Point(), gfx::Point()},
546 546
547 // A mouse move at (50, 50) should still go to the child. 547 // A mouse move at (50, 50) should still go to the child.
548 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), 548 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50),
549 gfx::Point(50, 50), base::TimeDelta(), 549 gfx::Point(50, 50), base::TimeTicks(),
550 ui::EF_LEFT_MOUSE_BUTTON, 0), 550 ui::EF_LEFT_MOUSE_BUTTON, 0),
551 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr, 551 child.get(), gfx::Point(50, 50), gfx::Point(40, 40), nullptr,
552 gfx::Point(), gfx::Point()}, 552 gfx::Point(), gfx::Point()},
553 553
554 }; 554 };
555 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), 555 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(),
556 tests, arraysize(tests)); 556 tests, arraysize(tests));
557 } 557 }
558 558
559 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { 559 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) {
560 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 560 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
561 561
562 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 562 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
563 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 563 child->SetBounds(gfx::Rect(10, 10, 20, 20));
564 564
565 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); 565 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>());
566 566
567 TestEventDispatcherDelegate* event_dispatcher_delegate = 567 TestEventDispatcherDelegate* event_dispatcher_delegate =
568 test_event_dispatcher_delegate(); 568 test_event_dispatcher_delegate();
569 EventDispatcher* dispatcher = event_dispatcher(); 569 EventDispatcher* dispatcher = event_dispatcher();
570 570
571 // Start move loop by sending mouse event over non-client area. 571 // Start move loop by sending mouse event over non-client area.
572 const ui::PointerEvent press_event(ui::MouseEvent( 572 const ui::PointerEvent press_event(ui::MouseEvent(
573 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), 573 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12),
574 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 574 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
575 dispatcher->ProcessEvent(press_event); 575 dispatcher->ProcessEvent(press_event);
576 576
577 // Events should target child and be in the non-client area. 577 // Events should target child and be in the non-client area.
578 std::unique_ptr<DispatchedEventDetails> details = 578 std::unique_ptr<DispatchedEventDetails> details =
579 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 579 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
580 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 580 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
581 ASSERT_TRUE(details); 581 ASSERT_TRUE(details);
582 ASSERT_EQ(child.get(), details->window); 582 ASSERT_EQ(child.get(), details->window);
583 EXPECT_TRUE(details->in_nonclient_area); 583 EXPECT_TRUE(details->in_nonclient_area);
584 584
585 // Move the mouse 5,6 pixels and target is the same. 585 // Move the mouse 5,6 pixels and target is the same.
586 const ui::PointerEvent move_event( 586 const ui::PointerEvent move_event(
587 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18), 587 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(17, 18), gfx::Point(17, 18),
588 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0)); 588 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0));
589 dispatcher->ProcessEvent(move_event); 589 dispatcher->ProcessEvent(move_event);
590 590
591 // Still same target. 591 // Still same target.
592 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 592 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
593 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 593 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
594 ASSERT_EQ(child.get(), details->window); 594 ASSERT_EQ(child.get(), details->window);
595 EXPECT_TRUE(details->in_nonclient_area); 595 EXPECT_TRUE(details->in_nonclient_area);
596 596
597 // Release the mouse. 597 // Release the mouse.
598 const ui::PointerEvent release_event(ui::MouseEvent( 598 const ui::PointerEvent release_event(ui::MouseEvent(
599 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18), 599 ui::ET_MOUSE_RELEASED, gfx::Point(17, 18), gfx::Point(17, 18),
600 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 600 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
601 dispatcher->ProcessEvent(release_event); 601 dispatcher->ProcessEvent(release_event);
602 602
603 // The event should not have been dispatched to the delegate. 603 // The event should not have been dispatched to the delegate.
604 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 604 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
605 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 605 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
606 ASSERT_EQ(child.get(), details->window); 606 ASSERT_EQ(child.get(), details->window);
607 EXPECT_TRUE(details->in_nonclient_area); 607 EXPECT_TRUE(details->in_nonclient_area);
608 608
609 // Press in the client area and verify target/client area. The non-client area 609 // Press in the client area and verify target/client area. The non-client area
610 // should get an exit first. 610 // should get an exit first.
611 const ui::PointerEvent press_event2(ui::MouseEvent( 611 const ui::PointerEvent press_event2(ui::MouseEvent(
612 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22), 612 ui::ET_MOUSE_PRESSED, gfx::Point(21, 22), gfx::Point(21, 22),
613 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 613 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
614 dispatcher->ProcessEvent(press_event2); 614 dispatcher->ProcessEvent(press_event2);
615 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 615 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
616 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events()); 616 EXPECT_TRUE(event_dispatcher_delegate->has_queued_events());
617 ASSERT_EQ(child.get(), details->window); 617 ASSERT_EQ(child.get(), details->window);
618 EXPECT_TRUE(details->in_nonclient_area); 618 EXPECT_TRUE(details->in_nonclient_area);
619 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); 619 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type());
620 620
621 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 621 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
622 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 622 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
623 ASSERT_EQ(child.get(), details->window); 623 ASSERT_EQ(child.get(), details->window);
624 EXPECT_FALSE(details->in_nonclient_area); 624 EXPECT_FALSE(details->in_nonclient_area);
625 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); 625 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type());
626 } 626 }
627 627
628 TEST_F(EventDispatcherTest, AdditionalClientArea) { 628 TEST_F(EventDispatcherTest, AdditionalClientArea) {
629 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 629 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
630 630
631 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 631 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
632 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 632 child->SetBounds(gfx::Rect(10, 10, 20, 20));
633 633
634 std::vector<gfx::Rect> additional_client_areas; 634 std::vector<gfx::Rect> additional_client_areas;
635 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); 635 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2));
636 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); 636 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas);
637 637
638 TestEventDispatcherDelegate* event_dispatcher_delegate = 638 TestEventDispatcherDelegate* event_dispatcher_delegate =
639 test_event_dispatcher_delegate(); 639 test_event_dispatcher_delegate();
640 // Press in the additional client area, it should go to the child. 640 // Press in the additional client area, it should go to the child.
641 const ui::PointerEvent press_event(ui::MouseEvent( 641 const ui::PointerEvent press_event(ui::MouseEvent(
642 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), 642 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11),
643 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 643 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
644 event_dispatcher()->ProcessEvent(press_event); 644 event_dispatcher()->ProcessEvent(press_event);
645 645
646 // Events should target child and be in the client area. 646 // Events should target child and be in the client area.
647 std::unique_ptr<DispatchedEventDetails> details = 647 std::unique_ptr<DispatchedEventDetails> details =
648 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 648 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
649 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 649 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
650 ASSERT_EQ(child.get(), details->window); 650 ASSERT_EQ(child.get(), details->window);
651 EXPECT_FALSE(details->in_nonclient_area); 651 EXPECT_FALSE(details->in_nonclient_area);
652 } 652 }
653 653
654 TEST_F(EventDispatcherTest, HitTestMask) { 654 TEST_F(EventDispatcherTest, HitTestMask) {
655 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 655 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
656 656
657 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 657 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
658 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 658 child->SetBounds(gfx::Rect(10, 10, 20, 20));
659 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); 659 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16));
660 660
661 // Move in the masked area. 661 // Move in the masked area.
662 const ui::PointerEvent move1(ui::MouseEvent( 662 const ui::PointerEvent move1(ui::MouseEvent(
663 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), 663 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11),
664 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0)); 664 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0));
665 event_dispatcher()->ProcessEvent(move1); 665 event_dispatcher()->ProcessEvent(move1);
666 666
667 // Event went through the child window and hit the root. 667 // Event went through the child window and hit the root.
668 std::unique_ptr<DispatchedEventDetails> details1 = 668 std::unique_ptr<DispatchedEventDetails> details1 =
669 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 669 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
670 EXPECT_EQ(root_window(), details1->window); 670 EXPECT_EQ(root_window(), details1->window);
671 EXPECT_FALSE(details1->in_nonclient_area); 671 EXPECT_FALSE(details1->in_nonclient_area);
672 672
673 child->ClearHitTestMask(); 673 child->ClearHitTestMask();
674 674
675 // Move right in the same part of the window. 675 // Move right in the same part of the window.
676 const ui::PointerEvent move2(ui::MouseEvent( 676 const ui::PointerEvent move2(ui::MouseEvent(
677 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12), 677 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12),
678 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0)); 678 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0));
679 event_dispatcher()->ProcessEvent(move2); 679 event_dispatcher()->ProcessEvent(move2);
680 680
681 // Mouse exits the root. 681 // Mouse exits the root.
682 std::unique_ptr<DispatchedEventDetails> details2 = 682 std::unique_ptr<DispatchedEventDetails> details2 =
683 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 683 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
684 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type()); 684 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type());
685 685
686 // Mouse hits the child. 686 // Mouse hits the child.
687 std::unique_ptr<DispatchedEventDetails> details3 = 687 std::unique_ptr<DispatchedEventDetails> details3 =
688 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 688 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
689 EXPECT_EQ(child.get(), details3->window); 689 EXPECT_EQ(child.get(), details3->window);
690 EXPECT_FALSE(details3->in_nonclient_area); 690 EXPECT_FALSE(details3->in_nonclient_area);
691 } 691 }
692 692
693 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { 693 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) {
694 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); 694 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3));
695 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); 695 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4));
696 696
697 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 697 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
698 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); 698 child1->SetBounds(gfx::Rect(10, 10, 20, 20));
699 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); 699 child2->SetBounds(gfx::Rect(50, 51, 11, 12));
700 700
701 TestEventDispatcherDelegate* event_dispatcher_delegate = 701 TestEventDispatcherDelegate* event_dispatcher_delegate =
702 test_event_dispatcher_delegate(); 702 test_event_dispatcher_delegate();
703 EventDispatcher* dispatcher = event_dispatcher(); 703 EventDispatcher* dispatcher = event_dispatcher();
704 704
705 // Press on child1. First press event should change focus. 705 // Press on child1. First press event should change focus.
706 const ui::PointerEvent press_event(ui::MouseEvent( 706 const ui::PointerEvent press_event(ui::MouseEvent(
707 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), 707 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12),
708 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 708 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
709 dispatcher->ProcessEvent(press_event); 709 dispatcher->ProcessEvent(press_event);
710 std::unique_ptr<DispatchedEventDetails> details = 710 std::unique_ptr<DispatchedEventDetails> details =
711 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 711 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
712 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 712 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
713 EXPECT_EQ(child1.get(), details->window); 713 EXPECT_EQ(child1.get(), details->window);
714 EXPECT_EQ(child1.get(), 714 EXPECT_EQ(child1.get(),
715 event_dispatcher_delegate->GetAndClearLastFocusedWindow()); 715 event_dispatcher_delegate->GetAndClearLastFocusedWindow());
716 716
717 // Press (with a different pointer id) on child2. Event should go to child2, 717 // Press (with a different pointer id) on child2. Event should go to child2,
718 // but focus should not change. 718 // but focus should not change.
719 const ui::PointerEvent touch_event(ui::TouchEvent( 719 const ui::PointerEvent touch_event(ui::TouchEvent(
720 ui::ET_TOUCH_PRESSED, gfx::Point(53, 54), 2, base::TimeDelta())); 720 ui::ET_TOUCH_PRESSED, gfx::Point(53, 54), 2, base::TimeTicks()));
721 dispatcher->ProcessEvent(touch_event); 721 dispatcher->ProcessEvent(touch_event);
722 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 722 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
723 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 723 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
724 EXPECT_EQ(child2.get(), details->window); 724 EXPECT_EQ(child2.get(), details->window);
725 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); 725 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow());
726 } 726 }
727 727
728 TEST_F(EventDispatcherTest, TwoPointersActive) { 728 TEST_F(EventDispatcherTest, TwoPointersActive) {
729 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); 729 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3));
730 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); 730 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4));
731 731
732 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 732 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
733 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); 733 child1->SetBounds(gfx::Rect(10, 10, 20, 20));
734 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); 734 child2->SetBounds(gfx::Rect(50, 51, 11, 12));
735 735
736 TestEventDispatcherDelegate* event_dispatcher_delegate = 736 TestEventDispatcherDelegate* event_dispatcher_delegate =
737 test_event_dispatcher_delegate(); 737 test_event_dispatcher_delegate();
738 EventDispatcher* dispatcher = event_dispatcher(); 738 EventDispatcher* dispatcher = event_dispatcher();
739 739
740 // Press on child1. 740 // Press on child1.
741 const ui::PointerEvent touch_event1(ui::TouchEvent( 741 const ui::PointerEvent touch_event1(ui::TouchEvent(
742 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); 742 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks()));
743 dispatcher->ProcessEvent(touch_event1); 743 dispatcher->ProcessEvent(touch_event1);
744 std::unique_ptr<DispatchedEventDetails> details = 744 std::unique_ptr<DispatchedEventDetails> details =
745 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 745 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
746 EXPECT_EQ(child1.get(), details->window); 746 EXPECT_EQ(child1.get(), details->window);
747 747
748 // Drag over child2, child1 should get the drag. 748 // Drag over child2, child1 should get the drag.
749 const ui::PointerEvent drag_event1(ui::TouchEvent( 749 const ui::PointerEvent drag_event1(ui::TouchEvent(
750 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeDelta())); 750 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeTicks()));
751 dispatcher->ProcessEvent(drag_event1); 751 dispatcher->ProcessEvent(drag_event1);
752 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 752 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
753 EXPECT_EQ(child1.get(), details->window); 753 EXPECT_EQ(child1.get(), details->window);
754 754
755 // Press on child2 with a different touch id. 755 // Press on child2 with a different touch id.
756 const ui::PointerEvent touch_event2(ui::TouchEvent( 756 const ui::PointerEvent touch_event2(ui::TouchEvent(
757 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeDelta())); 757 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeTicks()));
758 dispatcher->ProcessEvent(touch_event2); 758 dispatcher->ProcessEvent(touch_event2);
759 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 759 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
760 EXPECT_EQ(child2.get(), details->window); 760 EXPECT_EQ(child2.get(), details->window);
761 761
762 // Drag over child1 with id 2, child2 should continue to get the drag. 762 // Drag over child1 with id 2, child2 should continue to get the drag.
763 const ui::PointerEvent drag_event2(ui::TouchEvent( 763 const ui::PointerEvent drag_event2(ui::TouchEvent(
764 ui::ET_TOUCH_MOVED, gfx::Point(13, 14), 2, base::TimeDelta())); 764 ui::ET_TOUCH_MOVED, gfx::Point(13, 14), 2, base::TimeTicks()));
765 dispatcher->ProcessEvent(drag_event2); 765 dispatcher->ProcessEvent(drag_event2);
766 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 766 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
767 EXPECT_EQ(child2.get(), details->window); 767 EXPECT_EQ(child2.get(), details->window);
768 768
769 // Drag again with id 1, child1 should continue to get it. 769 // Drag again with id 1, child1 should continue to get it.
770 dispatcher->ProcessEvent(drag_event1); 770 dispatcher->ProcessEvent(drag_event1);
771 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 771 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
772 EXPECT_EQ(child1.get(), details->window); 772 EXPECT_EQ(child1.get(), details->window);
773 773
774 // Release touch id 1, and click on 2. 2 should get it. 774 // Release touch id 1, and click on 2. 2 should get it.
775 const ui::PointerEvent touch_release(ui::TouchEvent( 775 const ui::PointerEvent touch_release(ui::TouchEvent(
776 ui::ET_TOUCH_RELEASED, gfx::Point(54, 55), 1, base::TimeDelta())); 776 ui::ET_TOUCH_RELEASED, gfx::Point(54, 55), 1, base::TimeTicks()));
777 dispatcher->ProcessEvent(touch_release); 777 dispatcher->ProcessEvent(touch_release);
778 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 778 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
779 EXPECT_EQ(child1.get(), details->window); 779 EXPECT_EQ(child1.get(), details->window);
780 const ui::PointerEvent touch_event3(ui::TouchEvent( 780 const ui::PointerEvent touch_event3(ui::TouchEvent(
781 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeDelta())); 781 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeTicks()));
782 dispatcher->ProcessEvent(touch_event3); 782 dispatcher->ProcessEvent(touch_event3);
783 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 783 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
784 EXPECT_EQ(child2.get(), details->window); 784 EXPECT_EQ(child2.get(), details->window);
785 } 785 }
786 786
787 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { 787 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) {
788 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 788 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
789 789
790 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 790 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
791 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 791 child->SetBounds(gfx::Rect(10, 10, 20, 20));
792 792
793 TestEventDispatcherDelegate* event_dispatcher_delegate = 793 TestEventDispatcherDelegate* event_dispatcher_delegate =
794 test_event_dispatcher_delegate(); 794 test_event_dispatcher_delegate();
795 EventDispatcher* dispatcher = event_dispatcher(); 795 EventDispatcher* dispatcher = event_dispatcher();
796 796
797 // Press on child. 797 // Press on child.
798 const ui::PointerEvent touch_event1(ui::TouchEvent( 798 const ui::PointerEvent touch_event1(ui::TouchEvent(
799 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); 799 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks()));
800 dispatcher->ProcessEvent(touch_event1); 800 dispatcher->ProcessEvent(touch_event1);
801 std::unique_ptr<DispatchedEventDetails> details = 801 std::unique_ptr<DispatchedEventDetails> details =
802 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 802 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
803 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 803 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
804 EXPECT_EQ(child.get(), details->window); 804 EXPECT_EQ(child.get(), details->window);
805 805
806 // Delete child, and continue the drag. Event should not be dispatched. 806 // Delete child, and continue the drag. Event should not be dispatched.
807 child.reset(); 807 child.reset();
808 808
809 const ui::PointerEvent drag_event1(ui::TouchEvent( 809 const ui::PointerEvent drag_event1(ui::TouchEvent(
810 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeDelta())); 810 ui::ET_TOUCH_MOVED, gfx::Point(53, 54), 1, base::TimeTicks()));
811 dispatcher->ProcessEvent(drag_event1); 811 dispatcher->ProcessEvent(drag_event1);
812 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 812 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
813 EXPECT_EQ(nullptr, details.get()); 813 EXPECT_EQ(nullptr, details.get());
814 } 814 }
815 815
816 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { 816 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) {
817 ServerWindow* root = root_window(); 817 ServerWindow* root = root_window();
818 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 818 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
819 819
820 root->SetBounds(gfx::Rect(0, 0, 100, 100)); 820 root->SetBounds(gfx::Rect(0, 0, 100, 100));
821 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 821 child->SetBounds(gfx::Rect(10, 10, 20, 20));
822 822
823 TestEventDispatcherDelegate* event_dispatcher_delegate = 823 TestEventDispatcherDelegate* event_dispatcher_delegate =
824 test_event_dispatcher_delegate(); 824 test_event_dispatcher_delegate();
825 EventDispatcher* dispatcher = event_dispatcher(); 825 EventDispatcher* dispatcher = event_dispatcher();
826 826
827 // Send event that is not over child. 827 // Send event that is not over child.
828 const ui::PointerEvent ui_event(ui::MouseEvent( 828 const ui::PointerEvent ui_event(ui::MouseEvent(
829 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), 829 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9),
830 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 830 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
831 dispatcher->ProcessEvent(ui_event); 831 dispatcher->ProcessEvent(ui_event);
832 std::unique_ptr<DispatchedEventDetails> details = 832 std::unique_ptr<DispatchedEventDetails> details =
833 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 833 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
834 ASSERT_EQ(root, details->window); 834 ASSERT_EQ(root, details->window);
835 835
836 // Release the mouse. 836 // Release the mouse.
837 const ui::PointerEvent release_event(ui::MouseEvent( 837 const ui::PointerEvent release_event(ui::MouseEvent(
838 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9), 838 ui::ET_MOUSE_RELEASED, gfx::Point(8, 9), gfx::Point(8, 9),
839 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 839 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
840 dispatcher->ProcessEvent(release_event); 840 dispatcher->ProcessEvent(release_event);
841 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 841 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
842 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 842 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
843 ASSERT_EQ(root, details->window); 843 ASSERT_EQ(root, details->window);
844 EXPECT_FALSE(details->in_nonclient_area); 844 EXPECT_FALSE(details->in_nonclient_area);
845 845
846 // Change the extended hit test region and send event in extended hit test 846 // Change the extended hit test region and send event in extended hit test
847 // region. Should result in exit for root, followed by press for child. 847 // region. Should result in exit for root, followed by press for child.
848 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5)); 848 child->set_extended_hit_test_region(gfx::Insets(5, 5, 5, 5));
849 dispatcher->ProcessEvent(ui_event); 849 dispatcher->ProcessEvent(ui_event);
(...skipping 16 matching lines...) Expand all
866 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); 866 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3));
867 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); 867 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4));
868 868
869 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 869 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
870 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); 870 child1->SetBounds(gfx::Rect(10, 10, 20, 20));
871 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); 871 child2->SetBounds(gfx::Rect(50, 51, 11, 12));
872 872
873 MouseEventTest tests[] = { 873 MouseEventTest tests[] = {
874 // Send a mouse down event over child1. 874 // Send a mouse down event over child1.
875 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), 875 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(15, 15),
876 gfx::Point(15, 15), base::TimeDelta(), 876 gfx::Point(15, 15), base::TimeTicks(),
877 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), 877 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON),
878 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr, 878 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr,
879 gfx::Point(), gfx::Point()}, 879 gfx::Point(), gfx::Point()},
880 // Send mouse wheel over child2, should go to child1 as it has capture. 880 // Send mouse wheel over child2, should go to child1 as it has capture.
881 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54), 881 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54),
882 gfx::Point(53, 54), base::TimeDelta(), ui::EF_NONE, 882 gfx::Point(53, 54), base::TimeTicks(), ui::EF_NONE,
883 ui::EF_NONE), 883 ui::EF_NONE),
884 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr, 884 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr,
885 gfx::Point(), gfx::Point()}, 885 gfx::Point(), gfx::Point()},
886 }; 886 };
887 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), 887 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(),
888 tests, arraysize(tests)); 888 tests, arraysize(tests));
889 } 889 }
890 890
891 // Tests that when explicit capture has been set that all events go to the 891 // Tests that when explicit capture has been set that all events go to the
892 // designated window, and that when capture is cleared, events find the 892 // designated window, and that when capture is cleared, events find the
(...skipping 10 matching lines...) Expand all
903 EventDispatcher* dispatcher = event_dispatcher(); 903 EventDispatcher* dispatcher = event_dispatcher();
904 904
905 { 905 {
906 // Send all pointer events to the child. 906 // Send all pointer events to the child.
907 dispatcher->SetCaptureWindow(child.get(), false); 907 dispatcher->SetCaptureWindow(child.get(), false);
908 908
909 // The mouse press should go to the child even though its outside its 909 // The mouse press should go to the child even though its outside its
910 // bounds. 910 // bounds.
911 const ui::PointerEvent left_press_event(ui::MouseEvent( 911 const ui::PointerEvent left_press_event(ui::MouseEvent(
912 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 912 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5),
913 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 913 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
914 dispatcher->ProcessEvent(left_press_event); 914 dispatcher->ProcessEvent(left_press_event);
915 915
916 // Events should target child. 916 // Events should target child.
917 std::unique_ptr<DispatchedEventDetails> details = 917 std::unique_ptr<DispatchedEventDetails> details =
918 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 918 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
919 919
920 ASSERT_TRUE(details); 920 ASSERT_TRUE(details);
921 ASSERT_EQ(child.get(), details->window); 921 ASSERT_EQ(child.get(), details->window);
922 EXPECT_FALSE(details->in_nonclient_area); 922 EXPECT_FALSE(details->in_nonclient_area);
923 EXPECT_TRUE(IsMouseButtonDown()); 923 EXPECT_TRUE(IsMouseButtonDown());
924 924
925 // The mouse down state should update while capture is set. 925 // The mouse down state should update while capture is set.
926 const ui::PointerEvent right_press_event(ui::MouseEvent( 926 const ui::PointerEvent right_press_event(ui::MouseEvent(
927 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 927 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5),
928 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 928 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
929 ui::EF_RIGHT_MOUSE_BUTTON)); 929 ui::EF_RIGHT_MOUSE_BUTTON));
930 dispatcher->ProcessEvent(right_press_event); 930 dispatcher->ProcessEvent(right_press_event);
931 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 931 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
932 EXPECT_TRUE(IsMouseButtonDown()); 932 EXPECT_TRUE(IsMouseButtonDown());
933 933
934 // One button released should not clear mouse down 934 // One button released should not clear mouse down
935 const ui::PointerEvent left_release_event(ui::MouseEvent( 935 const ui::PointerEvent left_release_event(ui::MouseEvent(
936 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5), 936 ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), gfx::Point(5, 5),
937 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 937 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
938 ui::EF_LEFT_MOUSE_BUTTON)); 938 ui::EF_LEFT_MOUSE_BUTTON));
939 dispatcher->ProcessEvent(left_release_event); 939 dispatcher->ProcessEvent(left_release_event);
940 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 940 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
941 EXPECT_TRUE(IsMouseButtonDown()); 941 EXPECT_TRUE(IsMouseButtonDown());
942 942
943 // Touch Event while mouse is down should not affect state. 943 // Touch Event while mouse is down should not affect state.
944 const ui::PointerEvent touch_event(ui::TouchEvent( 944 const ui::PointerEvent touch_event(ui::TouchEvent(
945 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), 2, base::TimeDelta())); 945 ui::ET_TOUCH_PRESSED, gfx::Point(15, 15), 2, base::TimeTicks()));
946 dispatcher->ProcessEvent(touch_event); 946 dispatcher->ProcessEvent(touch_event);
947 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 947 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
948 EXPECT_TRUE(IsMouseButtonDown()); 948 EXPECT_TRUE(IsMouseButtonDown());
949 949
950 // Move event should not affect down 950 // Move event should not affect down
951 const ui::PointerEvent move_event( 951 const ui::PointerEvent move_event(
952 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5), 952 ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(15, 5), gfx::Point(15, 5),
953 base::TimeDelta(), ui::EF_RIGHT_MOUSE_BUTTON, 953 base::TimeTicks(), ui::EF_RIGHT_MOUSE_BUTTON,
954 ui::EF_RIGHT_MOUSE_BUTTON)); 954 ui::EF_RIGHT_MOUSE_BUTTON));
955 dispatcher->ProcessEvent(move_event); 955 dispatcher->ProcessEvent(move_event);
956 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 956 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
957 EXPECT_TRUE(IsMouseButtonDown()); 957 EXPECT_TRUE(IsMouseButtonDown());
958 958
959 // All mouse buttons up should clear mouse down. 959 // All mouse buttons up should clear mouse down.
960 const ui::PointerEvent right_release_event( 960 const ui::PointerEvent right_release_event(
961 ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), 961 ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5),
962 gfx::Point(5, 5), base::TimeDelta(), 962 gfx::Point(5, 5), base::TimeTicks(),
963 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON)); 963 ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON));
964 dispatcher->ProcessEvent(right_release_event); 964 dispatcher->ProcessEvent(right_release_event);
965 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 965 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
966 EXPECT_FALSE(IsMouseButtonDown()); 966 EXPECT_FALSE(IsMouseButtonDown());
967 } 967 }
968 968
969 { 969 {
970 // Releasing capture and sending the same event will go to the root. 970 // Releasing capture and sending the same event will go to the root.
971 dispatcher->SetCaptureWindow(nullptr, false); 971 dispatcher->SetCaptureWindow(nullptr, false);
972 const ui::PointerEvent press_event(ui::MouseEvent( 972 const ui::PointerEvent press_event(ui::MouseEvent(
973 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 973 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5),
974 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 974 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
975 dispatcher->ProcessEvent(press_event); 975 dispatcher->ProcessEvent(press_event);
976 976
977 // Events should target the root. 977 // Events should target the root.
978 std::unique_ptr<DispatchedEventDetails> details = 978 std::unique_ptr<DispatchedEventDetails> details =
979 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 979 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
980 980
981 ASSERT_TRUE(details); 981 ASSERT_TRUE(details);
982 ASSERT_EQ(root, details->window); 982 ASSERT_EQ(root, details->window);
983 } 983 }
984 } 984 }
985 985
986 // This test verifies that explicit capture overrides and resets implicit 986 // This test verifies that explicit capture overrides and resets implicit
987 // capture. 987 // capture.
988 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { 988 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) {
989 ServerWindow* root = root_window(); 989 ServerWindow* root = root_window();
990 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 990 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
991 991
992 root->SetBounds(gfx::Rect(0, 0, 100, 100)); 992 root->SetBounds(gfx::Rect(0, 0, 100, 100));
993 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 993 child->SetBounds(gfx::Rect(10, 10, 20, 20));
994 994
995 TestEventDispatcherDelegate* event_dispatcher_delegate = 995 TestEventDispatcherDelegate* event_dispatcher_delegate =
996 test_event_dispatcher_delegate(); 996 test_event_dispatcher_delegate();
997 EventDispatcher* dispatcher = event_dispatcher(); 997 EventDispatcher* dispatcher = event_dispatcher();
998 998
999 // Run some implicit capture tests. 999 // Run some implicit capture tests.
1000 MouseEventTest tests[] = { 1000 MouseEventTest tests[] = {
1001 // Send a mouse down event over child with a left mouse button 1001 // Send a mouse down event over child with a left mouse button
1002 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), 1002 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25),
1003 gfx::Point(20, 25), base::TimeDelta(), 1003 gfx::Point(20, 25), base::TimeTicks(),
1004 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), 1004 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON),
1005 child.get(), gfx::Point(20, 25), gfx::Point(10, 15)}, 1005 child.get(), gfx::Point(20, 25), gfx::Point(10, 15)},
1006 // Capture should be activated. Let's send a mouse move outside the bounds 1006 // Capture should be activated. Let's send a mouse move outside the bounds
1007 // of the child and press the right mouse button too. 1007 // of the child and press the right mouse button too.
1008 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), 1008 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50),
1009 gfx::Point(50, 50), base::TimeDelta(), 1009 gfx::Point(50, 50), base::TimeTicks(),
1010 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0), 1010 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 0),
1011 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, 1011 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)},
1012 // Release the left mouse button and verify that the mouse up event goes 1012 // Release the left mouse button and verify that the mouse up event goes
1013 // to the child. 1013 // to the child.
1014 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50), 1014 {ui::MouseEvent(ui::ET_MOUSE_RELEASED, gfx::Point(50, 50),
1015 gfx::Point(50, 50), base::TimeDelta(), 1015 gfx::Point(50, 50), base::TimeTicks(),
1016 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON, 1016 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
1017 ui::EF_RIGHT_MOUSE_BUTTON), 1017 ui::EF_RIGHT_MOUSE_BUTTON),
1018 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, 1018 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)},
1019 // A mouse move at (50, 50) should still go to the child. 1019 // A mouse move at (50, 50) should still go to the child.
1020 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50), 1020 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(50, 50),
1021 gfx::Point(50, 50), base::TimeDelta(), 1021 gfx::Point(50, 50), base::TimeTicks(),
1022 ui::EF_LEFT_MOUSE_BUTTON, 0), 1022 ui::EF_LEFT_MOUSE_BUTTON, 0),
1023 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)}, 1023 child.get(), gfx::Point(50, 50), gfx::Point(40, 40)},
1024 1024
1025 }; 1025 };
1026 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests, 1026 RunMouseEventTests(dispatcher, event_dispatcher_delegate, tests,
1027 arraysize(tests)); 1027 arraysize(tests));
1028 1028
1029 // Add a second pointer target to the child. 1029 // Add a second pointer target to the child.
1030 { 1030 {
1031 const ui::PointerEvent touch_event(ui::TouchEvent( 1031 const ui::PointerEvent touch_event(ui::TouchEvent(
1032 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); 1032 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks()));
1033 dispatcher->ProcessEvent(touch_event); 1033 dispatcher->ProcessEvent(touch_event);
1034 } 1034 }
1035 1035
1036 std::unique_ptr<DispatchedEventDetails> details = 1036 std::unique_ptr<DispatchedEventDetails> details =
1037 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 1037 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
1038 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 1038 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
1039 EXPECT_EQ(child.get(), details->window); 1039 EXPECT_EQ(child.get(), details->window);
1040 1040
1041 // Verify that no window has explicit capture and hence we did indeed do 1041 // Verify that no window has explicit capture and hence we did indeed do
1042 // implicit capture. 1042 // implicit capture.
(...skipping 11 matching lines...) Expand all
1054 EXPECT_EQ(ui::ET_POINTER_CANCELLED, details->event->type()); 1054 EXPECT_EQ(ui::ET_POINTER_CANCELLED, details->event->type());
1055 1055
1056 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 1056 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
1057 ASSERT_TRUE(details); 1057 ASSERT_TRUE(details);
1058 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 1058 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
1059 EXPECT_EQ(child.get(), details->window); 1059 EXPECT_EQ(child.get(), details->window);
1060 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type()); 1060 EXPECT_EQ(ui::ET_POINTER_EXITED, details->event->type());
1061 1061
1062 const ui::PointerEvent press_event(ui::MouseEvent( 1062 const ui::PointerEvent press_event(ui::MouseEvent(
1063 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), 1063 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15),
1064 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1064 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1065 dispatcher->ProcessEvent(press_event); 1065 dispatcher->ProcessEvent(press_event);
1066 1066
1067 // Events should target the root. 1067 // Events should target the root.
1068 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 1068 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
1069 ASSERT_TRUE(details); 1069 ASSERT_TRUE(details);
1070 ASSERT_EQ(root, details->window); 1070 ASSERT_EQ(root, details->window);
1071 ASSERT_TRUE(details->in_nonclient_area); 1071 ASSERT_TRUE(details->in_nonclient_area);
1072 } 1072 }
1073 1073
1074 // Tests that setting capture does delete active pointer targets for the capture 1074 // Tests that setting capture does delete active pointer targets for the capture
1075 // window. 1075 // window.
1076 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { 1076 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) {
1077 ServerWindow* root = root_window(); 1077 ServerWindow* root = root_window();
1078 root->SetBounds(gfx::Rect(0, 0, 100, 100)); 1078 root->SetBounds(gfx::Rect(0, 0, 100, 100));
1079 1079
1080 EventDispatcher* dispatcher = event_dispatcher(); 1080 EventDispatcher* dispatcher = event_dispatcher();
1081 { 1081 {
1082 const ui::PointerEvent press_event(ui::MouseEvent( 1082 const ui::PointerEvent press_event(ui::MouseEvent(
1083 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 1083 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5),
1084 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1084 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1085 dispatcher->ProcessEvent(press_event); 1085 dispatcher->ProcessEvent(press_event);
1086 1086
1087 std::unique_ptr<DispatchedEventDetails> details = 1087 std::unique_ptr<DispatchedEventDetails> details =
1088 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1088 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1089 ASSERT_TRUE(details); 1089 ASSERT_TRUE(details);
1090 ASSERT_EQ(root, details->window); 1090 ASSERT_EQ(root, details->window);
1091 } 1091 }
1092 { 1092 {
1093 const ui::PointerEvent touch_event(ui::TouchEvent( 1093 const ui::PointerEvent touch_event(ui::TouchEvent(
1094 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeDelta())); 1094 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks()));
1095 dispatcher->ProcessEvent(touch_event); 1095 dispatcher->ProcessEvent(touch_event);
1096 } 1096 }
1097 1097
1098 ASSERT_TRUE(AreAnyPointersDown()); 1098 ASSERT_TRUE(AreAnyPointersDown());
1099 ASSERT_TRUE(IsWindowPointerTarget(root)); 1099 ASSERT_TRUE(IsWindowPointerTarget(root));
1100 EXPECT_EQ(2, NumberPointerTargetsForWindow(root)); 1100 EXPECT_EQ(2, NumberPointerTargetsForWindow(root));
1101 1101
1102 // Setting the capture should clear the implicit pointers for the specified 1102 // Setting the capture should clear the implicit pointers for the specified
1103 // window. 1103 // window.
1104 dispatcher->SetCaptureWindow(root, true); 1104 dispatcher->SetCaptureWindow(root, true);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1155
1156 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); 1156 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>());
1157 EventDispatcher* dispatcher = event_dispatcher(); 1157 EventDispatcher* dispatcher = event_dispatcher();
1158 dispatcher->SetCaptureWindow(root, true); 1158 dispatcher->SetCaptureWindow(root, true);
1159 1159
1160 TestEventDispatcherDelegate* event_dispatcher_delegate = 1160 TestEventDispatcherDelegate* event_dispatcher_delegate =
1161 test_event_dispatcher_delegate(); 1161 test_event_dispatcher_delegate();
1162 // Press in the client area, it should be marked as non client. 1162 // Press in the client area, it should be marked as non client.
1163 const ui::PointerEvent press_event(ui::MouseEvent( 1163 const ui::PointerEvent press_event(ui::MouseEvent(
1164 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), 1164 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6),
1165 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1165 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1166 event_dispatcher()->ProcessEvent(press_event); 1166 event_dispatcher()->ProcessEvent(press_event);
1167 1167
1168 // Events should target child and be in the client area. 1168 // Events should target child and be in the client area.
1169 std::unique_ptr<DispatchedEventDetails> details = 1169 std::unique_ptr<DispatchedEventDetails> details =
1170 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 1170 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
1171 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 1171 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
1172 ASSERT_EQ(root, details->window); 1172 ASSERT_EQ(root, details->window);
1173 EXPECT_TRUE(details->in_nonclient_area); 1173 EXPECT_TRUE(details->in_nonclient_area);
1174 } 1174 }
1175 1175
1176 TEST_F(EventDispatcherTest, ProcessPointerEvents) { 1176 TEST_F(EventDispatcherTest, ProcessPointerEvents) {
1177 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 1177 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
1178 1178
1179 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1179 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1180 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 1180 child->SetBounds(gfx::Rect(10, 10, 20, 20));
1181 1181
1182 { 1182 {
1183 const ui::PointerEvent pointer_event(ui::MouseEvent( 1183 const ui::PointerEvent pointer_event(ui::MouseEvent(
1184 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), 1184 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25),
1185 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1185 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1186 event_dispatcher()->ProcessEvent(pointer_event); 1186 event_dispatcher()->ProcessEvent(pointer_event);
1187 1187
1188 std::unique_ptr<DispatchedEventDetails> details = 1188 std::unique_ptr<DispatchedEventDetails> details =
1189 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1189 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1190 ASSERT_TRUE(details); 1190 ASSERT_TRUE(details);
1191 ASSERT_EQ(child.get(), details->window); 1191 ASSERT_EQ(child.get(), details->window);
1192 1192
1193 ASSERT_TRUE(details->event); 1193 ASSERT_TRUE(details->event);
1194 ASSERT_TRUE(details->event->IsPointerEvent()); 1194 ASSERT_TRUE(details->event->IsPointerEvent());
1195 1195
1196 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); 1196 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent();
1197 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location()); 1197 EXPECT_EQ(gfx::Point(20, 25), dispatched_event->root_location());
1198 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location()); 1198 EXPECT_EQ(gfx::Point(10, 15), dispatched_event->location());
1199 } 1199 }
1200 1200
1201 { 1201 {
1202 const int touch_id = 3; 1202 const int touch_id = 3;
1203 const ui::PointerEvent pointer_event( 1203 const ui::PointerEvent pointer_event(
1204 ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(25, 20), touch_id, 1204 ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(25, 20), touch_id,
1205 base::TimeDelta())); 1205 base::TimeTicks()));
1206 event_dispatcher()->ProcessEvent(pointer_event); 1206 event_dispatcher()->ProcessEvent(pointer_event);
1207 1207
1208 std::unique_ptr<DispatchedEventDetails> details = 1208 std::unique_ptr<DispatchedEventDetails> details =
1209 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1209 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1210 ASSERT_TRUE(details); 1210 ASSERT_TRUE(details);
1211 ASSERT_EQ(child.get(), details->window); 1211 ASSERT_EQ(child.get(), details->window);
1212 1212
1213 ASSERT_TRUE(details->event); 1213 ASSERT_TRUE(details->event);
1214 ASSERT_TRUE(details->event->IsPointerEvent()); 1214 ASSERT_TRUE(details->event->IsPointerEvent());
1215 1215
1216 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); 1216 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent();
1217 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); 1217 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location());
1218 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); 1218 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location());
1219 EXPECT_EQ(touch_id, dispatched_event->pointer_id()); 1219 EXPECT_EQ(touch_id, dispatched_event->pointer_id());
1220 } 1220 }
1221 } 1221 }
1222 1222
1223 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { 1223 TEST_F(EventDispatcherTest, ResetClearsPointerDown) {
1224 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); 1224 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
1225 1225
1226 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1226 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1227 child->SetBounds(gfx::Rect(10, 10, 20, 20)); 1227 child->SetBounds(gfx::Rect(10, 10, 20, 20));
1228 1228
1229 // Send event that is over child. 1229 // Send event that is over child.
1230 const ui::PointerEvent ui_event(ui::MouseEvent( 1230 const ui::PointerEvent ui_event(ui::MouseEvent(
1231 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), 1231 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25),
1232 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1232 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1233 event_dispatcher()->ProcessEvent(ui_event); 1233 event_dispatcher()->ProcessEvent(ui_event);
1234 1234
1235 std::unique_ptr<DispatchedEventDetails> details = 1235 std::unique_ptr<DispatchedEventDetails> details =
1236 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1236 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1237 ASSERT_TRUE(details); 1237 ASSERT_TRUE(details);
1238 ASSERT_EQ(child.get(), details->window); 1238 ASSERT_EQ(child.get(), details->window);
1239 1239
1240 EXPECT_TRUE(AreAnyPointersDown()); 1240 EXPECT_TRUE(AreAnyPointersDown());
1241 1241
1242 event_dispatcher()->Reset(); 1242 event_dispatcher()->Reset();
(...skipping 22 matching lines...) Expand all
1265 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1265 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1266 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 1266 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1267 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); 1267 w2->SetBounds(gfx::Rect(50, 10, 10, 10));
1268 1268
1269 w1->AddTransientWindow(w2.get()); 1269 w1->AddTransientWindow(w2.get());
1270 w2->SetModal(); 1270 w2->SetModal();
1271 1271
1272 // Send event that is over |w1|. 1272 // Send event that is over |w1|.
1273 const ui::PointerEvent mouse_pressed(ui::MouseEvent( 1273 const ui::PointerEvent mouse_pressed(ui::MouseEvent(
1274 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), 1274 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15),
1275 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1275 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1276 event_dispatcher()->ProcessEvent(mouse_pressed); 1276 event_dispatcher()->ProcessEvent(mouse_pressed);
1277 1277
1278 std::unique_ptr<DispatchedEventDetails> details = 1278 std::unique_ptr<DispatchedEventDetails> details =
1279 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1279 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1280 ASSERT_TRUE(details); 1280 ASSERT_TRUE(details);
1281 EXPECT_EQ(w2.get(), details->window); 1281 EXPECT_EQ(w2.get(), details->window);
1282 EXPECT_TRUE(details->in_nonclient_area); 1282 EXPECT_TRUE(details->in_nonclient_area);
1283 1283
1284 ASSERT_TRUE(details->event); 1284 ASSERT_TRUE(details->event);
1285 ASSERT_TRUE(details->event->IsPointerEvent()); 1285 ASSERT_TRUE(details->event->IsPointerEvent());
(...skipping 11 matching lines...) Expand all
1297 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1297 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1298 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 1298 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1299 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); 1299 w2->SetBounds(gfx::Rect(50, 10, 10, 10));
1300 1300
1301 w1->AddTransientWindow(w2.get()); 1301 w1->AddTransientWindow(w2.get());
1302 w2->SetModal(); 1302 w2->SetModal();
1303 1303
1304 // Send event that is over |w2|. 1304 // Send event that is over |w2|.
1305 const ui::PointerEvent mouse_pressed(ui::MouseEvent( 1305 const ui::PointerEvent mouse_pressed(ui::MouseEvent(
1306 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), 1306 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15),
1307 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1307 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1308 event_dispatcher()->ProcessEvent(mouse_pressed); 1308 event_dispatcher()->ProcessEvent(mouse_pressed);
1309 1309
1310 std::unique_ptr<DispatchedEventDetails> details = 1310 std::unique_ptr<DispatchedEventDetails> details =
1311 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1311 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1312 ASSERT_TRUE(details); 1312 ASSERT_TRUE(details);
1313 EXPECT_EQ(w2.get(), details->window); 1313 EXPECT_EQ(w2.get(), details->window);
1314 EXPECT_FALSE(details->in_nonclient_area); 1314 EXPECT_FALSE(details->in_nonclient_area);
1315 1315
1316 ASSERT_TRUE(details->event); 1316 ASSERT_TRUE(details->event);
1317 ASSERT_TRUE(details->event->IsPointerEvent()); 1317 ASSERT_TRUE(details->event->IsPointerEvent());
(...skipping 14 matching lines...) Expand all
1332 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 1332 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1333 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); 1333 w2->SetBounds(gfx::Rect(50, 10, 10, 10));
1334 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); 1334 w3->SetBounds(gfx::Rect(70, 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 |w3|. 1339 // Send event that is over |w3|.
1340 const ui::PointerEvent mouse_pressed(ui::MouseEvent( 1340 const ui::PointerEvent mouse_pressed(ui::MouseEvent(
1341 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), 1341 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15),
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(w3.get(), details->window); 1348 EXPECT_EQ(w3.get(), details->window);
1349 EXPECT_FALSE(details->in_nonclient_area); 1349 EXPECT_FALSE(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());
(...skipping 15 matching lines...) Expand all
1368 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 1368 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1369 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); 1369 w11->SetBounds(gfx::Rect(10, 10, 10, 10));
1370 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); 1370 w2->SetBounds(gfx::Rect(50, 10, 10, 10));
1371 1371
1372 w1->AddTransientWindow(w2.get()); 1372 w1->AddTransientWindow(w2.get());
1373 w2->SetModal(); 1373 w2->SetModal();
1374 1374
1375 // Send event that is over |w11|. 1375 // Send event that is over |w11|.
1376 const ui::PointerEvent mouse_pressed(ui::MouseEvent( 1376 const ui::PointerEvent mouse_pressed(ui::MouseEvent(
1377 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), 1377 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25),
1378 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1378 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1379 event_dispatcher()->ProcessEvent(mouse_pressed); 1379 event_dispatcher()->ProcessEvent(mouse_pressed);
1380 1380
1381 std::unique_ptr<DispatchedEventDetails> details = 1381 std::unique_ptr<DispatchedEventDetails> details =
1382 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1382 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1383 ASSERT_TRUE(details); 1383 ASSERT_TRUE(details);
1384 EXPECT_EQ(w2.get(), details->window); 1384 EXPECT_EQ(w2.get(), details->window);
1385 EXPECT_TRUE(details->in_nonclient_area); 1385 EXPECT_TRUE(details->in_nonclient_area);
1386 1386
1387 ASSERT_TRUE(details->event); 1387 ASSERT_TRUE(details->event);
1388 ASSERT_TRUE(details->event->IsPointerEvent()); 1388 ASSERT_TRUE(details->event->IsPointerEvent());
1389 1389
1390 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); 1390 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent();
1391 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); 1391 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location());
1392 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); 1392 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location());
1393 } 1393 }
1394 1394
1395 // Tests that events on a system modal window target the modal window itself. 1395 // Tests that events on a system modal window target the modal window itself.
1396 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { 1396 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) {
1397 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); 1397 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3));
1398 1398
1399 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1399 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1400 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 1400 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1401 w1->SetModal(); 1401 w1->SetModal();
1402 1402
1403 // Send event that is over |w1|. 1403 // Send event that is over |w1|.
1404 const ui::PointerEvent mouse_pressed(ui::MouseEvent( 1404 const ui::PointerEvent mouse_pressed(ui::MouseEvent(
1405 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), 1405 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15),
1406 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1406 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1407 event_dispatcher()->ProcessEvent(mouse_pressed); 1407 event_dispatcher()->ProcessEvent(mouse_pressed);
1408 1408
1409 std::unique_ptr<DispatchedEventDetails> details = 1409 std::unique_ptr<DispatchedEventDetails> details =
1410 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1410 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1411 ASSERT_TRUE(details); 1411 ASSERT_TRUE(details);
1412 EXPECT_EQ(w1.get(), details->window); 1412 EXPECT_EQ(w1.get(), details->window);
1413 EXPECT_FALSE(details->in_nonclient_area); 1413 EXPECT_FALSE(details->in_nonclient_area);
1414 1414
1415 ASSERT_TRUE(details->event); 1415 ASSERT_TRUE(details->event);
1416 ASSERT_TRUE(details->event->IsPointerEvent()); 1416 ASSERT_TRUE(details->event->IsPointerEvent());
1417 1417
1418 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); 1418 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent();
1419 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); 1419 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location());
1420 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); 1420 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location());
1421 } 1421 }
1422 1422
1423 // Tests that events outside of system modal window target the modal window. 1423 // Tests that events outside of system modal window target the modal window.
1424 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { 1424 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) {
1425 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); 1425 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3));
1426 1426
1427 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1427 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1428 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); 1428 w1->SetBounds(gfx::Rect(10, 10, 30, 30));
1429 w1->SetModal(); 1429 w1->SetModal();
1430 event_dispatcher()->AddSystemModalWindow(w1.get()); 1430 event_dispatcher()->AddSystemModalWindow(w1.get());
1431 1431
1432 // Send event that is over |w1|. 1432 // Send event that is over |w1|.
1433 const ui::PointerEvent mouse_pressed(ui::MouseEvent( 1433 const ui::PointerEvent mouse_pressed(ui::MouseEvent(
1434 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), 1434 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15),
1435 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1435 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1436 event_dispatcher()->ProcessEvent(mouse_pressed); 1436 event_dispatcher()->ProcessEvent(mouse_pressed);
1437 1437
1438 std::unique_ptr<DispatchedEventDetails> details = 1438 std::unique_ptr<DispatchedEventDetails> details =
1439 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1439 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1440 ASSERT_TRUE(details); 1440 ASSERT_TRUE(details);
1441 EXPECT_EQ(w1.get(), details->window); 1441 EXPECT_EQ(w1.get(), details->window);
1442 EXPECT_TRUE(details->in_nonclient_area); 1442 EXPECT_TRUE(details->in_nonclient_area);
1443 1443
1444 ASSERT_TRUE(details->event); 1444 ASSERT_TRUE(details->event);
1445 ASSERT_TRUE(details->event->IsPointerEvent()); 1445 ASSERT_TRUE(details->event->IsPointerEvent());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 DisableHitTest(w2.get()); 1553 DisableHitTest(w2.get());
1554 1554
1555 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 1555 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
1556 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1556 w1->SetBounds(gfx::Rect(0, 0, 100, 100));
1557 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); 1557 w11->SetBounds(gfx::Rect(10, 10, 10, 10));
1558 w2->SetBounds(gfx::Rect(0, 0, 100, 100)); 1558 w2->SetBounds(gfx::Rect(0, 0, 100, 100));
1559 1559
1560 // Send event that is over |w11|. 1560 // Send event that is over |w11|.
1561 const ui::PointerEvent mouse_pressed(ui::MouseEvent( 1561 const ui::PointerEvent mouse_pressed(ui::MouseEvent(
1562 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), 1562 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15),
1563 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 1563 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
1564 event_dispatcher()->ProcessEvent(mouse_pressed); 1564 event_dispatcher()->ProcessEvent(mouse_pressed);
1565 event_dispatcher()->SetCaptureWindow(w11.get(), false); 1565 event_dispatcher()->SetCaptureWindow(w11.get(), false);
1566 1566
1567 std::unique_ptr<DispatchedEventDetails> details = 1567 std::unique_ptr<DispatchedEventDetails> details =
1568 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); 1568 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
1569 ASSERT_TRUE(details); 1569 ASSERT_TRUE(details);
1570 EXPECT_EQ(w11.get(), details->window); 1570 EXPECT_EQ(w11.get(), details->window);
1571 EXPECT_FALSE(details->in_nonclient_area); 1571 EXPECT_FALSE(details->in_nonclient_area);
1572 1572
1573 // Move |w11| to |w2| and verify the mouse is still down, and |w11| has 1573 // Move |w11| to |w2| and verify the mouse is still down, and |w11| has
1574 // capture. 1574 // capture.
1575 w2->Add(w11.get()); 1575 w2->Add(w11.get());
1576 EXPECT_TRUE(IsMouseButtonDown()); 1576 EXPECT_TRUE(IsMouseButtonDown());
1577 EXPECT_EQ(w11.get(), 1577 EXPECT_EQ(w11.get(),
1578 EventDispatcherTestApi(event_dispatcher()).capture_window()); 1578 EventDispatcherTestApi(event_dispatcher()).capture_window());
1579 } 1579 }
1580 1580
1581 } // namespace test 1581 } // namespace test
1582 } // namespace ws 1582 } // namespace ws
1583 } // namespace mus 1583 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/display_unittest.cc ('k') | components/mus/ws/event_matcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698