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
Loading
Please register or sign in to comment