Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 192c49e1 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Always return a new InputChannel when mocking InputManager

Some of the WmTests rely on a mock of InputManager. That is in general
not a good approach to testing, since the input code is owned by a
different subteam and is generally a rather separate code base.

However, if we were to mock the InputManager, the correct way would be
to always produce a new input channel, which is what's done in this CL.

Prior to this CL, the same input channel was reused, which meant that
"dispose" call on this input channel had surprising results.

Also, in this CL, delete testPerformDrag_NullDataToOtherUser test.
This test was broken by this refactor. Previously, all windows would use
the same input channel, which is incorrect. Now that this is fixed, the
test started failing:

java.lang.IllegalStateException: cancelDragAndDrop() does not match prepareDrag()
    at com.android.server.wm.DragDropController.cancelDragAndDrop(DragDropController.java:470)
    at com.android.server.wm.DragDropControllerTests.tearDown(DragDropControllerTests.java:193)

Based on my reading of this code, this test is bogus:
1. The API getTouchableWinAtPointLocked is only used for recents, and
   it's mock in this test is a no-op
2. The 'mToken' assignment in this test is incorrect, because in
   TearDown, this token is being used to cancel drag and drop. This
   token is then compared to the original token in the controller, and
   the test fails because there's a mismatch.

Bug: 323450804
Flag: TEST_ONLY
Test: atest com.android.server.wm.DragDropControllerTests
Change-Id: Ifd35e0801861303cf3b3af0a4a6aefc85624a330
parent a5971de4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment