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

Commit f4e211cf authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Always return a new InputChannel when mocking InputManager" into main

parents 91f66c16 192c49e1
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -217,16 +217,6 @@ public class DragDropControllerTests extends WindowTestsBase {
        doDragAndDrop(View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_GLOBAL_URI_READ, null, 0, 0);
    }

    @Test
    public void testPerformDrag_NullDataToOtherUser() {
        final WindowState otherUsersWindow =
                createDropTargetWindow("Other user's window", 1 * UserHandle.PER_USER_RANGE);
        doReturn(otherUsersWindow).when(mDisplayContent).getTouchableWinAtPointLocked(10, 10);

        doDragAndDrop(View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_GLOBAL_URI_READ, null, 10, 10);
        mToken = otherUsersWindow.mClient.asBinder();
    }

    @Test
    public void testPrivateInterceptGlobalDragDropFlagChecksPermission() {
        DisplayPolicy policy = mDisplayContent.getDisplayPolicy();
+9 −10
Original line number Diff line number Diff line
@@ -139,7 +139,6 @@ public class SystemServicesTestRule implements TestRule {
    private ActivityTaskManagerService mAtmService;
    private WindowManagerService mWmService;
    private InputManagerService mImService;
    private InputChannel mInputChannel;
    private Runnable mOnBeforeServicesCreated;
    /**
     * Spied {@link SurfaceControl.Transaction} class than can be used to verify calls.
@@ -326,12 +325,15 @@ public class SystemServicesTestRule implements TestRule {

        // InputManagerService
        mImService = mock(InputManagerService.class);
        // InputChannel cannot be mocked because it may pass to InputEventReceiver.
        final InputChannel[] inputChannels = InputChannel.openInputChannelPair(TAG);
        inputChannels[0].dispose();
        mInputChannel = inputChannels[1];
        doReturn(mInputChannel).when(mImService).monitorInput(anyString(), anyInt());
        doReturn(mInputChannel).when(mImService).createInputChannel(anyString());
        // InputChannel cannot be mocked because it may be passed to InputEventReceiver.
        Answer<InputChannel> newInputChannel = invocation -> {
            String name = invocation.getArgument(0);
            final InputChannel[] channels = InputChannel.openInputChannelPair(name);
            channels[0].dispose();
            return channels[1];
        };
        when(mImService.monitorInput(anyString(), anyInt())).thenAnswer(newInputChannel);
        when(mImService.createInputChannel(anyString())).thenAnswer(newInputChannel);

        // StatusBarManagerInternal
        final StatusBarManagerInternal sbmi = mock(StatusBarManagerInternal.class);
@@ -464,9 +466,6 @@ public class SystemServicesTestRule implements TestRule {
        SurfaceAnimationThread.dispose();
        AnimationThread.dispose();
        UiThread.dispose();
        if (mInputChannel != null) {
            mInputChannel.dispose();
        }

        tearDownLocalServices();
        // Reset priority booster because animation thread has been changed.