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

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2715743005: Revert of Avoid two targeting phases in aura client-lib and EventProcessor. (Closed)
Patch Set: Created 3 years, 9 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 | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/aura_test_helper.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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/aura/mus/capture_synchronizer.h" 24 #include "ui/aura/mus/capture_synchronizer.h"
25 #include "ui/aura/mus/property_converter.h" 25 #include "ui/aura/mus/property_converter.h"
26 #include "ui/aura/mus/window_mus.h" 26 #include "ui/aura/mus/window_mus.h"
27 #include "ui/aura/mus/window_tree_client_delegate.h" 27 #include "ui/aura/mus/window_tree_client_delegate.h"
28 #include "ui/aura/mus/window_tree_client_observer.h" 28 #include "ui/aura/mus/window_tree_client_observer.h"
29 #include "ui/aura/mus/window_tree_host_mus.h" 29 #include "ui/aura/mus/window_tree_host_mus.h"
30 #include "ui/aura/test/aura_mus_test_base.h" 30 #include "ui/aura/test/aura_mus_test_base.h"
31 #include "ui/aura/test/mus/test_window_tree.h" 31 #include "ui/aura/test/mus/test_window_tree.h"
32 #include "ui/aura/test/mus/window_tree_client_private.h" 32 #include "ui/aura/test/mus/window_tree_client_private.h"
33 #include "ui/aura/test/test_window_delegate.h" 33 #include "ui/aura/test/test_window_delegate.h"
34 #include "ui/aura/test/test_window_targeter.h"
35 #include "ui/aura/window.h" 34 #include "ui/aura/window.h"
36 #include "ui/aura/window_targeter.h"
37 #include "ui/aura/window_tracker.h" 35 #include "ui/aura/window_tracker.h"
38 #include "ui/aura/window_tree_host_observer.h" 36 #include "ui/aura/window_tree_host_observer.h"
39 #include "ui/base/class_property.h" 37 #include "ui/base/class_property.h"
40 #include "ui/compositor/compositor.h" 38 #include "ui/compositor/compositor.h"
41 #include "ui/display/display.h" 39 #include "ui/display/display.h"
42 #include "ui/display/display_switches.h" 40 #include "ui/display/display_switches.h"
43 #include "ui/display/screen.h" 41 #include "ui/display/screen.h"
44 #include "ui/events/event.h" 42 #include "ui/events/event.h"
45 #include "ui/events/event_utils.h" 43 #include "ui/events/event_utils.h"
46 #include "ui/gfx/geometry/dip_util.h" 44 #include "ui/gfx/geometry/dip_util.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // Simulate server changing back to original visible. Should take immediately. 486 // Simulate server changing back to original visible. Should take immediately.
489 window_tree_client()->OnWindowVisibilityChanged(server_id(root_window()), 487 window_tree_client()->OnWindowVisibilityChanged(server_id(root_window()),
490 original_visible); 488 original_visible);
491 EXPECT_EQ(original_visible, root_window()->TargetVisibility()); 489 EXPECT_EQ(original_visible, root_window()->TargetVisibility());
492 } 490 }
493 491
494 namespace { 492 namespace {
495 493
496 class InputEventBasicTestWindowDelegate : public test::TestWindowDelegate { 494 class InputEventBasicTestWindowDelegate : public test::TestWindowDelegate {
497 public: 495 public:
496 static uint32_t constexpr kEventId = 1;
497
498 explicit InputEventBasicTestWindowDelegate(TestWindowTree* test_window_tree) 498 explicit InputEventBasicTestWindowDelegate(TestWindowTree* test_window_tree)
499 : test_window_tree_(test_window_tree) {} 499 : test_window_tree_(test_window_tree) {}
500 ~InputEventBasicTestWindowDelegate() override {} 500 ~InputEventBasicTestWindowDelegate() override {}
501 501
502 bool got_move() const { return got_move_; } 502 bool got_move() const { return got_move_; }
503 bool was_acked() const { return was_acked_; } 503 bool was_acked() const { return was_acked_; }
504 const gfx::Point& last_event_location() const { return last_event_location_; } 504 const gfx::Point& last_event_location() const { return last_event_location_; }
505 void set_event_id(uint32_t event_id) { event_id_ = event_id; }
506 505
507 // TestWindowDelegate:: 506 // TestWindowDelegate::
508 void OnMouseEvent(ui::MouseEvent* event) override { 507 void OnMouseEvent(ui::MouseEvent* event) override {
509 was_acked_ = test_window_tree_->WasEventAcked(event_id_); 508 was_acked_ = test_window_tree_->WasEventAcked(kEventId);
510 if (event->type() == ui::ET_MOUSE_MOVED) 509 if (event->type() == ui::ET_MOUSE_MOVED)
511 got_move_ = true; 510 got_move_ = true;
512 last_event_location_ = event->location(); 511 last_event_location_ = event->location();
513 event->SetHandled(); 512 event->SetHandled();
514 } 513 }
515 514
516 void reset() {
517 was_acked_ = false;
518 got_move_ = false;
519 last_event_location_ = gfx::Point();
520 event_id_ = 0;
521 }
522
523 private: 515 private:
524 TestWindowTree* test_window_tree_; 516 TestWindowTree* test_window_tree_;
525 bool was_acked_ = false; 517 bool was_acked_ = false;
526 bool got_move_ = false; 518 bool got_move_ = false;
527 gfx::Point last_event_location_; 519 gfx::Point last_event_location_;
528 uint32_t event_id_ = 0;
529 520
530 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate); 521 DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate);
531 }; 522 };
532 523
533 } // namespace 524 } // namespace
534 525
535 TEST_F(WindowTreeClientClientTest, InputEventBasic) { 526 TEST_F(WindowTreeClientClientTest, InputEventBasic) {
536 InputEventBasicTestWindowDelegate window_delegate(window_tree()); 527 InputEventBasicTestWindowDelegate window_delegate(window_tree());
537 WindowTreeHostMus window_tree_host(window_tree_client_impl()); 528 WindowTreeHostMus window_tree_host(window_tree_client_impl());
538 Window* top_level = window_tree_host.window(); 529 Window* top_level = window_tree_host.window();
539 const gfx::Rect bounds(0, 0, 100, 100); 530 const gfx::Rect bounds(0, 0, 100, 100);
540 window_tree_host.SetBoundsInPixels(bounds); 531 window_tree_host.SetBoundsInPixels(bounds);
541 window_tree_host.InitHost(); 532 window_tree_host.InitHost();
542 window_tree_host.Show(); 533 window_tree_host.Show();
543 EXPECT_EQ(bounds, top_level->bounds()); 534 EXPECT_EQ(bounds, top_level->bounds());
544 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); 535 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
545 Window child(&window_delegate); 536 Window child(&window_delegate);
546 child.Init(ui::LAYER_NOT_DRAWN); 537 child.Init(ui::LAYER_NOT_DRAWN);
547 top_level->AddChild(&child); 538 top_level->AddChild(&child);
548 child.SetBounds(gfx::Rect(10, 10, 100, 100)); 539 child.SetBounds(gfx::Rect(10, 10, 100, 100));
549 child.Show(); 540 child.Show();
550 EXPECT_FALSE(window_delegate.got_move()); 541 EXPECT_FALSE(window_delegate.got_move());
551 EXPECT_FALSE(window_delegate.was_acked()); 542 EXPECT_FALSE(window_delegate.was_acked());
552 const gfx::Point event_location_in_child(2, 3); 543 const gfx::Point event_location_in_child(2, 3);
553 const uint32_t event_id = 1;
554 window_delegate.set_event_id(event_id);
555 std::unique_ptr<ui::Event> ui_event( 544 std::unique_ptr<ui::Event> ui_event(
556 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child, 545 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child,
557 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0)); 546 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0));
558 window_tree_client()->OnWindowInputEvent( 547 window_tree_client()->OnWindowInputEvent(
559 event_id, server_id(&child), window_tree_host.display_id(), 548 InputEventBasicTestWindowDelegate::kEventId, server_id(&child),
560 ui::Event::Clone(*ui_event.get()), 0); 549 window_tree_host.display_id(), ui::Event::Clone(*ui_event.get()), 0);
561 EXPECT_TRUE(window_tree()->WasEventAcked(event_id)); 550 EXPECT_TRUE(window_tree()->WasEventAcked(
551 InputEventBasicTestWindowDelegate::kEventId));
562 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 552 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
563 window_tree()->GetEventResult(event_id)); 553 window_tree()->GetEventResult(
554 InputEventBasicTestWindowDelegate::kEventId));
564 EXPECT_TRUE(window_delegate.got_move()); 555 EXPECT_TRUE(window_delegate.got_move());
565 EXPECT_FALSE(window_delegate.was_acked()); 556 EXPECT_FALSE(window_delegate.was_acked());
566 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); 557 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location());
567 } 558 }
568 559
569 TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) {
570 WindowTreeHostMus window_tree_host(window_tree_client_impl());
571 Window* top_level = window_tree_host.window();
572 const gfx::Rect bounds(0, 0, 100, 100);
573 window_tree_host.SetBoundsInPixels(bounds);
574 window_tree_host.InitHost();
575 window_tree_host.Show();
576 EXPECT_EQ(bounds, top_level->bounds());
577 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
578 InputEventBasicTestWindowDelegate window_delegate1(window_tree());
579 Window child1(&window_delegate1);
580 child1.Init(ui::LAYER_NOT_DRAWN);
581 child1.SetEventTargeter(base::MakeUnique<WindowTargeter>());
582 top_level->AddChild(&child1);
583 child1.SetBounds(gfx::Rect(10, 10, 100, 100));
584 child1.Show();
585 InputEventBasicTestWindowDelegate window_delegate2(window_tree());
586 Window child2(&window_delegate2);
587 child2.Init(ui::LAYER_NOT_DRAWN);
588 child1.AddChild(&child2);
589 child2.SetBounds(gfx::Rect(20, 30, 100, 100));
590 child2.Show();
591
592 EXPECT_FALSE(window_delegate1.got_move());
593 EXPECT_FALSE(window_delegate2.got_move());
594
595 // child1 has a targeter set and event_location is (50, 60), child2
596 // should get the event even though mus-ws wants to send to child1.
597 const gfx::Point event_location(50, 60);
598 uint32_t event_id = 1;
599 window_delegate1.set_event_id(event_id);
600 window_delegate2.set_event_id(event_id);
601 std::unique_ptr<ui::Event> ui_event(
602 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(),
603 ui::EventTimeForNow(), ui::EF_NONE, 0));
604 window_tree_client()->OnWindowInputEvent(
605 event_id, server_id(&child1), window_tree_host.display_id(),
606 ui::Event::Clone(*ui_event.get()), 0);
607 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
608 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
609 window_tree()->GetEventResult(event_id));
610 EXPECT_FALSE(window_delegate1.got_move());
611 EXPECT_TRUE(window_delegate2.got_move());
612 EXPECT_EQ(gfx::Point(30, 30), window_delegate2.last_event_location());
613 window_delegate1.reset();
614 window_delegate2.reset();
615
616 // Remove the targeter for child1 and specify the event to go to child1. This
617 // time child1 should receive the event not child2.
618 child1.SetEventTargeter(nullptr);
619 event_id = 2;
620 window_delegate1.set_event_id(event_id);
621 window_delegate2.set_event_id(event_id);
622 std::unique_ptr<ui::Event> ui_event1(
623 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(),
624 ui::EventTimeForNow(), ui::EF_NONE, 0));
625 window_tree_client()->OnWindowInputEvent(
626 event_id, server_id(&child1), window_tree_host.display_id(),
627 ui::Event::Clone(*ui_event1.get()), 0);
628 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
629 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
630 window_tree()->GetEventResult(event_id));
631 EXPECT_TRUE(window_delegate1.got_move());
632 EXPECT_FALSE(window_delegate2.got_move());
633 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location());
634 }
635
636 TEST_F(WindowTreeClientClientTest, InputEventCustomWindowTargeter) {
637 WindowTreeHostMus window_tree_host(window_tree_client_impl());
638 Window* top_level = window_tree_host.window();
639 const gfx::Rect bounds(0, 0, 100, 100);
640 window_tree_host.SetBoundsInPixels(bounds);
641 window_tree_host.InitHost();
642 window_tree_host.Show();
643 EXPECT_EQ(bounds, top_level->bounds());
644 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
645 InputEventBasicTestWindowDelegate window_delegate1(window_tree());
646 Window child1(&window_delegate1);
647 child1.Init(ui::LAYER_NOT_DRAWN);
648 child1.SetEventTargeter(base::MakeUnique<test::TestWindowTargeter>());
649 top_level->AddChild(&child1);
650 child1.SetBounds(gfx::Rect(10, 10, 100, 100));
651 child1.Show();
652 InputEventBasicTestWindowDelegate window_delegate2(window_tree());
653 Window child2(&window_delegate2);
654 child2.Init(ui::LAYER_NOT_DRAWN);
655 child1.AddChild(&child2);
656 child2.SetBounds(gfx::Rect(20, 30, 100, 100));
657 child2.Show();
658
659 EXPECT_FALSE(window_delegate1.got_move());
660 EXPECT_FALSE(window_delegate2.got_move());
661
662 // child1 has a custom targeter set which would always return itself as the
663 // target window therefore event should go to child1 unlike
664 // WindowTreeClientClientTest.InputEventFindTargetAndConversion.
665 const gfx::Point event_location(50, 60);
666 uint32_t event_id = 1;
667 window_delegate1.set_event_id(event_id);
668 window_delegate2.set_event_id(event_id);
669 std::unique_ptr<ui::Event> ui_event(
670 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(),
671 ui::EventTimeForNow(), ui::EF_NONE, 0));
672 window_tree_client()->OnWindowInputEvent(
673 event_id, server_id(&child1), window_tree_host.display_id(),
674 ui::Event::Clone(*ui_event.get()), 0);
675 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
676 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
677 window_tree()->GetEventResult(event_id));
678 EXPECT_TRUE(window_delegate1.got_move());
679 EXPECT_FALSE(window_delegate2.got_move());
680 EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location());
681 window_delegate1.reset();
682 window_delegate2.reset();
683
684 // child1 should get the event even though mus-ws specifies child2 and it's
685 // actually in child2's space. Event location will be transformed.
686 event_id = 2;
687 window_delegate1.set_event_id(event_id);
688 window_delegate2.set_event_id(event_id);
689 window_tree_client()->OnWindowInputEvent(
690 event_id, server_id(&child2), window_tree_host.display_id(),
691 ui::Event::Clone(*ui_event.get()), 0);
692 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
693 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
694 window_tree()->GetEventResult(event_id));
695 EXPECT_TRUE(window_delegate1.got_move());
696 EXPECT_FALSE(window_delegate2.got_move());
697 EXPECT_EQ(gfx::Point(70, 90), window_delegate1.last_event_location());
698 }
699
700 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { 560 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest {
701 public: 561 public:
702 WindowTreeClientPointerObserverTest() {} 562 WindowTreeClientPointerObserverTest() {}
703 ~WindowTreeClientPointerObserverTest() override {} 563 ~WindowTreeClientPointerObserverTest() override {}
704 564
705 void DeleteLastEventObserved() { last_event_observed_.reset(); } 565 void DeleteLastEventObserved() { last_event_observed_.reset(); }
706 const ui::PointerEvent* last_event_observed() const { 566 const ui::PointerEvent* last_event_observed() const {
707 return last_event_observed_.get(); 567 return last_event_observed_.get();
708 } 568 }
709 569
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id)); 1581 WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
1722 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), 1582 window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
1723 display_id, true); 1583 display_id, true);
1724 1584
1725 // aura::Window should operate in DIP and aura::WindowTreeHost should operate 1585 // aura::Window should operate in DIP and aura::WindowTreeHost should operate
1726 // in pixels. 1586 // in pixels.
1727 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); 1587 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
1728 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); 1588 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels());
1729 } 1589 }
1730 1590
1731 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) { 1591 TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDips) {
1732 display::Screen* screen = display::Screen::GetScreen(); 1592 display::Screen* screen = display::Screen::GetScreen();
1733 const display::Display primary_display = screen->GetPrimaryDisplay(); 1593 const display::Display primary_display = screen->GetPrimaryDisplay();
1734 ASSERT_EQ(2.0f, primary_display.device_scale_factor()); 1594 ASSERT_EQ(2.0f, primary_display.device_scale_factor());
1735 1595
1736 std::unique_ptr<Window> top_level(base::MakeUnique<Window>(nullptr)); 1596 std::unique_ptr<Window> top_level(base::MakeUnique<Window>(nullptr));
1737 top_level->SetType(ui::wm::WINDOW_TYPE_NORMAL); 1597 top_level->SetType(ui::wm::WINDOW_TYPE_NORMAL);
1738 top_level->Init(ui::LAYER_NOT_DRAWN); 1598 top_level->Init(ui::LAYER_NOT_DRAWN);
1739 top_level->SetBounds(gfx::Rect(0, 0, 100, 100)); 1599 top_level->SetBounds(gfx::Rect(0, 0, 100, 100));
1740 top_level->Show(); 1600 top_level->Show();
1741 1601
(...skipping 13 matching lines...) Expand all
1755 1615
1756 // Delegate received the event in Dips. 1616 // Delegate received the event in Dips.
1757 const ui::PointerEvent* last_event = last_event_observed(); 1617 const ui::PointerEvent* last_event = last_event_observed();
1758 ASSERT_TRUE(last_event); 1618 ASSERT_TRUE(last_event);
1759 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels), 1619 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels),
1760 last_event->location()); 1620 last_event->location());
1761 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels), 1621 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels),
1762 last_event->root_location()); 1622 last_event->root_location());
1763 } 1623 }
1764 1624
1765 TEST_F(WindowTreeClientClientTestHighDPI, InputEventsInDip) {
1766 WindowTreeHostMus window_tree_host(window_tree_client_impl());
1767 display::Screen* screen = display::Screen::GetScreen();
1768 display::Display display;
1769 ASSERT_TRUE(
1770 screen->GetDisplayWithDisplayId(window_tree_host.display_id(), &display));
1771 ASSERT_EQ(2.0f, display.device_scale_factor());
1772
1773 Window* top_level = window_tree_host.window();
1774 const gfx::Rect bounds_in_pixels(0, 0, 100, 100);
1775 window_tree_host.SetBoundsInPixels(bounds_in_pixels);
1776 window_tree_host.InitHost();
1777 window_tree_host.Show();
1778 EXPECT_EQ(gfx::ConvertRectToDIP(2.0f, bounds_in_pixels), top_level->bounds());
1779 EXPECT_EQ(bounds_in_pixels, window_tree_host.GetBoundsInPixels());
1780
1781 InputEventBasicTestWindowDelegate window_delegate1(window_tree());
1782 Window child1(&window_delegate1);
1783 child1.Init(ui::LAYER_NOT_DRAWN);
1784 child1.SetEventTargeter(base::MakeUnique<test::TestWindowTargeter>());
1785 top_level->AddChild(&child1);
1786 child1.SetBounds(gfx::Rect(10, 10, 100, 100));
1787 child1.Show();
1788 InputEventBasicTestWindowDelegate window_delegate2(window_tree());
1789 Window child2(&window_delegate2);
1790 child2.Init(ui::LAYER_NOT_DRAWN);
1791 child1.AddChild(&child2);
1792 child2.SetBounds(gfx::Rect(20, 30, 100, 100));
1793 child2.Show();
1794
1795 EXPECT_FALSE(window_delegate1.got_move());
1796 EXPECT_FALSE(window_delegate2.got_move());
1797
1798 // child1 has a custom targeter set which would always return itself as the
1799 // target window therefore event should go to child1 and should be in dip.
1800 const gfx::Point event_location_in_pixels(50, 60);
1801 uint32_t event_id = 1;
1802 window_delegate1.set_event_id(event_id);
1803 window_delegate2.set_event_id(event_id);
1804 std::unique_ptr<ui::Event> ui_event(
1805 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_pixels,
1806 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0));
1807 window_tree_client()->OnWindowInputEvent(
1808 event_id, server_id(&child1), window_tree_host.display_id(),
1809 ui::Event::Clone(*ui_event.get()), 0);
1810 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
1811 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
1812 window_tree()->GetEventResult(event_id));
1813 EXPECT_TRUE(window_delegate1.got_move());
1814 EXPECT_FALSE(window_delegate2.got_move());
1815 const gfx::Point event_location_in_dip(25, 30);
1816 EXPECT_EQ(event_location_in_dip, window_delegate1.last_event_location());
1817 window_delegate1.reset();
1818 window_delegate2.reset();
1819
1820 // Event location will be transformed and should be in dip.
1821 event_id = 2;
1822 window_delegate1.set_event_id(event_id);
1823 window_delegate2.set_event_id(event_id);
1824 window_tree_client()->OnWindowInputEvent(
1825 event_id, server_id(&child2), window_tree_host.display_id(),
1826 ui::Event::Clone(*ui_event.get()), 0);
1827 EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
1828 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
1829 window_tree()->GetEventResult(event_id));
1830 EXPECT_TRUE(window_delegate1.got_move());
1831 EXPECT_FALSE(window_delegate2.got_move());
1832 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20,
1833 event_location_in_dip.y() + 30);
1834 EXPECT_EQ(transformed_event_location_in_dip,
1835 window_delegate1.last_event_location());
1836 }
1837
1838 } // namespace aura 1625 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/aura_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698