@@ -1776,6 +1776,89 @@ TEST_F(PointerChoreographerTest, SetsPointerIconForMouseOnTwoDisplays) {
17761776 firstMousePc->assertPointerIconNotSet ();
17771777}
17781778
1779+ TEST_F (PointerChoreographerTest, A11yPointerMotionFilterMouse) {
1780+ mChoreographer .setDisplayViewports (createViewports ({DISPLAY_ID}));
1781+ mChoreographer .setDefaultMouseDisplayId (DISPLAY_ID);
1782+ mChoreographer .notifyInputDevicesChanged (
1783+ {/* id=*/ 0 ,
1784+ {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_MOUSE,
1785+ ui::LogicalDisplayId::INVALID)}});
1786+ auto pc = assertPointerControllerCreated (ControllerType::MOUSE);
1787+ ASSERT_EQ (DISPLAY_ID, pc->getDisplayId ());
1788+
1789+ pc->setPosition (100 , 200 );
1790+ mChoreographer .setAccessibilityPointerMotionFilterEnabled (true );
1791+
1792+ EXPECT_CALL (mMockPolicy ,
1793+ filterPointerMotionForAccessibility (testing::Eq (vec2{100 , 200 }),
1794+ testing::Eq (vec2{10 .f , 20 .f }),
1795+ testing::Eq (DISPLAY_ID)))
1796+ .Times (1 )
1797+ .WillOnce (testing::Return (vec2{4 , 13 }));
1798+
1799+ mChoreographer .notifyMotion (
1800+ MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
1801+ .pointer (MOUSE_POINTER)
1802+ .deviceId (DEVICE_ID)
1803+ .displayId (ui::LogicalDisplayId::INVALID)
1804+ .build ());
1805+
1806+ // Cursor position is decided by filtered delta, but pointer coord's relative values are kept.
1807+ pc->assertPosition (104 , 213 );
1808+ mTestListener .assertNotifyMotionWasCalled (AllOf (WithCoords (104 , 213 ), WithDisplayId (DISPLAY_ID),
1809+ WithCursorPosition (104 , 213 ),
1810+ WithRelativeMotion (10 , 20 )));
1811+ }
1812+
1813+ TEST_F (PointerChoreographerTest, A11yPointerMotionFilterTouchpad) {
1814+ mChoreographer .setDisplayViewports (createViewports ({DISPLAY_ID}));
1815+ mChoreographer .setDefaultMouseDisplayId (DISPLAY_ID);
1816+ mChoreographer .notifyInputDevicesChanged (
1817+ {/* id=*/ 0 ,
1818+ {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD,
1819+ ui::LogicalDisplayId::INVALID)}});
1820+ auto pc = assertPointerControllerCreated (ControllerType::MOUSE);
1821+ ASSERT_EQ (DISPLAY_ID, pc->getDisplayId ());
1822+
1823+ pc->setPosition (100 , 200 );
1824+ mChoreographer .setAccessibilityPointerMotionFilterEnabled (true );
1825+
1826+ EXPECT_CALL (mMockPolicy ,
1827+ filterPointerMotionForAccessibility (testing::Eq (vec2{100 , 200 }),
1828+ testing::Eq (vec2{10 .f , 20 .f }),
1829+ testing::Eq (DISPLAY_ID)))
1830+ .Times (1 )
1831+ .WillOnce (testing::Return (vec2{4 , 13 }));
1832+
1833+ mChoreographer .notifyMotion (
1834+ MotionArgsBuilder (AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_MOUSE)
1835+ .pointer (TOUCHPAD_POINTER)
1836+ .deviceId (DEVICE_ID)
1837+ .displayId (ui::LogicalDisplayId::INVALID)
1838+ .build ());
1839+
1840+ // Cursor position is decided by filtered delta, but pointer coord's relative values are kept.
1841+ pc->assertPosition (104 , 213 );
1842+ mTestListener .assertNotifyMotionWasCalled (AllOf (WithCoords (104 , 213 ), WithDisplayId (DISPLAY_ID),
1843+ WithCursorPosition (104 , 213 ),
1844+ WithRelativeMotion (10 , 20 )));
1845+ }
1846+
1847+ TEST_F (PointerChoreographerTest, A11yPointerMotionFilterNotFilterTouch) {
1848+ mChoreographer .notifyInputDevicesChanged (
1849+ {/* id=*/ 0 , {generateTestDeviceInfo (DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, DISPLAY_ID)}});
1850+ mChoreographer .setAccessibilityPointerMotionFilterEnabled (true );
1851+
1852+ EXPECT_CALL (mMockPolicy , filterPointerMotionForAccessibility).Times (0 );
1853+
1854+ mChoreographer .notifyMotion (
1855+ MotionArgsBuilder (AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
1856+ .pointer (FIRST_TOUCH_POINTER)
1857+ .deviceId (DEVICE_ID)
1858+ .displayId (DISPLAY_ID)
1859+ .build ());
1860+ }
1861+
17791862using SkipPointerScreenshotForPrivacySensitiveDisplaysFixtureParam =
17801863 std::tuple<std::string_view /* name*/ , uint32_t /* source*/ , ControllerType, PointerBuilder,
17811864 std::function<void (PointerChoreographer&)>, int32_t /* action*/ >;
0 commit comments