@@ -3072,6 +3072,90 @@ TEST_F(PointerChoreographerDisplayTopologyDefaultMouseDisplayTests,
30723072 ASSERT_TRUE (pc->isPointerShown ());
30733073}
30743074
3075+ TEST_F (PointerChoreographerDisplayTopologyDefaultMouseDisplayTests,
3076+ UsePrimaryDisplayIfAssociatedDisplayIsInTopology) {
3077+ SCOPED_FLAG_OVERRIDE (connected_displays_cursor, true );
3078+ SCOPED_FLAG_OVERRIDE (connected_displays_associated_display_cursor_bugfix, true );
3079+
3080+ // Add two displays
3081+ mChoreographer .setDisplayViewports (
3082+ {createViewport (FIRST_DISPLAY_ID), createViewport (SECOND_DISPLAY_ID)});
3083+ setDisplayTopologyWithDisplays (/* primaryDisplayId=*/ SECOND_DISPLAY_ID,
3084+ /* adjacentDisplays=*/ {FIRST_DISPLAY_ID});
3085+
3086+ mChoreographer .notifyInputDevicesChanged (
3087+ {/* id=*/ 0 , {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_MOUSE, FIRST_DISPLAY_ID)}});
3088+
3089+ auto pc = assertPointerControllerCreated (ControllerType::MOUSE);
3090+ pc->assertViewportSet (SECOND_DISPLAY_ID);
3091+ ASSERT_TRUE (pc->isPointerShown ());
3092+ }
3093+
3094+ TEST_F (PointerChoreographerDisplayTopologyDefaultMouseDisplayTests,
3095+ AllowCrossingDisplayEvenWithAssociatedDisplaySet) {
3096+ SCOPED_FLAG_OVERRIDE (connected_displays_cursor, true );
3097+ SCOPED_FLAG_OVERRIDE (connected_displays_associated_display_cursor_bugfix, true );
3098+
3099+ // Add two displays
3100+ mChoreographer .setDisplayViewports (
3101+ {createViewport (FIRST_DISPLAY_ID), createViewport (SECOND_DISPLAY_ID)});
3102+ setDisplayTopologyWithDisplays (/* primaryDisplayId=*/ FIRST_DISPLAY_ID,
3103+ /* adjacentDisplays=*/ {SECOND_DISPLAY_ID});
3104+
3105+ mChoreographer .notifyInputDevicesChanged (
3106+ {/* id=*/ 0 ,
3107+ {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_MOUSE, SECOND_DISPLAY_ID)}});
3108+
3109+ auto pc = assertPointerControllerCreated (ControllerType::MOUSE);
3110+ pc->assertViewportSet (FIRST_DISPLAY_ID);
3111+ ASSERT_TRUE (pc->isPointerShown ());
3112+
3113+ // Move cursor to the secondary display
3114+ auto pointerBuilder = PointerBuilder (/* id=*/ 0 , ToolType::MOUSE)
3115+ .axis (AMOTION_EVENT_AXIS_RELATIVE_X, /* x=*/ 100 )
3116+ .axis (AMOTION_EVENT_AXIS_RELATIVE_Y, /* y=*/ 0 );
3117+ mChoreographer .notifyMotion (
3118+ MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
3119+ .pointer (pointerBuilder)
3120+ .deviceId (DEVICE_ID)
3121+ .displayId (ui::LogicalDisplayId::INVALID)
3122+ .build ());
3123+
3124+ assertPointerControllerNotCreated ();
3125+ pc->assertViewportSet (SECOND_DISPLAY_ID);
3126+ ASSERT_TRUE (pc->isPointerShown ());
3127+ }
3128+
3129+ TEST_F (PointerChoreographerDisplayTopologyDefaultMouseDisplayTests,
3130+ AddAssociatedDisplayCursorOutsideOfDisplayTopology) {
3131+ SCOPED_FLAG_OVERRIDE (connected_displays_cursor, true );
3132+ SCOPED_FLAG_OVERRIDE (connected_displays_associated_display_cursor_bugfix, true );
3133+
3134+ // Add three displays, with only first and second display in DisplayTopolgoy
3135+ mChoreographer .setDisplayViewports ({createViewport (FIRST_DISPLAY_ID),
3136+ createViewport (SECOND_DISPLAY_ID),
3137+ createViewport (THIRD_DISPLAY_ID)});
3138+ setDisplayTopologyWithDisplays (/* primaryDisplayId=*/ FIRST_DISPLAY_ID,
3139+ /* adjacentDisplays=*/ {SECOND_DISPLAY_ID});
3140+
3141+ mChoreographer .notifyInputDevicesChanged (
3142+ {/* id=*/ 0 ,
3143+ {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_MOUSE,
3144+ ui::LogicalDisplayId::INVALID)}});
3145+
3146+ auto pc = assertPointerControllerCreated (ControllerType::MOUSE);
3147+ pc->assertViewportSet (FIRST_DISPLAY_ID);
3148+ ASSERT_TRUE (pc->isPointerShown ());
3149+
3150+ // Adds a new mouse associated with third display
3151+ mChoreographer .notifyInputDevicesChanged (
3152+ {/* id=*/ 1 , {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_MOUSE, THIRD_DISPLAY_ID)}});
3153+
3154+ pc = assertPointerControllerCreated (ControllerType::MOUSE);
3155+ pc->assertViewportSet (THIRD_DISPLAY_ID);
3156+ ASSERT_TRUE (pc->isPointerShown ());
3157+ }
3158+
30753159class PointerChoreographerWindowInfoListenerTest : public testing ::Test {};
30763160
30773161TEST_F_WITH_FLAGS (
0 commit comments