Loading quickstep/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ filegroup { filegroup { name: "launcher3-quickstep-tests-src", path: "tests", srcs: ["tests/src/**/*.java"], srcs: ["tests/src/**/*.java", "tests/src/**/*.kt"], } filegroup { Loading tests/src/com/android/launcher3/DeviceProfileGridDimensionsTest.kt→quickstep/tests/src/com/android/quickstep/DeviceProfileQuickstepTest.kt +122 −0 Original line number Diff line number Diff line Loading @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3 package com.android.quickstep import android.graphics.PointF import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.launcher3.DeviceProfileBaseTest import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.util.WindowBounds import com.google.common.truth.Truth.assertThat import org.junit.Test Loading @@ -26,16 +27,14 @@ import org.mockito.ArgumentMatchers import org.mockito.Mockito.`when` as whenever /** * Test for [DeviceProfile] grid dimensions. * * This includes workspace, cell layout, shortcut and widget container, cell sizes, etc. * Test for [DeviceProfile] quickstep. */ @SmallTest @RunWith(AndroidJUnit4::class) class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { class DeviceProfileQuickstepTest : DeviceProfileBaseTest() { @Test fun getCellLayoutWidth_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelWidth() { fun getCellLayoutWidthAndHeight_twoPanelLandscapeScalable4By4GridTablet() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 Loading @@ -44,19 +43,17 @@ class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) whenever(info.smallestSizeDp(ArgumentMatchers.any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() val dp = newDP() val expectedWorkspaceWidth = availableWidth val expectedCellLayoutWidth = (expectedWorkspaceWidth - (dp.workspacePadding.right + dp.workspacePadding.left)) / dp.panelCount assertThat(dp.cellLayoutWidth).isEqualTo(expectedCellLayoutWidth) assertThat(dp.cellLayoutWidth).isEqualTo(1235) assertThat(dp.cellLayoutHeight).isEqualTo(1235) } @Test fun getCellLayoutHeight_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelHeight() { fun getCellSize_twoPanelLandscapeScalable4By4GridTablet() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 Loading @@ -65,18 +62,17 @@ class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) whenever(info.smallestSizeDp(ArgumentMatchers.any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() val dp = newDP() val expectedWorkspaceHeight = availableHeight val expectedCellLayoutHeight = expectedWorkspaceHeight - (dp.workspacePadding.top + dp.workspacePadding.bottom) assertThat(dp.cellLayoutHeight).isEqualTo(expectedCellLayoutHeight) assertThat(dp.getCellSize().y).isEqualTo(264) assertThat(dp.getCellSize().x).isEqualTo(258) } @Test fun getCellSize_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelWidth() { fun getPanelCount_twoPanelLandscapeScalable4By4GridTablet() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 Loading @@ -85,44 +81,42 @@ class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) whenever(info.smallestSizeDp(ArgumentMatchers.any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() val dp = newDP() val expectedWorkspaceWidth = availableWidth val expectedCellLayoutWidth = (expectedWorkspaceWidth - (dp.workspacePadding.right + dp.workspacePadding.left)) / dp.panelCount val expectedShortcutAndWidgetContainerWidth = expectedCellLayoutWidth - (dp.cellLayoutPaddingPx.left + dp.cellLayoutPaddingPx.right) assertThat(dp.getCellSize().x).isEqualTo( (expectedShortcutAndWidgetContainerWidth - ((inv!!.numColumns - 1) * dp.cellLayoutBorderSpacePx.x)) / inv!!.numColumns) val expectedWorkspaceHeight = availableHeight val expectedCellLayoutHeight = expectedWorkspaceHeight - (dp.workspacePadding.top + dp.workspacePadding.bottom) val expectedShortcutAndWidgetContainerHeight = expectedCellLayoutHeight - (dp.cellLayoutPaddingPx.top + dp.cellLayoutPaddingPx.bottom) assertThat(dp.getCellSize().y).isEqualTo( (expectedShortcutAndWidgetContainerHeight - ((inv!!.numRows - 1) * dp.cellLayoutBorderSpacePx.y)) / inv!!.numRows) assertThat(dp.panelCount).isEqualTo(2) } @Test fun getPanelCount_twoPanelLandscapeScalable4By4GridTablet_equalsTwoPanels() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 val availableHeight = 1500 windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0) useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) fun getWorkspaceSpringLoadShrunkTopBottom_landscapePhoneVerticalBar() { inv = newScalableInvariantDeviceProfile() initializeVarsForPhone(true) inv = newScalableInvariantDeviceProfile().apply { deviceType = InvariantDeviceProfile.TYPE_PHONE transposeLayoutWithOrientation = true } val dp = newDP() assertThat(dp.panelCount).isEqualTo(2) assertThat(dp.isVerticalBarLayout).isEqualTo(true) assertThat(dp.cellLayoutSpringLoadShrunkTop).isEqualTo(168) assertThat(dp.cellLayoutSpringLoadShrunkBottom).isEqualTo(1358) } @Test fun getWorkspaceSpringLoadShrunkTopBottom_portraitPhone() { inv = newScalableInvariantDeviceProfile() initializeVarsForPhone() inv = newScalableInvariantDeviceProfile().apply { deviceType = InvariantDeviceProfile.TYPE_PHONE } val dp = newDP() assertThat(dp.isVerticalBarLayout).isEqualTo(false) assertThat(dp.cellLayoutSpringLoadShrunkTop).isEqualTo(364) assertThat(dp.cellLayoutSpringLoadShrunkBottom).isEqualTo(2199) } } No newline at end of file src/com/android/launcher3/DeviceProfile.java +3 −6 Original line number Diff line number Diff line Loading @@ -930,15 +930,12 @@ public class DeviceProfile { * Gets the space in px from the bottom of last item in the vertical-bar hotseat to the * bottom of the screen. */ public int getVerticalHotseatLastItemBottomOffset() { private int getVerticalHotseatLastItemBottomOffset() { int cellHeight = calculateCellHeight( heightPx - mHotseatPadding.top - mHotseatPadding.bottom, hotseatBorderSpace, numShownHotseatIcons); int hotseatSize = (cellHeight * numShownHotseatIcons) + (hotseatBorderSpace * (numShownHotseatIcons - 1)); int extraHotseatEndSpacing = (heightPx - hotseatSize) / 2; int extraIconEndSpacing = (cellHeight - iconSizePx) / 2; return extraHotseatEndSpacing + extraIconEndSpacing + mHotseatPadding.bottom; return extraIconEndSpacing + mHotseatPadding.bottom; } /** Loading @@ -953,7 +950,7 @@ public class DeviceProfile { /** * Gets the scaled bottom of the workspace in px for the spring-loaded edit state. */ private float getCellLayoutSpringLoadShrunkBottom() { public float getCellLayoutSpringLoadShrunkBottom() { int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx; workspaceSpringLoadShrunkBottom = heightPx - (isVerticalBarLayout() ? getVerticalHotseatLastItemBottomOffset() Loading tests/src/com/android/launcher3/DeviceProfileBaseTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ abstract class DeviceProfileBaseTest { whenever(info.isTablet(any())).thenReturn(false) whenever(info.getDensityDpi()).thenReturn(560) whenever(info.smallestSizeDp(any())).thenReturn(411f) inv = newScalableInvariantDeviceProfile() } Loading @@ -79,6 +80,7 @@ abstract class DeviceProfileBaseTest { whenever(info.isTablet(any())).thenReturn(true) whenever(info.getDensityDpi()).thenReturn(320) whenever(info.smallestSizeDp(any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() } Loading Loading
quickstep/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ filegroup { filegroup { name: "launcher3-quickstep-tests-src", path: "tests", srcs: ["tests/src/**/*.java"], srcs: ["tests/src/**/*.java", "tests/src/**/*.kt"], } filegroup { Loading
tests/src/com/android/launcher3/DeviceProfileGridDimensionsTest.kt→quickstep/tests/src/com/android/quickstep/DeviceProfileQuickstepTest.kt +122 −0 Original line number Diff line number Diff line Loading @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3 package com.android.quickstep import android.graphics.PointF import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.launcher3.DeviceProfileBaseTest import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.util.WindowBounds import com.google.common.truth.Truth.assertThat import org.junit.Test Loading @@ -26,16 +27,14 @@ import org.mockito.ArgumentMatchers import org.mockito.Mockito.`when` as whenever /** * Test for [DeviceProfile] grid dimensions. * * This includes workspace, cell layout, shortcut and widget container, cell sizes, etc. * Test for [DeviceProfile] quickstep. */ @SmallTest @RunWith(AndroidJUnit4::class) class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { class DeviceProfileQuickstepTest : DeviceProfileBaseTest() { @Test fun getCellLayoutWidth_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelWidth() { fun getCellLayoutWidthAndHeight_twoPanelLandscapeScalable4By4GridTablet() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 Loading @@ -44,19 +43,17 @@ class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) whenever(info.smallestSizeDp(ArgumentMatchers.any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() val dp = newDP() val expectedWorkspaceWidth = availableWidth val expectedCellLayoutWidth = (expectedWorkspaceWidth - (dp.workspacePadding.right + dp.workspacePadding.left)) / dp.panelCount assertThat(dp.cellLayoutWidth).isEqualTo(expectedCellLayoutWidth) assertThat(dp.cellLayoutWidth).isEqualTo(1235) assertThat(dp.cellLayoutHeight).isEqualTo(1235) } @Test fun getCellLayoutHeight_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelHeight() { fun getCellSize_twoPanelLandscapeScalable4By4GridTablet() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 Loading @@ -65,18 +62,17 @@ class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) whenever(info.smallestSizeDp(ArgumentMatchers.any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() val dp = newDP() val expectedWorkspaceHeight = availableHeight val expectedCellLayoutHeight = expectedWorkspaceHeight - (dp.workspacePadding.top + dp.workspacePadding.bottom) assertThat(dp.cellLayoutHeight).isEqualTo(expectedCellLayoutHeight) assertThat(dp.getCellSize().y).isEqualTo(264) assertThat(dp.getCellSize().x).isEqualTo(258) } @Test fun getCellSize_twoPanelLandscapeScalable4By4GridTablet_equalsSinglePanelWidth() { fun getPanelCount_twoPanelLandscapeScalable4By4GridTablet() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 Loading @@ -85,44 +81,42 @@ class DeviceProfileGridDimensionsTest : DeviceProfileBaseTest() { useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) whenever(info.smallestSizeDp(ArgumentMatchers.any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() val dp = newDP() val expectedWorkspaceWidth = availableWidth val expectedCellLayoutWidth = (expectedWorkspaceWidth - (dp.workspacePadding.right + dp.workspacePadding.left)) / dp.panelCount val expectedShortcutAndWidgetContainerWidth = expectedCellLayoutWidth - (dp.cellLayoutPaddingPx.left + dp.cellLayoutPaddingPx.right) assertThat(dp.getCellSize().x).isEqualTo( (expectedShortcutAndWidgetContainerWidth - ((inv!!.numColumns - 1) * dp.cellLayoutBorderSpacePx.x)) / inv!!.numColumns) val expectedWorkspaceHeight = availableHeight val expectedCellLayoutHeight = expectedWorkspaceHeight - (dp.workspacePadding.top + dp.workspacePadding.bottom) val expectedShortcutAndWidgetContainerHeight = expectedCellLayoutHeight - (dp.cellLayoutPaddingPx.top + dp.cellLayoutPaddingPx.bottom) assertThat(dp.getCellSize().y).isEqualTo( (expectedShortcutAndWidgetContainerHeight - ((inv!!.numRows - 1) * dp.cellLayoutBorderSpacePx.y)) / inv!!.numRows) assertThat(dp.panelCount).isEqualTo(2) } @Test fun getPanelCount_twoPanelLandscapeScalable4By4GridTablet_equalsTwoPanels() { val tabletWidth = 2560 val tabletHeight = 1600 val availableWidth = 2560 val availableHeight = 1500 windowBounds = WindowBounds(tabletWidth, tabletHeight, availableWidth, availableHeight, 0) useTwoPanels = true whenever(info.isTablet(ArgumentMatchers.any())).thenReturn(true) whenever(info.densityDpi).thenReturn(320) fun getWorkspaceSpringLoadShrunkTopBottom_landscapePhoneVerticalBar() { inv = newScalableInvariantDeviceProfile() initializeVarsForPhone(true) inv = newScalableInvariantDeviceProfile().apply { deviceType = InvariantDeviceProfile.TYPE_PHONE transposeLayoutWithOrientation = true } val dp = newDP() assertThat(dp.panelCount).isEqualTo(2) assertThat(dp.isVerticalBarLayout).isEqualTo(true) assertThat(dp.cellLayoutSpringLoadShrunkTop).isEqualTo(168) assertThat(dp.cellLayoutSpringLoadShrunkBottom).isEqualTo(1358) } @Test fun getWorkspaceSpringLoadShrunkTopBottom_portraitPhone() { inv = newScalableInvariantDeviceProfile() initializeVarsForPhone() inv = newScalableInvariantDeviceProfile().apply { deviceType = InvariantDeviceProfile.TYPE_PHONE } val dp = newDP() assertThat(dp.isVerticalBarLayout).isEqualTo(false) assertThat(dp.cellLayoutSpringLoadShrunkTop).isEqualTo(364) assertThat(dp.cellLayoutSpringLoadShrunkBottom).isEqualTo(2199) } } No newline at end of file
src/com/android/launcher3/DeviceProfile.java +3 −6 Original line number Diff line number Diff line Loading @@ -930,15 +930,12 @@ public class DeviceProfile { * Gets the space in px from the bottom of last item in the vertical-bar hotseat to the * bottom of the screen. */ public int getVerticalHotseatLastItemBottomOffset() { private int getVerticalHotseatLastItemBottomOffset() { int cellHeight = calculateCellHeight( heightPx - mHotseatPadding.top - mHotseatPadding.bottom, hotseatBorderSpace, numShownHotseatIcons); int hotseatSize = (cellHeight * numShownHotseatIcons) + (hotseatBorderSpace * (numShownHotseatIcons - 1)); int extraHotseatEndSpacing = (heightPx - hotseatSize) / 2; int extraIconEndSpacing = (cellHeight - iconSizePx) / 2; return extraHotseatEndSpacing + extraIconEndSpacing + mHotseatPadding.bottom; return extraIconEndSpacing + mHotseatPadding.bottom; } /** Loading @@ -953,7 +950,7 @@ public class DeviceProfile { /** * Gets the scaled bottom of the workspace in px for the spring-loaded edit state. */ private float getCellLayoutSpringLoadShrunkBottom() { public float getCellLayoutSpringLoadShrunkBottom() { int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx; workspaceSpringLoadShrunkBottom = heightPx - (isVerticalBarLayout() ? getVerticalHotseatLastItemBottomOffset() Loading
tests/src/com/android/launcher3/DeviceProfileBaseTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ abstract class DeviceProfileBaseTest { whenever(info.isTablet(any())).thenReturn(false) whenever(info.getDensityDpi()).thenReturn(560) whenever(info.smallestSizeDp(any())).thenReturn(411f) inv = newScalableInvariantDeviceProfile() } Loading @@ -79,6 +80,7 @@ abstract class DeviceProfileBaseTest { whenever(info.isTablet(any())).thenReturn(true) whenever(info.getDensityDpi()).thenReturn(320) whenever(info.smallestSizeDp(any())).thenReturn(800f) inv = newScalableInvariantDeviceProfile() } Loading