Loading quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java +27 −8 Original line number Diff line number Diff line Loading @@ -18,11 +18,15 @@ package com.android.quickstep.util; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.util.ArrayMap; import android.util.DisplayMetrics; import android.view.RemoteAnimationTarget; import android.view.Surface; Loading @@ -35,7 +39,6 @@ import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.LauncherModelHelper; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.ReflectionHelpers; import com.android.launcher3.util.RotationUtils; import com.android.launcher3.util.WindowBounds; import com.android.launcher3.util.window.CachedDisplayInfo; Loading @@ -61,6 +64,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_portrait_noRotation_sameInsets1() { new TaskMatrixVerifier() .withLauncherSize(1200, 2450) .withDensityDpi(420) .withInsets(new Rect(0, 80, 0, 120)) .verifyNoTransforms(); } Loading @@ -69,6 +73,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_portrait_noRotation_sameInsets2() { new TaskMatrixVerifier() .withLauncherSize(1200, 2450) .withDensityDpi(420) .withInsets(new Rect(55, 80, 55, 120)) .verifyNoTransforms(); } Loading @@ -77,6 +82,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_noRotation_sameInsets1() { new TaskMatrixVerifier() .withLauncherSize(2450, 1250) .withDensityDpi(420) .withInsets(new Rect(0, 80, 0, 40)) .verifyNoTransforms(); } Loading @@ -85,6 +91,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_noRotation_sameInsets2() { new TaskMatrixVerifier() .withLauncherSize(2450, 1250) .withDensityDpi(420) .withInsets(new Rect(0, 80, 120, 0)) .verifyNoTransforms(); } Loading @@ -93,6 +100,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_noRotation_sameInsets3() { new TaskMatrixVerifier() .withLauncherSize(2450, 1250) .withDensityDpi(420) .withInsets(new Rect(55, 80, 55, 120)) .verifyNoTransforms(); } Loading @@ -101,6 +109,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_rotated() { new TaskMatrixVerifier() .withLauncherSize(1200, 2450) .withDensityDpi(420) .withInsets(new Rect(0, 80, 0, 120)) .withAppBounds( new Rect(0, 0, 2450, 1200), Loading @@ -112,6 +121,7 @@ public class TaskViewSimulatorTest { private static class TaskMatrixVerifier extends TransformParams { private Point mDisplaySize = new Point(); private int mDensityDpi = DisplayMetrics.DENSITY_DEFAULT; private Rect mDisplayInsets = new Rect(); private Rect mAppBounds = new Rect(); private Rect mLauncherInsets = new Rect(); Loading @@ -129,6 +139,11 @@ public class TaskViewSimulatorTest { return this; } TaskMatrixVerifier withDensityDpi(int densityDpi) { mDensityDpi = densityDpi; return this; } TaskMatrixVerifier withInsets(Rect insets) { mDisplayInsets.set(insets); mLauncherInsets.set(insets); Loading Loading @@ -173,13 +188,17 @@ public class TaskViewSimulatorTest { new ArrayMap<>(); perDisplayBoundsCache.put(cdi.normalize(), allBounds); DisplayController.Info mockInfo = new Info( helper.sandboxContext, wmProxy, perDisplayBoundsCache); Configuration configuration = new Configuration(); configuration.densityDpi = mDensityDpi; Context configurationContext = helper.sandboxContext.createConfigurationContext( configuration); DisplayController.Info info = new Info( configurationContext, wmProxy, perDisplayBoundsCache); DisplayController controller = DisplayController.INSTANCE.get(helper.sandboxContext); controller.close(); ReflectionHelpers.setField(controller, "mInfo", mockInfo); DisplayController mockController = mock(DisplayController.class); when(mockController.getInfo()).thenReturn(info); helper.sandboxContext.putObject(DisplayController.INSTANCE, mockController); mDeviceProfile = InvariantDeviceProfile.INSTANCE.get(helper.sandboxContext) .getBestMatch(mAppBounds.width(), mAppBounds.height(), rotation); Loading @@ -189,7 +208,7 @@ public class TaskViewSimulatorTest { FallbackActivityInterface.INSTANCE); tvs.setDp(mDeviceProfile); int launcherRotation = mockInfo.rotation; int launcherRotation = info.rotation; if (mAppRotation < 0) { mAppRotation = launcherRotation; } Loading Loading
quickstep/tests/src/com/android/quickstep/util/TaskViewSimulatorTest.java +27 −8 Original line number Diff line number Diff line Loading @@ -18,11 +18,15 @@ package com.android.quickstep.util; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.util.ArrayMap; import android.util.DisplayMetrics; import android.view.RemoteAnimationTarget; import android.view.Surface; Loading @@ -35,7 +39,6 @@ import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.LauncherModelHelper; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.ReflectionHelpers; import com.android.launcher3.util.RotationUtils; import com.android.launcher3.util.WindowBounds; import com.android.launcher3.util.window.CachedDisplayInfo; Loading @@ -61,6 +64,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_portrait_noRotation_sameInsets1() { new TaskMatrixVerifier() .withLauncherSize(1200, 2450) .withDensityDpi(420) .withInsets(new Rect(0, 80, 0, 120)) .verifyNoTransforms(); } Loading @@ -69,6 +73,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_portrait_noRotation_sameInsets2() { new TaskMatrixVerifier() .withLauncherSize(1200, 2450) .withDensityDpi(420) .withInsets(new Rect(55, 80, 55, 120)) .verifyNoTransforms(); } Loading @@ -77,6 +82,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_noRotation_sameInsets1() { new TaskMatrixVerifier() .withLauncherSize(2450, 1250) .withDensityDpi(420) .withInsets(new Rect(0, 80, 0, 40)) .verifyNoTransforms(); } Loading @@ -85,6 +91,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_noRotation_sameInsets2() { new TaskMatrixVerifier() .withLauncherSize(2450, 1250) .withDensityDpi(420) .withInsets(new Rect(0, 80, 120, 0)) .verifyNoTransforms(); } Loading @@ -93,6 +100,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_noRotation_sameInsets3() { new TaskMatrixVerifier() .withLauncherSize(2450, 1250) .withDensityDpi(420) .withInsets(new Rect(55, 80, 55, 120)) .verifyNoTransforms(); } Loading @@ -101,6 +109,7 @@ public class TaskViewSimulatorTest { public void taskProperlyScaled_landscape_rotated() { new TaskMatrixVerifier() .withLauncherSize(1200, 2450) .withDensityDpi(420) .withInsets(new Rect(0, 80, 0, 120)) .withAppBounds( new Rect(0, 0, 2450, 1200), Loading @@ -112,6 +121,7 @@ public class TaskViewSimulatorTest { private static class TaskMatrixVerifier extends TransformParams { private Point mDisplaySize = new Point(); private int mDensityDpi = DisplayMetrics.DENSITY_DEFAULT; private Rect mDisplayInsets = new Rect(); private Rect mAppBounds = new Rect(); private Rect mLauncherInsets = new Rect(); Loading @@ -129,6 +139,11 @@ public class TaskViewSimulatorTest { return this; } TaskMatrixVerifier withDensityDpi(int densityDpi) { mDensityDpi = densityDpi; return this; } TaskMatrixVerifier withInsets(Rect insets) { mDisplayInsets.set(insets); mLauncherInsets.set(insets); Loading Loading @@ -173,13 +188,17 @@ public class TaskViewSimulatorTest { new ArrayMap<>(); perDisplayBoundsCache.put(cdi.normalize(), allBounds); DisplayController.Info mockInfo = new Info( helper.sandboxContext, wmProxy, perDisplayBoundsCache); Configuration configuration = new Configuration(); configuration.densityDpi = mDensityDpi; Context configurationContext = helper.sandboxContext.createConfigurationContext( configuration); DisplayController.Info info = new Info( configurationContext, wmProxy, perDisplayBoundsCache); DisplayController controller = DisplayController.INSTANCE.get(helper.sandboxContext); controller.close(); ReflectionHelpers.setField(controller, "mInfo", mockInfo); DisplayController mockController = mock(DisplayController.class); when(mockController.getInfo()).thenReturn(info); helper.sandboxContext.putObject(DisplayController.INSTANCE, mockController); mDeviceProfile = InvariantDeviceProfile.INSTANCE.get(helper.sandboxContext) .getBestMatch(mAppBounds.width(), mAppBounds.height(), rotation); Loading @@ -189,7 +208,7 @@ public class TaskViewSimulatorTest { FallbackActivityInterface.INSTANCE); tvs.setDp(mDeviceProfile); int launcherRotation = mockInfo.rotation; int launcherRotation = info.rotation; if (mAppRotation < 0) { mAppRotation = launcherRotation; } Loading