Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "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 14 matching lines...) Expand all Loading... | |
| 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/window.h" | 34 #include "ui/aura/window.h" |
| 35 #include "ui/aura/window_targeter.h" | |
| 35 #include "ui/aura/window_tracker.h" | 36 #include "ui/aura/window_tracker.h" |
| 36 #include "ui/aura/window_tree_host_observer.h" | 37 #include "ui/aura/window_tree_host_observer.h" |
| 37 #include "ui/base/class_property.h" | 38 #include "ui/base/class_property.h" |
| 38 #include "ui/compositor/compositor.h" | 39 #include "ui/compositor/compositor.h" |
| 39 #include "ui/display/display.h" | 40 #include "ui/display/display.h" |
| 40 #include "ui/display/display_switches.h" | 41 #include "ui/display/display_switches.h" |
| 41 #include "ui/display/screen.h" | 42 #include "ui/display/screen.h" |
| 42 #include "ui/events/event.h" | 43 #include "ui/events/event.h" |
| 43 #include "ui/events/event_utils.h" | 44 #include "ui/events/event_utils.h" |
| 44 #include "ui/gfx/geometry/dip_util.h" | 45 #include "ui/gfx/geometry/dip_util.h" |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 EXPECT_TRUE(window_tree()->WasEventAcked( | 551 EXPECT_TRUE(window_tree()->WasEventAcked( |
| 551 InputEventBasicTestWindowDelegate::kEventId)); | 552 InputEventBasicTestWindowDelegate::kEventId)); |
| 552 EXPECT_EQ(ui::mojom::EventResult::HANDLED, | 553 EXPECT_EQ(ui::mojom::EventResult::HANDLED, |
| 553 window_tree()->GetEventResult( | 554 window_tree()->GetEventResult( |
| 554 InputEventBasicTestWindowDelegate::kEventId)); | 555 InputEventBasicTestWindowDelegate::kEventId)); |
| 555 EXPECT_TRUE(window_delegate.got_move()); | 556 EXPECT_TRUE(window_delegate.got_move()); |
| 556 EXPECT_FALSE(window_delegate.was_acked()); | 557 EXPECT_FALSE(window_delegate.was_acked()); |
| 557 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); | 558 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); |
| 558 } | 559 } |
| 559 | 560 |
| 561 TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) { | |
| 562 InputEventBasicTestWindowDelegate window_delegate(window_tree()); | |
| 563 WindowTreeHostMus window_tree_host(window_tree_client_impl()); | |
| 564 Window* top_level = window_tree_host.window(); | |
| 565 const gfx::Rect bounds(0, 0, 100, 100); | |
| 566 window_tree_host.SetBoundsInPixels(bounds); | |
| 567 window_tree_host.InitHost(); | |
| 568 window_tree_host.Show(); | |
| 569 EXPECT_EQ(bounds, top_level->bounds()); | |
| 570 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); | |
| 571 Window child1(&window_delegate); | |
| 572 child1.Init(ui::LAYER_NOT_DRAWN); | |
| 573 child1.SetEventTargeter(base::MakeUnique<WindowTargeter>()); | |
| 574 top_level->AddChild(&child1); | |
| 575 child1.SetBounds(gfx::Rect(10, 10, 100, 100)); | |
| 576 child1.Show(); | |
| 577 Window child2(&window_delegate); | |
|
sadrul
2017/02/13 17:05:42
Can you use a different WindowDelegate here, and u
riajiang
2017/02/13 23:30:34
Done.
| |
| 578 child2.Init(ui::LAYER_NOT_DRAWN); | |
| 579 child1.AddChild(&child2); | |
| 580 child2.SetBounds(gfx::Rect(20, 30, 100, 100)); | |
| 581 child2.Show(); | |
| 582 | |
| 583 EXPECT_FALSE(window_delegate.got_move()); | |
| 584 EXPECT_FALSE(window_delegate.was_acked()); | |
| 585 const gfx::Point event_location_in_child2(50, 60); | |
| 586 std::unique_ptr<ui::Event> ui_event( | |
| 587 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child2, | |
| 588 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0)); | |
| 589 window_tree_client()->OnWindowInputEvent( | |
| 590 InputEventBasicTestWindowDelegate::kEventId, server_id(&child1), | |
| 591 window_tree_host.display_id(), ui::Event::Clone(*ui_event.get()), 0); | |
| 592 EXPECT_TRUE(window_tree()->WasEventAcked( | |
| 593 InputEventBasicTestWindowDelegate::kEventId)); | |
| 594 EXPECT_EQ(ui::mojom::EventResult::HANDLED, | |
| 595 window_tree()->GetEventResult( | |
| 596 InputEventBasicTestWindowDelegate::kEventId)); | |
| 597 EXPECT_TRUE(window_delegate.got_move()); | |
| 598 EXPECT_FALSE(window_delegate.was_acked()); | |
| 599 EXPECT_EQ(gfx::Point(30, 30), window_delegate.last_event_location()); | |
| 600 } | |
| 601 | |
| 560 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { | 602 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { |
| 561 public: | 603 public: |
| 562 WindowTreeClientPointerObserverTest() {} | 604 WindowTreeClientPointerObserverTest() {} |
| 563 ~WindowTreeClientPointerObserverTest() override {} | 605 ~WindowTreeClientPointerObserverTest() override {} |
| 564 | 606 |
| 565 void DeleteLastEventObserved() { last_event_observed_.reset(); } | 607 void DeleteLastEventObserved() { last_event_observed_.reset(); } |
| 566 const ui::PointerEvent* last_event_observed() const { | 608 const ui::PointerEvent* last_event_observed() const { |
| 567 return last_event_observed_.get(); | 609 return last_event_observed_.get(); |
| 568 } | 610 } |
| 569 | 611 |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 // Delegate received the event in Dips. | 1658 // Delegate received the event in Dips. |
| 1617 const ui::PointerEvent* last_event = last_event_observed(); | 1659 const ui::PointerEvent* last_event = last_event_observed(); |
| 1618 ASSERT_TRUE(last_event); | 1660 ASSERT_TRUE(last_event); |
| 1619 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels), | 1661 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels), |
| 1620 last_event->location()); | 1662 last_event->location()); |
| 1621 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels), | 1663 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels), |
| 1622 last_event->root_location()); | 1664 last_event->root_location()); |
| 1623 } | 1665 } |
| 1624 | 1666 |
| 1625 } // namespace aura | 1667 } // namespace aura |
| OLD | NEW |