@@ -645,22 +645,93 @@ TEST_F(PointerChoreographerTest, TouchSetsSpots) {
645645 pc->assertSpotCount (DISPLAY_ID, 0 );
646646}
647647
648+ /* *
649+ * In this test, we simulate the complete event of the stylus approaching and clicking on the
650+ * screen, and then leaving the screen. We should ensure that spots are displayed correctly.
651+ */
648652TEST_F (PointerChoreographerTest, TouchSetsSpotsForStylusEvent) {
649653 mChoreographer .setShowTouchesEnabled (true );
654+ mChoreographer .setStylusPointerIconEnabled (false );
650655 mChoreographer .notifyInputDevicesChanged (
651656 {/* id=*/ 0 ,
652657 {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
653658 DISPLAY_ID)}});
654659
655- // Emit down event with stylus properties .
656- mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_DOWN ,
660+ // First, the stylus begin to approach the screen .
661+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_ENTER ,
657662 AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
658663 .pointer (STYLUS_POINTER)
659664 .deviceId (DEVICE_ID)
660665 .displayId (DISPLAY_ID)
661666 .build ());
662667 auto pc = assertPointerControllerCreated (ControllerType::TOUCH);
663668 pc->assertSpotCount (DISPLAY_ID, 1 );
669+
670+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_MOVE,
671+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
672+ .pointer (STYLUS_POINTER)
673+ .deviceId (DEVICE_ID)
674+ .displayId (DISPLAY_ID)
675+ .build ());
676+ pc->assertSpotCount (DISPLAY_ID, 1 );
677+
678+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_EXIT,
679+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
680+ .pointer (STYLUS_POINTER)
681+ .deviceId (DEVICE_ID)
682+ .displayId (DISPLAY_ID)
683+ .build ());
684+ pc->assertSpotCount (DISPLAY_ID, 0 );
685+
686+ // Now, use stylus touch the screen.
687+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_DOWN,
688+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
689+ .pointer (STYLUS_POINTER)
690+ .deviceId (DEVICE_ID)
691+ .displayId (DISPLAY_ID)
692+ .build ());
693+ pc->assertSpotCount (DISPLAY_ID, 1 );
694+
695+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_MOVE,
696+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
697+ .pointer (STYLUS_POINTER)
698+ .deviceId (DEVICE_ID)
699+ .displayId (DISPLAY_ID)
700+ .build ());
701+ pc->assertSpotCount (DISPLAY_ID, 1 );
702+
703+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_UP,
704+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
705+ .pointer (STYLUS_POINTER)
706+ .deviceId (DEVICE_ID)
707+ .displayId (DISPLAY_ID)
708+ .build ());
709+ pc->assertSpotCount (DISPLAY_ID, 0 );
710+
711+ // Then, the stylus start leave from the screen.
712+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_ENTER,
713+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
714+ .pointer (STYLUS_POINTER)
715+ .deviceId (DEVICE_ID)
716+ .displayId (DISPLAY_ID)
717+ .build ());
718+ pc->assertSpotCount (DISPLAY_ID, 1 );
719+
720+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_MOVE,
721+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
722+ .pointer (STYLUS_POINTER)
723+ .deviceId (DEVICE_ID)
724+ .displayId (DISPLAY_ID)
725+ .build ());
726+ pc->assertSpotCount (DISPLAY_ID, 1 );
727+
728+ mChoreographer .notifyMotion (MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_EXIT,
729+ AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS)
730+ .pointer (STYLUS_POINTER)
731+ .deviceId (DEVICE_ID)
732+ .displayId (DISPLAY_ID)
733+ .build ());
734+ pc->assertSpotCount (DISPLAY_ID, 0 );
664735}
665736
666737TEST_F (PointerChoreographerTest, TouchSetsSpotsForTwoDisplays) {
0 commit comments