DisplayContent rotateBounds not keeping same physical position for 180

Rotation_90 + rotation_90 is different from the result of rotation_180
with the current implementation. Should also take care of rotation_180.

Fix: 180751251
Bug: 173124775
Test: atest WmTests:DisplayContentTests
Test: atest WMShellUnitTests:DisplayLayoutTest
Test: atest FrameworksCoreTests:RotationUtilsTest
Change-Id: Ia1c87409b4c4cc412c3fd89e58d08b6ae2069fd0
This commit is contained in:
Chris Li
2021-02-18 14:01:51 -08:00
parent e040263f27
commit 29f24a134c
13 changed files with 194 additions and 128 deletions

View File

@@ -38,6 +38,12 @@ import com.android.internal.R;
import org.junit.Test;
/**
* Tests for {@link DisplayLayout}.
*
* Build/Install/Run:
* atest WMShellUnitTests:DisplayLayoutTest
*/
@SmallTest
public class DisplayLayoutTest {
@@ -70,18 +76,6 @@ public class DisplayLayoutTest {
@Test
public void testRotate() {
// Basic rotate utility
Rect testParent = new Rect(0, 0, 1000, 600);
Rect testInner = new Rect(40, 20, 120, 80);
Rect testResult = new Rect(testInner);
DisplayLayout.rotateBounds(testResult, testParent, 1);
assertEquals(new Rect(20, 880, 80, 960), testResult);
testResult.set(testInner);
DisplayLayout.rotateBounds(testResult, testParent, 2);
assertEquals(new Rect(880, 20, 960, 80), testResult);
testResult.set(testInner);
DisplayLayout.rotateBounds(testResult, testParent, 3);
assertEquals(new Rect(520, 40, 580, 120), testResult);
Resources res = createResources(40, 50, false, 30, 40);
DisplayInfo info = createDisplayInfo(1000, 1500, 60, ROTATION_0);
DisplayLayout dl = new DisplayLayout(info, res, true, true);

View File

@@ -16,6 +16,7 @@
package com.android.wm.shell.pip;
import static android.util.RotationUtils.rotateBounds;
import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_90;
@@ -37,7 +38,6 @@ import android.view.SurfaceControl;
import androidx.test.filters.SmallTest;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.DisplayLayout;
import org.junit.Before;
import org.junit.Test;
@@ -141,7 +141,7 @@ public class PipAnimationControllerTest extends ShellTestCase {
// Apply fraction 1 to compute the end value.
animator.applySurfaceControlTransaction(mLeash, new DummySurfaceControlTx(), 1);
final Rect rotatedEndBounds = new Rect(endBounds);
DisplayLayout.rotateBounds(rotatedEndBounds, endBounds, ROTATION_90);
rotateBounds(rotatedEndBounds, endBounds, ROTATION_90);
assertEquals("Expect 90 degree rotated bounds", rotatedEndBounds, animator.mCurrentValue);
}