@@ -15185,4 +15185,91 @@ TEST_P(TransferOrDontTransferFixture, MouseAndTouchTransferSimultaneousMultiDevi
1518515185
1518615186INSTANTIATE_TEST_SUITE_P(WithAndWithoutTransfer, TransferOrDontTransferFixture, testing::Bool());
1518715187
15188+ class InputDispatcherConnectedDisplayTest : public InputDispatcherTest {
15189+ constexpr static int DENSITY_MEDIUM = 160;
15190+
15191+ const DisplayTopologyGraph
15192+ mTopology{.primaryDisplayId = DISPLAY_ID,
15193+ .graph = {{DISPLAY_ID,
15194+ {{SECOND_DISPLAY_ID, DisplayTopologyPosition::TOP, 0.0f}}},
15195+ {SECOND_DISPLAY_ID,
15196+ {{DISPLAY_ID, DisplayTopologyPosition::BOTTOM, 0.0f}}}},
15197+ .displaysDensity = {{DISPLAY_ID, DENSITY_MEDIUM},
15198+ {SECOND_DISPLAY_ID, DENSITY_MEDIUM}}};
15199+
15200+ protected:
15201+ sp<FakeWindowHandle> mWindow;
15202+
15203+ void SetUp() override {
15204+ InputDispatcherTest::SetUp();
15205+ mDispatcher->setDisplayTopology(mTopology);
15206+ mWindow = sp<FakeWindowHandle>::make(std::make_shared<FakeApplicationHandle>(), mDispatcher,
15207+ "Window", DISPLAY_ID);
15208+ mWindow->setFrame({0, 0, 100, 100});
15209+
15210+ mDispatcher->onWindowInfosChanged({{*mWindow->getInfo()}, {}, 0, 0});
15211+ }
15212+ };
15213+
15214+ TEST_F(InputDispatcherConnectedDisplayTest, MultiDisplayMouseGesture) {
15215+ SCOPED_FLAG_OVERRIDE(connected_displays_cursor, true);
15216+
15217+ // pointer-down
15218+ mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE)
15219+ .displayId(DISPLAY_ID)
15220+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15221+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(60).y(60))
15222+ .build());
15223+ mWindow->consumeMotionEvent(
15224+ AllOf(WithMotionAction(ACTION_DOWN), WithDisplayId(DISPLAY_ID), WithRawCoords(60, 60)));
15225+
15226+ mDispatcher->notifyMotion(
15227+ MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
15228+ .displayId(DISPLAY_ID)
15229+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15230+ .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
15231+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(60).y(60))
15232+ .build());
15233+ mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
15234+ WithDisplayId(DISPLAY_ID), WithRawCoords(60, 60)));
15235+
15236+ // pointer-move
15237+ mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_MOUSE)
15238+ .displayId(DISPLAY_ID)
15239+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15240+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(60).y(60))
15241+ .build());
15242+ mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
15243+ WithDisplayId(DISPLAY_ID), WithRawCoords(60, 60)));
15244+
15245+ // pointer-move with different display
15246+ // TODO (b/383092013): by default windows will not be topology aware and receive events as it
15247+ // was in the same display. This behaviour has not been implemented yet.
15248+ mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_MOUSE)
15249+ .displayId(SECOND_DISPLAY_ID)
15250+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
15251+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(70).y(70))
15252+ .build());
15253+ mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
15254+ WithDisplayId(SECOND_DISPLAY_ID), WithRawCoords(70, 70)));
15255+
15256+ // pointer-up
15257+ mDispatcher->notifyMotion(
15258+ MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_RELEASE, AINPUT_SOURCE_MOUSE)
15259+ .displayId(SECOND_DISPLAY_ID)
15260+ .buttonState(0)
15261+ .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
15262+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(70).y(70))
15263+ .build());
15264+ mWindow->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
15265+ WithDisplayId(SECOND_DISPLAY_ID), WithRawCoords(70, 70)));
15266+
15267+ mDispatcher->notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_MOUSE)
15268+ .displayId(SECOND_DISPLAY_ID)
15269+ .buttonState(0)
15270+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(70).y(70))
15271+ .build());
15272+ mWindow->consumeMotionUp(SECOND_DISPLAY_ID);
15273+ }
15274+
1518815275} // namespace android::inputdispatcher
0 commit comments