| 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..aae75b7564797a28895f78698acea630c45748e7 100644
|
| --- a/ui/aura/mus/window_tree_client_unittest.cc
|
| +++ b/ui/aura/mus/window_tree_client_unittest.cc
|
| @@ -22,6 +22,7 @@
|
| #include "ui/aura/client/focus_client.h"
|
| #include "ui/aura/client/transient_window_client.h"
|
| #include "ui/aura/mus/capture_synchronizer.h"
|
| +#include "ui/aura/mus/mus_types.h"
|
| #include "ui/aura/mus/property_converter.h"
|
| #include "ui/aura/mus/window_mus.h"
|
| #include "ui/aura/mus/window_tree_client_delegate.h"
|
| @@ -41,6 +42,7 @@
|
| #include "ui/display/screen.h"
|
| #include "ui/events/event.h"
|
| #include "ui/events/event_utils.h"
|
| +#include "ui/events/test/test_event_handler.h"
|
| #include "ui/gfx/geometry/dip_util.h"
|
| #include "ui/gfx/geometry/rect.h"
|
|
|
| @@ -521,6 +523,36 @@ class InputEventBasicTestWindowDelegate : public test::TestWindowDelegate {
|
| DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate);
|
| };
|
|
|
| +class InputEventBasicTestEventHandler : public ui::test::TestEventHandler {
|
| + public:
|
| + static uint32_t constexpr kEventId = 1;
|
| +
|
| + explicit InputEventBasicTestEventHandler(TestWindowTree* test_window_tree)
|
| + : test_window_tree_(test_window_tree) {}
|
| + ~InputEventBasicTestEventHandler() override {}
|
| +
|
| + bool got_move() const { return got_move_; }
|
| + bool was_acked() const { return was_acked_; }
|
| + const gfx::Point& last_event_location() const { return last_event_location_; }
|
| +
|
| + // ui::test::TestEventHandler overrides.
|
| + void OnMouseEvent(ui::MouseEvent* event) override {
|
| + was_acked_ = test_window_tree_->WasEventAcked(kEventId);
|
| + if (event->type() == ui::ET_MOUSE_MOVED)
|
| + got_move_ = true;
|
| + last_event_location_ = event->location();
|
| + event->SetHandled();
|
| + }
|
| +
|
| + private:
|
| + TestWindowTree* test_window_tree_;
|
| + bool was_acked_ = false;
|
| + bool got_move_ = false;
|
| + gfx::Point last_event_location_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestEventHandler);
|
| +};
|
| +
|
| } // namespace
|
|
|
| TEST_F(WindowTreeClientClientTest, InputEventBasic) {
|
| @@ -557,6 +589,50 @@ TEST_F(WindowTreeClientClientTest, InputEventBasic) {
|
| EXPECT_EQ(event_location_in_child, window_delegate.last_event_location());
|
| }
|
|
|
| +TEST_F(WindowTreeClientClientTest, InputEventNoWindow) {
|
| + WindowTreeHostMus window_tree_host(window_tree_client_impl());
|
| + Window* top_level = window_tree_host.window();
|
| + InputEventBasicTestEventHandler event_handler(window_tree());
|
| + top_level->AddPreTargetHandler(&event_handler);
|
| + 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());
|
| + InputEventBasicTestWindowDelegate window_delegate(window_tree());
|
| + Window child(&window_delegate);
|
| + child.Init(ui::LAYER_NOT_DRAWN);
|
| + top_level->AddChild(&child);
|
| + child.SetBounds(gfx::Rect(10, 10, 100, 100));
|
| + child.Show();
|
| + EXPECT_FALSE(event_handler.got_move());
|
| + EXPECT_FALSE(event_handler.was_acked());
|
| + EXPECT_FALSE(window_delegate.got_move());
|
| + EXPECT_FALSE(window_delegate.was_acked());
|
| + const gfx::Point event_location_in_child(20, 30);
|
| + std::unique_ptr<ui::Event> ui_event(new ui::MouseEvent(
|
| + ui::ET_MOUSE_MOVED, event_location_in_child, gfx::Point(2, 3),
|
| + ui::EventTimeForNow(), ui::EF_NONE, 0));
|
| + window_tree_client()->OnWindowInputEvent(
|
| + InputEventBasicTestWindowDelegate::kEventId, kInvalidServerId,
|
| + window_tree_host.display_id(), ui::Event::Clone(*ui_event.get()), 0);
|
| + // WindowTreeClient::OnWindowInputEvent cannot find a target window with
|
| + // kInvalidServerId but should use the display_id to find the window_tree_host
|
| + // for event dispatching and dispatch the event to |top_level|.
|
| + EXPECT_TRUE(window_tree()->WasEventAcked(
|
| + InputEventBasicTestWindowDelegate::kEventId));
|
| + EXPECT_EQ(ui::mojom::EventResult::HANDLED,
|
| + window_tree()->GetEventResult(
|
| + InputEventBasicTestWindowDelegate::kEventId));
|
| + EXPECT_TRUE(event_handler.got_move());
|
| + EXPECT_FALSE(event_handler.was_acked());
|
| + EXPECT_EQ(gfx::Point(2, 3), event_handler.last_event_location());
|
| + EXPECT_FALSE(window_delegate.got_move());
|
| + EXPECT_FALSE(window_delegate.was_acked());
|
| + EXPECT_EQ(gfx::Point(), window_delegate.last_event_location());
|
| +}
|
| +
|
| class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest {
|
| public:
|
| WindowTreeClientPointerObserverTest() {}
|
|
|