@@ -12927,6 +12927,87 @@ TEST_F(InputDispatcherDragTests, NoDragAndDropWithHoveringPointer) {
1292712927 << "Drag and drop should not work with a hovering pointer";
1292812928}
1292912929
12930+ /**
12931+ * Two devices, we use the second pointer of Device A to start the drag, during the drag process, if
12932+ * we perform a click using Device B, the dispatcher should work well.
12933+ */
12934+ TEST_F(InputDispatcherDragTests, DragAndDropWhenSplitTouchAndMultiDevice) {
12935+ const DeviceId deviceA = 1;
12936+ const DeviceId deviceB = 2;
12937+ // First down on second window with deviceA.
12938+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
12939+ .deviceId(deviceA)
12940+ .pointer(PointerBuilder(0, ToolType::FINGER).x(150).y(50))
12941+ .build());
12942+ mSecondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(deviceA),
12943+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
12944+
12945+ // Second down on first window with deviceA
12946+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
12947+ .deviceId(deviceA)
12948+ .pointer(PointerBuilder(0, ToolType::FINGER).x(150).y(50))
12949+ .pointer(PointerBuilder(1, ToolType::FINGER).x(50).y(50))
12950+ .build());
12951+ mWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(deviceA),
12952+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
12953+ mSecondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_MOVE), WithDeviceId(deviceA),
12954+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
12955+
12956+ // Perform drag and drop from first window.
12957+ ASSERT_TRUE(startDrag(/*sendDown=*/false));
12958+
12959+ // Click first window with device B, we should ensure dispatcher work well.
12960+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
12961+ .deviceId(deviceB)
12962+ .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
12963+ .build());
12964+ mWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(deviceB),
12965+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
12966+
12967+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_MOUSE)
12968+ .deviceId(deviceB)
12969+ .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
12970+ .build());
12971+ mWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_UP), WithDeviceId(deviceB),
12972+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
12973+
12974+ // Move with device A.
12975+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
12976+ .deviceId(deviceA)
12977+ .pointer(PointerBuilder(0, ToolType::FINGER).x(151).y(51))
12978+ .pointer(PointerBuilder(1, ToolType::FINGER).x(51).y(51))
12979+ .build());
12980+
12981+ mDragWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_MOVE), WithDeviceId(deviceA),
12982+ WithDisplayId(ui::LogicalDisplayId::DEFAULT),
12983+ WithFlags(AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE)));
12984+ mWindow->consumeDragEvent(false, 51, 51);
12985+ mSecondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_MOVE), WithDeviceId(deviceA),
12986+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
12987+
12988+ // Releasing the drag pointer should cause drop.
12989+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN)
12990+ .deviceId(deviceA)
12991+ .pointer(PointerBuilder(0, ToolType::FINGER).x(151).y(51))
12992+ .pointer(PointerBuilder(1, ToolType::FINGER).x(51).y(51))
12993+ .build());
12994+ mDragWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_UP), WithDeviceId(deviceA),
12995+ WithDisplayId(ui::LogicalDisplayId::DEFAULT),
12996+ WithFlags(AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE)));
12997+ mFakePolicy->assertDropTargetEquals(*mDispatcher, mWindow->getToken());
12998+ mSecondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_MOVE), WithDeviceId(deviceA),
12999+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
13000+
13001+ // Release all pointers.
13002+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN)
13003+ .deviceId(deviceA)
13004+ .pointer(PointerBuilder(0, ToolType::FINGER).x(151).y(51))
13005+ .build());
13006+ mSecondWindow->consumeMotionEvent(AllOf(WithMotionAction(ACTION_UP), WithDeviceId(deviceA),
13007+ WithDisplayId(ui::LogicalDisplayId::DEFAULT)));
13008+ mWindow->assertNoEvents();
13009+ }
13010+
1293013011class InputDispatcherDropInputFeatureTest : public InputDispatcherTest {};
1293113012
1293213013TEST_F(InputDispatcherDropInputFeatureTest, WindowDropsInput) {
0 commit comments