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