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

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

Merge "WM: Fix WindowStateTests#testSeamlesslyRotateWindow"

parents aaf60895 d8c664b1
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -4535,7 +4535,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        updateSurfacePosition(getPendingTransaction());
        updateSurfacePosition(getPendingTransaction());
    }
    }


    private void updateSurfacePosition(Transaction t) {
    @VisibleForTesting
    void updateSurfacePosition(Transaction t) {
        if (mSurfaceControl == null) {
        if (mSurfaceControl == null) {
            return;
            return;
        }
        }
+12 −3
Original line number Original line Diff line number Diff line
@@ -370,22 +370,31 @@ public class WindowStateTests extends WindowTestsBase {
        final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
        final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);


        app.mHasSurface = true;
        app.mHasSurface = true;
        app.mToken.mSurfaceControl = mock(SurfaceControl.class);
        app.mSurfaceControl = mock(SurfaceControl.class);
        try {
        try {
            app.getFrameLw().set(10, 20, 60, 80);
            app.getFrameLw().set(10, 20, 60, 80);
            app.updateSurfacePosition(t);


            app.seamlesslyRotateIfAllowed(t, ROTATION_0, ROTATION_90, true);
            app.seamlesslyRotateIfAllowed(t, ROTATION_0, ROTATION_90, true);


            assertTrue(app.mSeamlesslyRotated);
            assertTrue(app.mSeamlesslyRotated);

            // Verify we un-rotate the window state surface.
            Matrix matrix = new Matrix();
            Matrix matrix = new Matrix();
            // Un-rotate 90 deg
            // Un-rotate 90 deg
            matrix.setRotate(270);
            matrix.setRotate(270);
            // Translate it back to origin
            // Translate it back to origin
            matrix.postTranslate(0, mDisplayInfo.logicalWidth);
            matrix.postTranslate(0, mDisplayInfo.logicalWidth);
            verify(t).setMatrix(eq(app.mToken.mSurfaceControl), eq(matrix), any(float[].class));
            verify(t).setMatrix(eq(app.mSurfaceControl), eq(matrix), any(float[].class));

            // Verify we update the position as well.
            float[] currentSurfacePos = {app.mLastSurfacePosition.x, app.mLastSurfacePosition.y};
            matrix.mapPoints(currentSurfacePos);
            verify(t).setPosition(eq(app.mSurfaceControl), eq(currentSurfacePos[0]),
                    eq(currentSurfacePos[1]));
        } finally {
        } finally {
            app.mSurfaceControl = null;
            app.mHasSurface = false;
            app.mHasSurface = false;
            app.mToken.mSurfaceControl = null;
        }
        }
    }
    }