@@ -830,22 +830,93 @@ TEST_F(PointerChoreographerTest, TouchSetsSpots) {
830830 pc->assertSpotCount (DISPLAY_ID, 0 );
831831}
832832
833+ /* *
834+ * In this test, we simulate the complete event of the stylus approaching and clicking on the
835+ * screen, and then leaving the screen. We should ensure that spots are displayed correctly.
836+ */
833837TEST_F (PointerChoreographerTest, TouchSetsSpotsForStylusEvent) {
834838 mChoreographer .setShowTouchesEnabled (true );
839+ mChoreographer .setStylusPointerIconEnabled (false );
835840 mChoreographer .notifyInputDevicesChanged (
836841 {/* id=*/ 0 ,
837842 {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
838843 DISPLAY_ID)}});
839844
840- // Emit down event with stylus properties .
841- mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_DOWN ,
845+ // First, the stylus begin to approach the screen .
846+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_ENTER ,
842847 AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
843848 .pointer (STYLUS_POINTER)
844849 .deviceId (DEVICE_ID)
845850 .displayId (DISPLAY_ID)
846851 .build ());
847852 auto pc = assertPointerControllerCreated (ControllerType::TOUCH);
848853 pc->assertSpotCount (DISPLAY_ID, 1 );
854+
855+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_MOVE,
856+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
857+ .pointer (STYLUS_POINTER)
858+ .deviceId (DEVICE_ID)
859+ .displayId (DISPLAY_ID)
860+ .build ());
861+ pc->assertSpotCount (DISPLAY_ID, 1 );
862+
863+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_EXIT,
864+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
865+ .pointer (STYLUS_POINTER)
866+ .deviceId (DEVICE_ID)
867+ .displayId (DISPLAY_ID)
868+ .build ());
869+ pc->assertSpotCount (DISPLAY_ID, 0 );
870+
871+ // Now, use stylus touch the screen.
872+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_DOWN,
873+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
874+ .pointer (STYLUS_POINTER)
875+ .deviceId (DEVICE_ID)
876+ .displayId (DISPLAY_ID)
877+ .build ());
878+ pc->assertSpotCount (DISPLAY_ID, 1 );
879+
880+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_MOVE,
881+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
882+ .pointer (STYLUS_POINTER)
883+ .deviceId (DEVICE_ID)
884+ .displayId (DISPLAY_ID)
885+ .build ());
886+ pc->assertSpotCount (DISPLAY_ID, 1 );
887+
888+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_UP,
889+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
890+ .pointer (STYLUS_POINTER)
891+ .deviceId (DEVICE_ID)
892+ .displayId (DISPLAY_ID)
893+ .build ());
894+ pc->assertSpotCount (DISPLAY_ID, 0 );
895+
896+ // Then, the stylus start leave from the screen.
897+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_ENTER,
898+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
899+ .pointer (STYLUS_POINTER)
900+ .deviceId (DEVICE_ID)
901+ .displayId (DISPLAY_ID)
902+ .build ());
903+ pc->assertSpotCount (DISPLAY_ID, 1 );
904+
905+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_MOVE,
906+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
907+ .pointer (STYLUS_POINTER)
908+ .deviceId (DEVICE_ID)
909+ .displayId (DISPLAY_ID)
910+ .build ());
911+ pc->assertSpotCount (DISPLAY_ID, 1 );
912+
913+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_EXIT,
914+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
915+ .pointer (STYLUS_POINTER)
916+ .deviceId (DEVICE_ID)
917+ .displayId (DISPLAY_ID)
918+ .build ());
919+ pc->assertSpotCount (DISPLAY_ID, 0 );
849920}
850921
851922TEST_F (PointerChoreographerTest, TouchSetsSpotsForTwoDisplays) {
0 commit comments