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

Commit eca9a2fd authored by Winson Chung's avatar Winson Chung Committed by Automerger Merge Worker
Browse files

Merge "Fix a couple shell unit test regressions" into tm-qpr-dev am: 4cc40c76

parents 52d2e66e 4cc40c76
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -30,10 +30,13 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import static java.lang.Integer.MAX_VALUE;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.RemoteException;
import android.test.suitebuilder.annotation.SmallTest;
@@ -135,12 +138,12 @@ public class PipControllerTest extends ShellTestCase {

    @Test
    public void instantiatePipController_addInitCallback() {
        verify(mShellInit, times(1)).addInitCallback(any(), any());
        verify(mShellInit, times(1)).addInitCallback(any(), eq(mPipController));
    }

    @Test
    public void instantiateController_registerDumpCallback() {
        verify(mMockShellCommandHandler, times(1)).addDumpCallback(any(), any());
        verify(mMockShellCommandHandler, times(1)).addDumpCallback(any(), eq(mPipController));
    }

    @Test
@@ -156,7 +159,7 @@ public class PipControllerTest extends ShellTestCase {
    @Test
    public void instantiatePipController_registerExternalInterface() {
        verify(mShellController, times(1)).addExternalInterface(
                eq(ShellSharedConstants.KEY_EXTRA_SHELL_PIP), any(), any());
                eq(ShellSharedConstants.KEY_EXTRA_SHELL_PIP), any(), eq(mPipController));
    }

    @Test
@@ -252,6 +255,10 @@ public class PipControllerTest extends ShellTestCase {
        final int displayId = 1;
        final Rect bounds = new Rect(0, 0, 10, 10);
        when(mMockPipBoundsAlgorithm.getDefaultBounds()).thenReturn(bounds);
        when(mMockPipBoundsState.getBounds()).thenReturn(bounds);
        when(mMockPipBoundsState.getMinSize()).thenReturn(new Point(1, 1));
        when(mMockPipBoundsState.getMaxSize()).thenReturn(new Point(MAX_VALUE, MAX_VALUE));
        when(mMockPipBoundsState.getBounds()).thenReturn(bounds);
        when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId);
        when(mMockPipBoundsState.getDisplayLayout()).thenReturn(mMockDisplayLayout1);
        when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2);
+4 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;

import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.ExternalInterfaceBinder;
import com.android.wm.shell.common.ShellExecutor;

@@ -61,10 +62,9 @@ public class ShellControllerTest extends ShellTestCase {
    @Mock
    private ShellCommandHandler mShellCommandHandler;
    @Mock
    private ShellExecutor mExecutor;
    @Mock
    private Context mTestUserContext;

    private TestShellExecutor mExecutor;
    private ShellController mController;
    private TestConfigurationChangeListener mConfigChangeListener;
    private TestKeyguardChangeListener mKeyguardChangeListener;
@@ -77,6 +77,7 @@ public class ShellControllerTest extends ShellTestCase {
        mKeyguardChangeListener = new TestKeyguardChangeListener();
        mConfigChangeListener = new TestConfigurationChangeListener();
        mUserChangeListener = new TestUserChangeListener();
        mExecutor = new TestShellExecutor();
        mController = new ShellController(mShellInit, mShellCommandHandler, mExecutor);
        mController.onConfigurationChanged(getConfigurationCopy());
    }
@@ -104,6 +105,7 @@ public class ShellControllerTest extends ShellTestCase {

        Bundle b = new Bundle();
        mController.asShell().createExternalInterfaces(b);
        mExecutor.flushAll();
        assertTrue(b.getIBinder(EXTRA_TEST_BINDER) == callback);
    }

+2 −2
Original line number Diff line number Diff line
@@ -936,7 +936,7 @@ public class ShellTransitionTests extends ShellTestCase {
        TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
                RunningTaskInfo taskInfo) {
            final TransitionInfo.Change change =
                    new TransitionInfo.Change(null /* token */, null /* leash */);
                    new TransitionInfo.Change(null /* token */, createMockSurface(true));
            change.setMode(mode);
            change.setTaskInfo(taskInfo);
            mInfo.addChange(change);
@@ -961,7 +961,7 @@ public class ShellTransitionTests extends ShellTestCase {
        final TransitionInfo.Change mChange;

        ChangeBuilder(@WindowManager.TransitionType int mode) {
            mChange = new TransitionInfo.Change(null /* token */, null /* leash */);
            mChange = new TransitionInfo.Change(null /* token */, createMockSurface(true));
            mChange.setMode(mode);
        }

+27 −23
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ public class DesktopModeWindowDecorViewModelTests extends ShellTestCase {
                    "testEventReceiversOnMultipleDisplays", /*width=*/ 400, /*height=*/ 400,
                    /*densityDpi=*/ 320, surfaceView.getHolder().getSurface(),
                    DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY);
            try {
                int secondaryDisplayId = secondaryDisplay.getDisplay().getDisplayId();

                final int taskId = 1;
@@ -227,6 +228,9 @@ public class DesktopModeWindowDecorViewModelTests extends ShellTestCase {
                        startT, finishT);
                mDesktopModeWindowDecorViewModel.destroyWindowDecoration(thirdTaskInfo);
                mDesktopModeWindowDecorViewModel.destroyWindowDecoration(taskInfo);
            } finally {
                secondaryDisplay.release();
            }
        });
        verify(mMockInputMonitorFactory, times(2)).create(any(), any());
        verify(mInputMonitor, times(1)).dispose();
@@ -239,7 +243,7 @@ public class DesktopModeWindowDecorViewModelTests extends ShellTestCase {
            r.run();
            latch.countDown();
        });
        latch.await(20, TimeUnit.MILLISECONDS);
        latch.await(1, TimeUnit.SECONDS);
    }

    private static ActivityManager.RunningTaskInfo createTaskInfo(int taskId,
+3 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.view.SurfaceControlViewHost;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.WindowManager.LayoutParams;
import android.window.TaskConstants;
import android.window.WindowContainerTransaction;

import androidx.test.filters.SmallTest;
@@ -232,7 +233,8 @@ public class WindowDecorationTests extends ShellTestCase {
        verify(mMockSurfaceControlStartT)
                .setColor(taskBackgroundSurface, new float[] {1.f, 1.f, 0.f});
        verify(mMockSurfaceControlStartT).setShadowRadius(taskBackgroundSurface, 10);
        verify(mMockSurfaceControlStartT).setLayer(taskBackgroundSurface, -1);
        verify(mMockSurfaceControlStartT).setLayer(taskBackgroundSurface,
                TaskConstants.TASK_CHILD_LAYER_TASK_BACKGROUND);
        verify(mMockSurfaceControlStartT).show(taskBackgroundSurface);

        verify(captionContainerSurfaceBuilder).setParent(decorContainerSurface);