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

Commit 4b1e9bc7 authored by Garfield Tan's avatar Garfield Tan
Browse files

Fix ShellTransitionTests on landscape devices

ShellTransitionTests uses the real primary display and
DisplayController, and the upside down rotation is 90 degrees on some
landscape devices. This CL changes it to a mock so we have better
control on its behavior.

Bug: 242207533
Test: atest ShellTransitionTests
Change-Id: I4cacb79f5a9549f2ad62f42a92b4e01398879b5a
parent fcfe5eec
Loading
Loading
Loading
Loading
+8 −25
Original line number Diff line number Diff line
@@ -59,8 +59,6 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.view.IDisplayWindowListener;
import android.view.IWindowManager;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.WindowManager;
@@ -82,6 +80,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.sysui.ShellInit;
@@ -834,16 +833,13 @@ public class ShellTransitionTests extends ShellTestCase {
    }

    private DisplayController createTestDisplayController() {
        IWindowManager mockWM = mock(IWindowManager.class);
        final IDisplayWindowListener[] displayListener = new IDisplayWindowListener[1];
        try {
            doReturn(new int[]{DEFAULT_DISPLAY}).when(mockWM).registerDisplayWindowListener(any());
        } catch (RemoteException e) {
            // No remote stuff happening, so this can't be hit
        }
        ShellInit shellInit = new ShellInit(mMainExecutor);
        DisplayController out = new DisplayController(mContext, mockWM, shellInit, mMainExecutor);
        shellInit.init();
        DisplayLayout displayLayout = mock(DisplayLayout.class);
        doReturn(Surface.ROTATION_180).when(displayLayout).getUpsideDownRotation();
        // By default we ignore nav bar in deciding if a seamless rotation is allowed.
        doReturn(true).when(displayLayout).allowSeamlessRotationDespiteNavBarMoving();

        DisplayController out = mock(DisplayController.class);
        doReturn(displayLayout).when(out).getDisplayLayout(DEFAULT_DISPLAY);
        return out;
    }

@@ -854,17 +850,4 @@ public class ShellTransitionTests extends ShellTestCase {
        shellInit.init();
        return t;
    }
//
//    private class TestDisplayController extends DisplayController {
//        private final DisplayLayout mTestDisplayLayout;
//        TestDisplayController() {
//            super(mContext, mock(IWindowManager.class), mMainExecutor);
//            mTestDisplayLayout = new DisplayLayout();
//            mTestDisplayLayout.
//        }
//
//        @Override
//        DisplayLayout
//    }

}