| Index: ui/aura/window_event_dispatcher_unittest.cc
|
| diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc
|
| index b13935272fd4e1a5af37c23f3b60980292fb508e..3ee18b7fda2fed80facb1354d0b00357b71dc829 100644
|
| --- a/ui/aura/window_event_dispatcher_unittest.cc
|
| +++ b/ui/aura/window_event_dispatcher_unittest.cc
|
| @@ -126,9 +126,10 @@ TEST_P(WindowEventDispatcherTest, OnHostMouseEvent) {
|
|
|
| // Send a mouse event to window1.
|
| gfx::Point point(101, 201);
|
| - ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, point,
|
| - ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent event1(
|
| + ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(),
|
| + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&event1);
|
|
|
| // Event was tested for non-client area for the target window.
|
| @@ -150,9 +151,10 @@ TEST_P(WindowEventDispatcherTest, RepostEvent) {
|
| // press.
|
| EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown());
|
| gfx::Point point(10, 10);
|
| - ui::MouseEvent event(ui::ET_MOUSE_PRESSED, point, point,
|
| - ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent event(
|
| + ui::ET_MOUSE_PRESSED, point, point, ui::EventTimeForNow(),
|
| + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| host()->dispatcher()->RepostEvent(&event);
|
| RunAllPendingInMessageLoop();
|
| EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
|
| @@ -176,7 +178,8 @@ TEST_P(WindowEventDispatcherTest, MouseButtonState) {
|
| // Press the left button.
|
| event.reset(new ui::MouseEvent(
|
| ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(),
|
| - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
|
| DispatchEventUsingWindowDispatcher(event.get());
|
| EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
|
|
|
| @@ -184,28 +187,32 @@ TEST_P(WindowEventDispatcherTest, MouseButtonState) {
|
| event.reset(new ui::MouseEvent(
|
| ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(),
|
| ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
|
| - ui::EF_RIGHT_MOUSE_BUTTON));
|
| + ui::EF_RIGHT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
|
| DispatchEventUsingWindowDispatcher(event.get());
|
| EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
|
|
|
| // Release the left button.
|
| event.reset(new ui::MouseEvent(
|
| ui::ET_MOUSE_RELEASED, location, location, ui::EventTimeForNow(),
|
| - ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
|
| + ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
|
| DispatchEventUsingWindowDispatcher(event.get());
|
| EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
|
|
|
| // Release the right button. We should ignore the Shift-is-down flag.
|
| - event.reset(new ui::MouseEvent(ui::ET_MOUSE_RELEASED, location, location,
|
| - ui::EventTimeForNow(), ui::EF_SHIFT_DOWN,
|
| - ui::EF_RIGHT_MOUSE_BUTTON));
|
| + event.reset(new ui::MouseEvent(
|
| + ui::ET_MOUSE_RELEASED, location, location, ui::EventTimeForNow(),
|
| + ui::EF_SHIFT_DOWN, ui::EF_RIGHT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
|
| DispatchEventUsingWindowDispatcher(event.get());
|
| EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown());
|
|
|
| // Press the middle button.
|
| event.reset(new ui::MouseEvent(
|
| ui::ET_MOUSE_PRESSED, location, location, ui::EventTimeForNow(),
|
| - ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON));
|
| + ui::EF_MIDDLE_MOUSE_BUTTON, ui::EF_MIDDLE_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
|
| DispatchEventUsingWindowDispatcher(event.get());
|
| EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
|
| }
|
| @@ -215,8 +222,9 @@ TEST_P(WindowEventDispatcherTest, TranslatedEvent) {
|
| NULL, 1, gfx::Rect(50, 50, 100, 100), root_window()));
|
|
|
| gfx::Point origin(100, 100);
|
| - ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin,
|
| - ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent root(
|
| + ui::ET_MOUSE_PRESSED, origin, origin, ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
|
|
| EXPECT_EQ("100,100", root.location().ToString());
|
| EXPECT_EQ("100,100", root.root_location().ToString());
|
| @@ -646,7 +654,8 @@ TEST_P(WindowEventDispatcherTest, MAYBE(RepostTargetsCaptureWindow)) {
|
| window->SetCapture();
|
| const ui::MouseEvent press_event(
|
| ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
|
| - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| host()->dispatcher()->RepostEvent(&press_event);
|
| RunAllPendingInMessageLoop(); // Necessitated by RepostEvent().
|
| // Mouse moves/enters may be generated. We only care about a pressed.
|
| @@ -662,9 +671,10 @@ TEST_P(WindowEventDispatcherTest, MouseMovesHeld) {
|
| std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate(
|
| &delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
|
|
|
| - ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0),
|
| - gfx::Point(0, 0), ui::EventTimeForNow(), 0,
|
| - 0);
|
| + ui::MouseEvent mouse_move_event(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_move_event);
|
| // Discard MOUSE_ENTER.
|
| recorder.Reset();
|
| @@ -672,17 +682,19 @@ TEST_P(WindowEventDispatcherTest, MouseMovesHeld) {
|
| host()->dispatcher()->HoldPointerMoves();
|
|
|
| // Check that we don't immediately dispatch the MOUSE_DRAGGED event.
|
| - ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0),
|
| - gfx::Point(0, 0), ui::EventTimeForNow(), 0,
|
| - 0);
|
| + ui::MouseEvent mouse_dragged_event(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
|
| EXPECT_TRUE(recorder.events().empty());
|
|
|
| // Check that we do dispatch the held MOUSE_DRAGGED event before another type
|
| // of event.
|
| - ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0),
|
| - gfx::Point(0, 0), ui::EventTimeForNow(), 0,
|
| - 0);
|
| + ui::MouseEvent mouse_pressed_event(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
|
| EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
|
| EventTypesToString(recorder.events()));
|
| @@ -691,18 +703,21 @@ TEST_P(WindowEventDispatcherTest, MouseMovesHeld) {
|
| // Check that we coalesce held MOUSE_DRAGGED events. Note that here (and
|
| // elsewhere in this test) we re-define each event prior to dispatch so that
|
| // it has the correct state (phase, handled, target, etc.).
|
| - mouse_dragged_event =
|
| - ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| - ui::EventTimeForNow(), 0, 0);
|
| - ui::MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(),
|
| - 0, 0);
|
| + mouse_dragged_event = ui::MouseEvent(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| + ui::MouseEvent mouse_dragged_event2(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
|
| EXPECT_TRUE(recorder.events().empty());
|
| - mouse_pressed_event =
|
| - ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| - ui::EventTimeForNow(), 0, 0);
|
| + mouse_pressed_event = ui::MouseEvent(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
|
| EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
|
| EventTypesToString(recorder.events()));
|
| @@ -710,9 +725,10 @@ TEST_P(WindowEventDispatcherTest, MouseMovesHeld) {
|
|
|
| // Check that on ReleasePointerMoves, held events are not dispatched
|
| // immediately, but posted instead.
|
| - mouse_dragged_event =
|
| - ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| - ui::EventTimeForNow(), 0, 0);
|
| + mouse_dragged_event = ui::MouseEvent(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
|
| host()->dispatcher()->ReleasePointerMoves();
|
| EXPECT_TRUE(recorder.events().empty());
|
| @@ -723,14 +739,16 @@ TEST_P(WindowEventDispatcherTest, MouseMovesHeld) {
|
| // However if another message comes in before the dispatch of the posted
|
| // event, check that the posted event is dispatched before this new event.
|
| host()->dispatcher()->HoldPointerMoves();
|
| - mouse_dragged_event =
|
| - ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| - ui::EventTimeForNow(), 0, 0);
|
| + mouse_dragged_event = ui::MouseEvent(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
|
| host()->dispatcher()->ReleasePointerMoves();
|
| - mouse_pressed_event =
|
| - ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| - ui::EventTimeForNow(), 0, 0);
|
| + mouse_pressed_event = ui::MouseEvent(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
|
| EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
|
| EventTypesToString(recorder.events()));
|
| @@ -741,14 +759,16 @@ TEST_P(WindowEventDispatcherTest, MouseMovesHeld) {
|
| // Check that if the other message is another MOUSE_DRAGGED, we still coalesce
|
| // them.
|
| host()->dispatcher()->HoldPointerMoves();
|
| - mouse_dragged_event =
|
| - ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| - ui::EventTimeForNow(), 0, 0);
|
| + mouse_dragged_event = ui::MouseEvent(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
|
| host()->dispatcher()->ReleasePointerMoves();
|
| - mouse_dragged_event2 =
|
| - ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0);
|
| + mouse_dragged_event2 = ui::MouseEvent(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
|
| EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(recorder.events()));
|
| recorder.Reset();
|
| @@ -757,15 +777,18 @@ TEST_P(WindowEventDispatcherTest, MouseMovesHeld) {
|
|
|
| // Check that synthetic mouse move event has a right location when issued
|
| // while holding pointer moves.
|
| - mouse_dragged_event =
|
| - ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| - ui::EventTimeForNow(), 0, 0);
|
| - mouse_dragged_event2 =
|
| - ui::MouseEvent(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0);
|
| - ui::MouseEvent mouse_dragged_event3(ui::ET_MOUSE_DRAGGED, gfx::Point(28, 28),
|
| - gfx::Point(28, 28), ui::EventTimeForNow(),
|
| - 0, 0);
|
| + mouse_dragged_event = ui::MouseEvent(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0), gfx::Point(0, 0),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| + mouse_dragged_event2 = ui::MouseEvent(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| + ui::MouseEvent mouse_dragged_event3(
|
| + ui::ET_MOUSE_DRAGGED, gfx::Point(28, 28), gfx::Point(28, 28),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| host()->dispatcher()->HoldPointerMoves();
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
|
| DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
|
| @@ -861,8 +884,9 @@ TEST_P(WindowEventDispatcherTest, MouseEventWithoutTargetWindow) {
|
| window_second->AddPreTargetHandler(&recorder_second);
|
|
|
| const gfx::Point event_location(22, 33);
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
|
| - ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_MOVED, event_location, event_location, ui::EventTimeForNow(),
|
| + 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
|
|
| EXPECT_TRUE(recorder_first.events().empty());
|
| @@ -886,8 +910,9 @@ TEST_P(WindowEventDispatcherTest, DispatchMouseExitWhenHidingWindow) {
|
|
|
| // Dispatch a mouse move event into the window.
|
| const gfx::Point event_location(22, 33);
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
|
| - ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_MOVED, event_location, event_location, ui::EventTimeForNow(),
|
| + 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
| EXPECT_FALSE(recorder.events().empty());
|
| recorder.Reset();
|
| @@ -1025,16 +1050,19 @@ TEST_P(WindowEventDispatcherTest, DispatchSyntheticMouseEvents) {
|
| test::TestCursorClient cursor_client(root_window());
|
|
|
| // Dispatch a non-synthetic mouse event when mouse events are enabled.
|
| - ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent mouse1(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse1);
|
| EXPECT_FALSE(recorder.events().empty());
|
| recorder.Reset();
|
|
|
| // Dispatch a synthetic mouse event when mouse events are enabled.
|
| - ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(),
|
| - ui::EF_IS_SYNTHESIZED, 0);
|
| + ui::MouseEvent mouse2(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse2);
|
| EXPECT_FALSE(recorder.events().empty());
|
| recorder.Reset();
|
| @@ -1056,9 +1084,10 @@ TEST_P(WindowEventDispatcherTest, DoNotSynthesizeWhileButtonDown) {
|
|
|
| window->AddPreTargetHandler(&recorder);
|
| // Dispatch a non-synthetic mouse event when mouse events are enabled.
|
| - ui::MouseEvent mouse1(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(),
|
| - ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent mouse1(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse1);
|
| ASSERT_EQ(1u, recorder.events().size());
|
| EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder.events()[0]);
|
| @@ -1096,8 +1125,10 @@ TEST_P(WindowEventDispatcherTest,
|
| window->AddPreTargetHandler(&recorder);
|
|
|
| // Dispatch a non-synthetic mouse event to place cursor inside window bounds.
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
| EXPECT_FALSE(recorder.events().empty());
|
| recorder.Reset();
|
| @@ -1151,8 +1182,9 @@ TEST_P(WindowEventDispatcherTest, DispatchMouseExitWhenCursorHidden) {
|
|
|
| // Dispatch a mouse move event into the window.
|
| gfx::Point mouse_location(gfx::Point(15, 25));
|
| - ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
|
| - ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent mouse1(
|
| + ui::ET_MOUSE_MOVED, mouse_location, mouse_location, ui::EventTimeForNow(),
|
| + 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| EXPECT_TRUE(recorder.events().empty());
|
| DispatchEventUsingWindowDispatcher(&mouse1);
|
| EXPECT_FALSE(recorder.events().empty());
|
| @@ -1188,8 +1220,9 @@ TEST_P(WindowEventDispatcherTest,
|
|
|
| // Dispatch a mouse move event into the window.
|
| gfx::Point mouse_location(gfx::Point(15, 25));
|
| - ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location, mouse_location,
|
| - ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent mouse1(
|
| + ui::ET_MOUSE_MOVED, mouse_location, mouse_location, ui::EventTimeForNow(),
|
| + 0, 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| EXPECT_TRUE(recorder.events().empty());
|
| DispatchEventUsingWindowDispatcher(&mouse1);
|
| EXPECT_FALSE(recorder.events().empty());
|
| @@ -1199,9 +1232,10 @@ TEST_P(WindowEventDispatcherTest,
|
| cursor_client.DisableMouseEvents();
|
|
|
| gfx::Point mouse_exit_location(gfx::Point(150, 150));
|
| - ui::MouseEvent mouse2(ui::ET_MOUSE_EXITED, gfx::Point(150, 150),
|
| - gfx::Point(150, 150), ui::EventTimeForNow(),
|
| - ui::EF_IS_SYNTHESIZED, 0);
|
| + ui::MouseEvent mouse2(
|
| + ui::ET_MOUSE_EXITED, gfx::Point(150, 150), gfx::Point(150, 150),
|
| + ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse2);
|
|
|
| EXPECT_FALSE(recorder.events().empty());
|
| @@ -1665,8 +1699,10 @@ TEST_P(WindowEventDispatcherTest, DeleteDispatcherDuringPreDispatch) {
|
| // destroyed. This test passes if no crash happens.
|
| // Here we can't use EventGenerator since it expects that the dispatcher is
|
| // not destroyed at the end of the dispatch.
|
| - ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(20, 20),
|
| - gfx::Point(20, 20), base::TimeTicks(), 0, 0);
|
| + ui::MouseEvent mouse_move(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(20, 20), gfx::Point(20, 20),
|
| + base::TimeTicks(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| ui::EventDispatchDetails details =
|
| host->dispatcher()->DispatchEvent(w2, &mouse_move);
|
| EXPECT_TRUE(details.dispatcher_destroyed);
|
| @@ -1738,9 +1774,10 @@ class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate {
|
| void OnMouseEvent(ui::MouseEvent* event) override {
|
| if ((event->flags() & ui::EF_SHIFT_DOWN) != 0 &&
|
| mouse_event_count_++ == 0) {
|
| - ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(),
|
| - ui::EF_SHIFT_DOWN, 0);
|
| + ui::MouseEvent mouse_event(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), ui::EF_SHIFT_DOWN, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| root_->GetHost()->dispatcher()->RepostEvent(&mouse_event);
|
| }
|
| }
|
| @@ -1763,12 +1800,15 @@ TEST_P(WindowEventDispatcherTest, DontResetHeldEvent) {
|
| DontResetHeldEventWindowDelegate delegate(root_window());
|
| std::unique_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate));
|
| w1->SetBounds(gfx::Rect(0, 0, 40, 40));
|
| - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(),
|
| - ui::EF_SHIFT_DOWN, 0);
|
| + ui::MouseEvent pressed(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), ui::EF_SHIFT_DOWN, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| root_window()->GetHost()->dispatcher()->RepostEvent(&pressed);
|
| - ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(), 0, 0);
|
| + ui::MouseEvent pressed2(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| // Dispatch an event to flush event scheduled by way of RepostEvent().
|
| DispatchEventUsingWindowDispatcher(&pressed2);
|
| // Delegate should have seen reposted event (identified by way of
|
| @@ -1825,9 +1865,10 @@ TEST_P(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) {
|
| // Owned by |h2|.
|
| Window* w1 = CreateNormalWindow(1, h2->window(), &delegate);
|
| w1->SetBounds(gfx::Rect(0, 0, 40, 40));
|
| - ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(),
|
| - ui::EF_SHIFT_DOWN, 0);
|
| + ui::MouseEvent pressed(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), ui::EF_SHIFT_DOWN, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| h2->dispatcher()->RepostEvent(&pressed);
|
| // RunAllPendingInMessageLoop() to make sure the |pressed| is run.
|
| RunAllPendingInMessageLoop();
|
| @@ -2037,7 +2078,8 @@ class WindowEventDispatcherTestWithMessageLoop
|
| // the reposted event should not have fired.
|
| std::unique_ptr<ui::MouseEvent> mouse(new ui::MouseEvent(
|
| ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| - ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE));
|
| + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
|
| message_loop()->task_runner()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&WindowEventDispatcherTestWithMessageLoop::RepostEventHelper,
|
| @@ -2121,18 +2163,20 @@ TEST_P(WindowEventDispatcherTestInHighDPI, EventLocationTransform) {
|
| child->AddPreTargetHandler(&handler_child);
|
|
|
| {
|
| - ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(30, 30),
|
| - gfx::Point(30, 30), ui::EventTimeForNow(), ui::EF_NONE,
|
| - ui::EF_NONE);
|
| + ui::MouseEvent move(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(30, 30), gfx::Point(30, 30),
|
| + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&move);
|
| EXPECT_EQ(0, handler_child.num_mouse_events());
|
| EXPECT_EQ(1, handler_root.num_mouse_events());
|
| }
|
|
|
| {
|
| - ui::MouseEvent move(ui::ET_MOUSE_MOVED, gfx::Point(50, 50),
|
| - gfx::Point(50, 50), ui::EventTimeForNow(), ui::EF_NONE,
|
| - ui::EF_NONE);
|
| + ui::MouseEvent move(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(50, 50), gfx::Point(50, 50),
|
| + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&move);
|
| // The child receives an ENTER, and a MOVED event.
|
| EXPECT_EQ(2, handler_child.num_mouse_events());
|
| @@ -2221,19 +2265,21 @@ TEST_P(WindowEventDispatcherTestInHighDPI,
|
| // Make sure the window is visible.
|
| RunAllPendingInMessageLoop();
|
|
|
| - ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, gfx::Point(80, 80),
|
| - gfx::Point(80, 80), ui::EventTimeForNow(),
|
| - ui::EF_NONE, ui::EF_NONE);
|
| + ui::MouseEvent mouse_move(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(80, 80), gfx::Point(80, 80),
|
| + ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| const base::Closure callback_on_right_click = base::Bind(
|
| base::IgnoreResult(&WindowEventDispatcherTestInHighDPI::DispatchEvent),
|
| base::Unretained(this), base::Unretained(&mouse_move));
|
| TriggerNestedLoopOnRightMousePress handler(callback_on_right_click);
|
| window->AddPreTargetHandler(&handler);
|
|
|
| - std::unique_ptr<ui::MouseEvent> mouse(
|
| - new ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeForNow(),
|
| - ui::EF_RIGHT_MOUSE_BUTTON, ui::EF_RIGHT_MOUSE_BUTTON));
|
| + std::unique_ptr<ui::MouseEvent> mouse(new ui::MouseEvent(
|
| + ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeForNow(), ui::EF_RIGHT_MOUSE_BUTTON,
|
| + ui::EF_RIGHT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
|
| host()->dispatcher()->RepostEvent(mouse.get());
|
| EXPECT_EQ(0, handler.num_mouse_events());
|
|
|
| @@ -2274,8 +2320,10 @@ TEST_P(WindowEventDispatcherTest, SynthesizedLocatedEvent) {
|
| Env::GetInstance()->last_mouse_location().ToString());
|
|
|
| // Synthesized event should not update the mouse location.
|
| - ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
|
| - ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0);
|
| + ui::MouseEvent mouseev(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(),
|
| + ui::EF_IS_SYNTHESIZED, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| generator.Dispatch(&mouseev);
|
| EXPECT_EQ("10,10",
|
| Env::GetInstance()->last_mouse_location().ToString());
|
| @@ -2369,9 +2417,11 @@ class DispatchEventHandler : public ui::EventHandler {
|
| // ui::EventHandler:
|
| void OnMouseEvent(ui::MouseEvent* mouse) override {
|
| if (mouse->type() == ui::ET_MOUSE_MOVED) {
|
| - ui::MouseEvent move(ui::ET_MOUSE_MOVED, target_->bounds().CenterPoint(),
|
| - target_->bounds().CenterPoint(),
|
| - ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
|
| + ui::MouseEvent move(
|
| + ui::ET_MOUSE_MOVED, target_->bounds().CenterPoint(),
|
| + target_->bounds().CenterPoint(), ui::EventTimeForNow(), ui::EF_NONE,
|
| + ui::EF_NONE,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| ui::EventDispatchDetails details =
|
| target_->GetHost()->dispatcher()->OnEventFromSource(&move);
|
| ASSERT_FALSE(details.dispatcher_destroyed);
|
| @@ -2444,9 +2494,11 @@ TEST_P(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) {
|
| EXPECT_NE(root_window(), second_root);
|
|
|
| // Dispatch an event to |first|.
|
| - ui::MouseEvent move(ui::ET_MOUSE_MOVED, first->bounds().CenterPoint(),
|
| - first->bounds().CenterPoint(), ui::EventTimeForNow(),
|
| - ui::EF_NONE, ui::EF_NONE);
|
| + ui::MouseEvent move(
|
| + ui::ET_MOUSE_MOVED, first->bounds().CenterPoint(),
|
| + first->bounds().CenterPoint(), ui::EventTimeForNow(), ui::EF_NONE,
|
| + ui::EF_NONE,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| ui::EventDispatchDetails details =
|
| host()->dispatcher()->OnEventFromSource(&move);
|
| ASSERT_FALSE(details.dispatcher_destroyed);
|
| @@ -2546,9 +2598,10 @@ TEST_P(WindowEventDispatcherTest,
|
| EventFilterRecorder recorder_second;
|
| window_second->AddPreTargetHandler(&recorder_second);
|
| const gfx::Point event_location(25, 15);
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, event_location, event_location,
|
| - ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_PRESSED, event_location, event_location,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
| EXPECT_TRUE(recorder_first.events().empty());
|
| ASSERT_EQ(1u, recorder_second.events().size());
|
| @@ -2705,20 +2758,23 @@ TEST_P(WindowEventDispatcherTest, FractionOfTimeWithoutUserInputRecorded) {
|
| std::unique_ptr<aura::Window> window(
|
| test::CreateTestWindowWithId(1234, root_window()));
|
|
|
| - ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeStampFromSeconds(4), 0,
|
| - 0);
|
| + ui::MouseEvent mouse1(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeStampFromSeconds(4), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
|
|
| // To flush the idle fraction reporter, we need to dispatch two events. The
|
| // first event causes us to record the previous active period, and the second
|
| // flushes the previous active period.
|
| - ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeStampFromSeconds(16),
|
| - 0, 0);
|
| + ui::MouseEvent mouse2(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeStampFromSeconds(16), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
|
|
| - ui::MouseEvent mouse3(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
|
| - gfx::Point(10, 10), ui::EventTimeStampFromSeconds(30),
|
| - 0, 0);
|
| + ui::MouseEvent mouse3(
|
| + ui::ET_MOUSE_MOVED, gfx::Point(10, 10), gfx::Point(10, 10),
|
| + ui::EventTimeStampFromSeconds(30), 0, 0,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
|
|
| DispatchEventUsingWindowDispatcher(&mouse1);
|
| DispatchEventUsingWindowDispatcher(&mouse2);
|
| @@ -2781,9 +2837,10 @@ TEST_F(WindowEventDispatcherMusTest, LastEventLocation) {
|
| // Dispatch an event to |mouse_location|. While dispatching the event
|
| // Env::last_mouse_location() should return |mouse_location|.
|
| const gfx::Point mouse_location(1, 2);
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| - ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
| EXPECT_EQ(1, last_event_location_delegate.mouse_event_count());
|
| EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location());
|
| @@ -2804,9 +2861,10 @@ TEST_F(WindowEventDispatcherMusTest, UseDefaultTargeterToFindTarget) {
|
| gfx::Rect(20, 30, 100, 100), child1.get()));
|
|
|
| const gfx::Point mouse_location(30, 40);
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| - ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
| EXPECT_EQ(0, last_event_location_delegate1.mouse_event_count());
|
| EXPECT_EQ(1, last_event_location_delegate2.mouse_event_count());
|
| @@ -2826,9 +2884,10 @@ TEST_F(WindowEventDispatcherMusTest, UseDefaultTargeterToFindTarget2) {
|
| gfx::Rect(20, 30, 100, 100), child1.get()));
|
|
|
| const gfx::Point mouse_location(15, 25);
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| - ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
| EXPECT_EQ(1, last_event_location_delegate1.mouse_event_count());
|
| EXPECT_EQ(0, last_event_location_delegate2.mouse_event_count());
|
| @@ -2908,9 +2967,10 @@ TEST_F(WindowEventDispatcherMusTest, EventDispatchTriggersNestedMessageLoop) {
|
| // Dispatch an event to |mouse_location|. While dispatching the event
|
| // Env::last_mouse_location() should return |mouse_location|.
|
| const gfx::Point mouse_location(1, 2);
|
| - ui::MouseEvent mouse(ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| - ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| - ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent mouse(
|
| + ui::ET_MOUSE_PRESSED, mouse_location, mouse_location,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
|
| DispatchEventUsingWindowDispatcher(&mouse);
|
| EXPECT_EQ(1, last_event_location_delegate.mouse_event_count());
|
| EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count());
|
|
|