summaryrefslogtreecommitdiff
path: root/libs/input/tests/PointerController_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Synchronize pointer display change requestsPrabir Pradhan2022-05-051-3/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, when InputManagerService requests for PointerController to change the pointer display, there was no way to know when the request was completed or whether it succeeded. This could lead to a few issues: - WM's MousePositionTracker's coordinates would not be updated until the next mouse event was generated, meaning the position would be out of sync. - The creation of a virtual mouse device moves the pointer to a specific displayId. In order to test this behavior, we would need to sleep in the test code to wait for the system to update the pointer display and position, resulting in generally flaky tests. Here, we add a way to synchonize changes to the pointer display so that InputMangerService can know the current pointer display with certainty. PointerController, which is updated in the InputReader thread, is the source of truth of the pointer display. We add a policy call to notify IMS when the pointer display changes. When the pointer display is changed, the cursor position on the updated display is also updated so that the VirtualMouse#getCursorPosition() API is synchronized to the pointer display change. Bug: 216792538 Test: atest FrameworksServicesTests:InputManagerServiceTests Test: atest PointerIconTest Change-Id: I578fd1aba9335e2e078d749321e55a6d05299f3b Merged-In: I578fd1aba9335e2e078d749321e55a6d05299f3b
* Allow its WindowInfosListener to outlive PointerControllerPrabir Pradhan2022-01-171-0/+32
| | | | | | | | | | | | | | | | | A strong pointer to PointerController::DisplayInfoListener is given away when the listener is registered, so PC cannot guarantee that the listener is destroyed when it is destroyed. This means the listener can outlive PC, so there is a race condition between PC's destruction and an update to the listener. While it could be argued that it is the caller's responsibility to ensure that the listener is not updated after it is unregistered, there is no way to guarantee that using strong pointers. Here, we can be defensive and protect against this case. Bug: 212672261 Test: atest libinputservice_test Change-Id: I358a725980cc8c7d6ad0483a9b2a8b8715a03424
* Refactor of PointerControllerLiam Harrington2020-08-061-5/+1
| | | | | | | | | | Abstracted logic that applies to all pointer types into general PointerController class and moved implementation of logic specific to the mouse cursor and touch spots to MouseCursorController and TouchSpotController, respectively. Test: Pixel 3XL device, atest PointerController_test, compile Change-Id: Ia5825c37ca75951cc8bcd7d5102c986bd957e69f
* Move PointerController enums to enum classes.Michael Wright2020-07-071-6/+6
| | | | | | | Bug: 160010896 Test: atest PointerController_test, compile Change-Id: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea Merged-In: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea
* Move PointerController from sp to shared_ptrMichael Wright2020-07-071-2/+2
| | | | | | | Bug: 160010896 Test: atest PointerController_test, manual usage Change-Id: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b Merged-In: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b
* PointerController: Add guards to ensure display is validPrabir Pradhan2020-05-281-6/+48
| | | | | | | | | | | | This change makes it so that PointerController does not ask its Policy to load any resources for any displays until a DisplayViewport is set, and verifies this with unit tests. Bug: 145699789 Bug: 146385350 Test: atest libinputservice_test Change-Id: I2e48e7ac4700e6f9fdf939a7bd0e6639b051ade6 Merged-In: I2e48e7ac4700e6f9fdf939a7bd0e6639b051ade6
* Stop loading animation for addtional cursor type.Garfield Tan2020-05-281-10/+15
| | | | | | | | | | In the test below it only expects MockSprite#setIcon() being called once, but with animation it may be called multiple times. Bug: 144947344 Test: atest PoitnerControllerTest#updatePointerIcon Change-Id: I5c4908fb8301cae144fd637c831f2012a35862e3 Merged-In: I5c4908fb8301cae144fd637c831f2012a35862e3
* Add cursor type and hotspot to surface metadata.Garfield Tan2020-05-281-0/+215
Also bootstrap unit tests for PointerController. Need to mark 3 functions of SpriteController virtual so their behaviors can be overridden. Bug: 130822623 Test: SurfaceFlinger can get cursor type and hotspot. Change-Id: I739cd03214364144bb4e22a166ecc7abfd3492fe Merged-In: I739cd03214364144bb4e22a166ecc7abfd3492fe