Index: ui/aura/mus/window_tree_client_unittest.cc |
diff --git a/ui/aura/mus/window_tree_client_unittest.cc b/ui/aura/mus/window_tree_client_unittest.cc |
index 76dcf10e58846047070855359b207796cb78cc4d..2fd2fdd694136de56fc06031e253a91460ccb8df 100644 |
--- a/ui/aura/mus/window_tree_client_unittest.cc |
+++ b/ui/aura/mus/window_tree_client_unittest.cc |
@@ -32,6 +32,7 @@ |
#include "ui/aura/test/mus/window_tree_client_private.h" |
#include "ui/aura/test/test_window_delegate.h" |
#include "ui/aura/window.h" |
+#include "ui/aura/window_targeter.h" |
#include "ui/aura/window_tracker.h" |
#include "ui/aura/window_tree_host_observer.h" |
#include "ui/base/class_property.h" |
@@ -557,6 +558,47 @@ TEST_F(WindowTreeClientClientTest, InputEventBasic) { |
EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); |
} |
+TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) { |
+ InputEventBasicTestWindowDelegate window_delegate(window_tree()); |
+ WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
+ Window* top_level = window_tree_host.window(); |
+ const gfx::Rect bounds(0, 0, 100, 100); |
+ window_tree_host.SetBoundsInPixels(bounds); |
+ window_tree_host.InitHost(); |
+ window_tree_host.Show(); |
+ EXPECT_EQ(bounds, top_level->bounds()); |
+ EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels()); |
+ Window child1(&window_delegate); |
+ child1.Init(ui::LAYER_NOT_DRAWN); |
+ child1.SetEventTargeter(base::MakeUnique<WindowTargeter>()); |
+ top_level->AddChild(&child1); |
+ child1.SetBounds(gfx::Rect(10, 10, 100, 100)); |
+ child1.Show(); |
+ 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.
|
+ child2.Init(ui::LAYER_NOT_DRAWN); |
+ child1.AddChild(&child2); |
+ child2.SetBounds(gfx::Rect(20, 30, 100, 100)); |
+ child2.Show(); |
+ |
+ EXPECT_FALSE(window_delegate.got_move()); |
+ EXPECT_FALSE(window_delegate.was_acked()); |
+ const gfx::Point event_location_in_child2(50, 60); |
+ std::unique_ptr<ui::Event> ui_event( |
+ new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child2, |
+ gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0)); |
+ window_tree_client()->OnWindowInputEvent( |
+ InputEventBasicTestWindowDelegate::kEventId, server_id(&child1), |
+ window_tree_host.display_id(), ui::Event::Clone(*ui_event.get()), 0); |
+ EXPECT_TRUE(window_tree()->WasEventAcked( |
+ InputEventBasicTestWindowDelegate::kEventId)); |
+ EXPECT_EQ(ui::mojom::EventResult::HANDLED, |
+ window_tree()->GetEventResult( |
+ InputEventBasicTestWindowDelegate::kEventId)); |
+ EXPECT_TRUE(window_delegate.got_move()); |
+ EXPECT_FALSE(window_delegate.was_acked()); |
+ EXPECT_EQ(gfx::Point(30, 30), window_delegate.last_event_location()); |
+} |
+ |
class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { |
public: |
WindowTreeClientPointerObserverTest() {} |