Loading packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt +47 −20 Original line number Diff line number Diff line Loading @@ -16,22 +16,27 @@ package com.android.systemui.qs.panels.ui.compose import android.platform.test.flag.junit.FlagsParameterization import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.test.assertCountEquals import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithContentDescription import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.text.AnnotatedString import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.FlakyTest import androidx.test.filters.SmallTest import com.android.compose.theme.PlatformTheme import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.qs.flags.QsEditModeTabs import com.android.systemui.qs.panels.shared.model.SizedTileImpl import com.android.systemui.qs.panels.ui.compose.infinitegrid.DefaultEditTileGrid import com.android.systemui.qs.panels.ui.compose.infinitegrid.EditAction Loading @@ -45,11 +50,18 @@ import com.android.systemui.testKosmos import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @FlakyTest(bugId = 360351805) @SmallTest @RunWith(AndroidJUnit4::class) class DragAndDropTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class DragAndDropTest(flags: FlagsParameterization) : SysuiTestCase() { init { mSetFlagsRule.setFlagsParameterization(flags) } @get:Rule val composeRule = createComposeRule() private val kosmos = testKosmos() Loading Loading @@ -79,21 +91,29 @@ class DragAndDropTest : SysuiTestCase() { } } private fun ComposeContentTestRule.setEditContent(listState: EditTileListState) { setContent { EditTileGridUnderTest(listState) } waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select onNodeWithText("Layout").performClick() } } @Test fun draggedTile_shouldDisappear() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) listState.onStarted(listState.tiles[0] as TileGridCell, DragType.Move) // Tile is being dragged, it should be replaced with a placeholder. Assert that only the // copy in the available section is visible composeRule.onAllNodesWithContentDescription("tileA").assertCountEquals(1) // Tile is being dragged, it should be replaced with a placeholder. composeRule.onNodeWithContentDescription("tileA").assertDoesNotExist() // Available tiles should still appear for a move composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // Every other tile should still be in the same order composeRule.assertGridContainsExactly( Loading @@ -111,8 +131,7 @@ class DragAndDropTest : SysuiTestCase() { columns = 4, largeTilesSpan = 2, ) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) val sizedTile = SizedTileImpl(nonRemovableTile, width = 1) listState.onStarted(sizedTile, DragType.Move) Loading @@ -133,8 +152,7 @@ class DragAndDropTest : SysuiTestCase() { fun draggedTile_shouldChangePosition() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) listState.onStarted(listState.tiles[0] as TileGridCell, DragType.Move) Loading @@ -142,7 +160,7 @@ class DragAndDropTest : SysuiTestCase() { listState.onDrop() // Available tiles should appear for a move composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // Tile A and B should swap places composeRule.assertGridContainsExactly( Loading @@ -155,8 +173,7 @@ class DragAndDropTest : SysuiTestCase() { fun draggedTileOut_shouldBeRemoved() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) listState.onStarted(listState.tiles[0] as TileGridCell, DragType.Move) Loading @@ -164,7 +181,7 @@ class DragAndDropTest : SysuiTestCase() { listState.onDrop() // Available tiles should appear for a move composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // Tile A is gone composeRule.assertGridContainsExactly( Loading @@ -177,8 +194,7 @@ class DragAndDropTest : SysuiTestCase() { fun draggedNewTileIn_shouldBeAdded() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) val sizedTile = SizedTileImpl(createEditTile("tile_new", isRemovable = false), width = 1) listState.onStarted(sizedTile, DragType.Add) Loading @@ -193,7 +209,7 @@ class DragAndDropTest : SysuiTestCase() { listState.onDrop() // Available tiles should re-appear composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // tile_new is added after tileD composeRule.assertGridContainsExactly( Loading @@ -202,7 +218,18 @@ class DragAndDropTest : SysuiTestCase() { ) } private fun ComposeContentTestRule.assertAvailableGridExists() { if (!QsEditModeTabs.isEnabled) { onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() } } companion object { @Parameters(name = "{0}") @JvmStatic fun data() = FlagsParameterization.progressionOf(QsEditModeTabs.FLAG_NAME) private const val CURRENT_TILES_GRID_TEST_TAG = "CurrentTilesGrid" private const val AVAILABLE_TILES_GRID_TEST_TAG = "AvailableTilesGrid" Loading packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/InfiniteGridLayoutEditTileGridTest.kt +26 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.qs.panels.ui.compose import android.platform.test.flag.junit.FlagsParameterization import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState Loading @@ -31,7 +32,6 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performTouchInput import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.theme.PlatformTheme import com.android.systemui.SysuiTestCase Loading @@ -40,6 +40,7 @@ import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.qs.composefragment.dagger.usingMediaInComposeFragment import com.android.systemui.qs.flags.QsEditModeTabs import com.android.systemui.qs.panels.data.repository.defaultLargeTilesRepository import com.android.systemui.qs.panels.domain.interactor.iconTilesInteractor import com.android.systemui.qs.panels.ui.compose.infinitegrid.infiniteGridLayout Loading @@ -53,10 +54,17 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(AndroidJUnit4::class) class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class InfiniteGridLayoutEditTileGridTest(flags: FlagsParameterization) : SysuiTestCase() { init { mSetFlagsRule.setFlagsParameterization(flags) } @get:Rule val composeRule = createComposeRule() private val kosmos = Loading Loading @@ -97,6 +105,11 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { composeRule.setContent { TestEditTileGrid() } composeRule.waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select composeRule.onNodeWithText("Layout").performClick() } val stateOnFirstMove = listOf( "bt", Loading Loading @@ -243,6 +256,11 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { composeRule.setContent { TestEditTileGrid() } composeRule.waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select composeRule.onNodeWithText("Layout").performClick() } // Resize tileA to large composeRule .onNodeWithContentDescription("internet") Loading Loading @@ -285,6 +303,11 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { } companion object { @Parameters(name = "{0}") @JvmStatic fun data() = FlagsParameterization.progressionOf(QsEditModeTabs.FLAG_NAME) private const val AVAILABLE_TILES_GRID_TEST_TAG = "AvailableTilesGrid" private val TestEditTiles = listOf( Loading packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/ResizingTest.kt +40 −19 Original line number Diff line number Diff line Loading @@ -16,26 +16,29 @@ package com.android.systemui.qs.panels.ui.compose import android.platform.test.flag.junit.FlagsParameterization import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.test.ExperimentalTestApi import androidx.compose.ui.test.click import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performCustomAccessibilityActionWithLabel import androidx.compose.ui.test.performTouchInput import androidx.compose.ui.test.swipeLeft import androidx.compose.ui.test.swipeRight import androidx.compose.ui.text.AnnotatedString import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.theme.PlatformTheme import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.qs.flags.QsEditModeTabs import com.android.systemui.qs.panels.ui.compose.infinitegrid.DefaultEditTileGrid import com.android.systemui.qs.panels.ui.compose.infinitegrid.EditAction import com.android.systemui.qs.panels.ui.model.GridCell Loading @@ -50,11 +53,18 @@ import com.google.common.truth.Truth.assertThat import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalTestApi::class) @SmallTest @RunWith(AndroidJUnit4::class) class ResizingTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class ResizingTest(flags: FlagsParameterization) : SysuiTestCase() { init { mSetFlagsRule.setFlagsParameterization(flags) } @get:Rule val composeRule = createComposeRule() private val kosmos = testKosmos() Loading Loading @@ -90,13 +100,27 @@ class ResizingTest : SysuiTestCase() { } } private fun ComposeContentTestRule.setEditContent( listState: EditTileListState, tiles: List<EditTileViewModel> = TestEditTiles, largeTiles: Set<TileSpec> = TestLargeTilesSpecs, onResize: (EditAction.ResizeTile) -> Unit = {}, ) { setContent { EditTileGridUnderTest(listState, tiles, largeTiles, onResize) } waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select onNodeWithText("Layout").performClick() } } @Test fun toggleIconTileWithA11yAction_shouldBeLarge() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileA") Loading @@ -114,8 +138,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD_large") Loading @@ -133,8 +156,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileA") Loading @@ -154,8 +176,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD_large") Loading @@ -175,8 +196,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileA") Loading @@ -196,8 +216,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD_large") Loading @@ -224,10 +243,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(testTiles, emptySet(), columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState, testTiles) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState, testTiles) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD") Loading @@ -250,6 +266,11 @@ class ResizingTest : SysuiTestCase() { } companion object { @Parameters(name = "{0}") @JvmStatic fun data() = FlagsParameterization.progressionOf(QsEditModeTabs.FLAG_NAME) private fun createEditTile(tileSpec: String): EditTileViewModel { return EditTileViewModel( tileSpec = TileSpec.create(tileSpec), Loading Loading
packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt +47 −20 Original line number Diff line number Diff line Loading @@ -16,22 +16,27 @@ package com.android.systemui.qs.panels.ui.compose import android.platform.test.flag.junit.FlagsParameterization import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.test.assertCountEquals import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithContentDescription import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.text.AnnotatedString import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.FlakyTest import androidx.test.filters.SmallTest import com.android.compose.theme.PlatformTheme import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.qs.flags.QsEditModeTabs import com.android.systemui.qs.panels.shared.model.SizedTileImpl import com.android.systemui.qs.panels.ui.compose.infinitegrid.DefaultEditTileGrid import com.android.systemui.qs.panels.ui.compose.infinitegrid.EditAction Loading @@ -45,11 +50,18 @@ import com.android.systemui.testKosmos import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @FlakyTest(bugId = 360351805) @SmallTest @RunWith(AndroidJUnit4::class) class DragAndDropTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class DragAndDropTest(flags: FlagsParameterization) : SysuiTestCase() { init { mSetFlagsRule.setFlagsParameterization(flags) } @get:Rule val composeRule = createComposeRule() private val kosmos = testKosmos() Loading Loading @@ -79,21 +91,29 @@ class DragAndDropTest : SysuiTestCase() { } } private fun ComposeContentTestRule.setEditContent(listState: EditTileListState) { setContent { EditTileGridUnderTest(listState) } waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select onNodeWithText("Layout").performClick() } } @Test fun draggedTile_shouldDisappear() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) listState.onStarted(listState.tiles[0] as TileGridCell, DragType.Move) // Tile is being dragged, it should be replaced with a placeholder. Assert that only the // copy in the available section is visible composeRule.onAllNodesWithContentDescription("tileA").assertCountEquals(1) // Tile is being dragged, it should be replaced with a placeholder. composeRule.onNodeWithContentDescription("tileA").assertDoesNotExist() // Available tiles should still appear for a move composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // Every other tile should still be in the same order composeRule.assertGridContainsExactly( Loading @@ -111,8 +131,7 @@ class DragAndDropTest : SysuiTestCase() { columns = 4, largeTilesSpan = 2, ) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) val sizedTile = SizedTileImpl(nonRemovableTile, width = 1) listState.onStarted(sizedTile, DragType.Move) Loading @@ -133,8 +152,7 @@ class DragAndDropTest : SysuiTestCase() { fun draggedTile_shouldChangePosition() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) listState.onStarted(listState.tiles[0] as TileGridCell, DragType.Move) Loading @@ -142,7 +160,7 @@ class DragAndDropTest : SysuiTestCase() { listState.onDrop() // Available tiles should appear for a move composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // Tile A and B should swap places composeRule.assertGridContainsExactly( Loading @@ -155,8 +173,7 @@ class DragAndDropTest : SysuiTestCase() { fun draggedTileOut_shouldBeRemoved() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) listState.onStarted(listState.tiles[0] as TileGridCell, DragType.Move) Loading @@ -164,7 +181,7 @@ class DragAndDropTest : SysuiTestCase() { listState.onDrop() // Available tiles should appear for a move composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // Tile A is gone composeRule.assertGridContainsExactly( Loading @@ -177,8 +194,7 @@ class DragAndDropTest : SysuiTestCase() { fun draggedNewTileIn_shouldBeAdded() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) composeRule.setContent { EditTileGridUnderTest(listState) } composeRule.waitForIdle() composeRule.setEditContent(listState) val sizedTile = SizedTileImpl(createEditTile("tile_new", isRemovable = false), width = 1) listState.onStarted(sizedTile, DragType.Add) Loading @@ -193,7 +209,7 @@ class DragAndDropTest : SysuiTestCase() { listState.onDrop() // Available tiles should re-appear composeRule.onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() composeRule.assertAvailableGridExists() // tile_new is added after tileD composeRule.assertGridContainsExactly( Loading @@ -202,7 +218,18 @@ class DragAndDropTest : SysuiTestCase() { ) } private fun ComposeContentTestRule.assertAvailableGridExists() { if (!QsEditModeTabs.isEnabled) { onNodeWithTag(AVAILABLE_TILES_GRID_TEST_TAG).assertExists() } } companion object { @Parameters(name = "{0}") @JvmStatic fun data() = FlagsParameterization.progressionOf(QsEditModeTabs.FLAG_NAME) private const val CURRENT_TILES_GRID_TEST_TAG = "CurrentTilesGrid" private const val AVAILABLE_TILES_GRID_TEST_TAG = "AvailableTilesGrid" Loading
packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/InfiniteGridLayoutEditTileGridTest.kt +26 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.qs.panels.ui.compose import android.platform.test.flag.junit.FlagsParameterization import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState Loading @@ -31,7 +32,6 @@ import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performTouchInput import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.theme.PlatformTheme import com.android.systemui.SysuiTestCase Loading @@ -40,6 +40,7 @@ import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.qs.composefragment.dagger.usingMediaInComposeFragment import com.android.systemui.qs.flags.QsEditModeTabs import com.android.systemui.qs.panels.data.repository.defaultLargeTilesRepository import com.android.systemui.qs.panels.domain.interactor.iconTilesInteractor import com.android.systemui.qs.panels.ui.compose.infinitegrid.infiniteGridLayout Loading @@ -53,10 +54,17 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(AndroidJUnit4::class) class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class InfiniteGridLayoutEditTileGridTest(flags: FlagsParameterization) : SysuiTestCase() { init { mSetFlagsRule.setFlagsParameterization(flags) } @get:Rule val composeRule = createComposeRule() private val kosmos = Loading Loading @@ -97,6 +105,11 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { composeRule.setContent { TestEditTileGrid() } composeRule.waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select composeRule.onNodeWithText("Layout").performClick() } val stateOnFirstMove = listOf( "bt", Loading Loading @@ -243,6 +256,11 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { composeRule.setContent { TestEditTileGrid() } composeRule.waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select composeRule.onNodeWithText("Layout").performClick() } // Resize tileA to large composeRule .onNodeWithContentDescription("internet") Loading Loading @@ -285,6 +303,11 @@ class InfiniteGridLayoutEditTileGridTest : SysuiTestCase() { } companion object { @Parameters(name = "{0}") @JvmStatic fun data() = FlagsParameterization.progressionOf(QsEditModeTabs.FLAG_NAME) private const val AVAILABLE_TILES_GRID_TEST_TAG = "AvailableTilesGrid" private val TestEditTiles = listOf( Loading
packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/ResizingTest.kt +40 −19 Original line number Diff line number Diff line Loading @@ -16,26 +16,29 @@ package com.android.systemui.qs.panels.ui.compose import android.platform.test.flag.junit.FlagsParameterization import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.test.ExperimentalTestApi import androidx.compose.ui.test.click import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performCustomAccessibilityActionWithLabel import androidx.compose.ui.test.performTouchInput import androidx.compose.ui.test.swipeLeft import androidx.compose.ui.test.swipeRight import androidx.compose.ui.text.AnnotatedString import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.theme.PlatformTheme import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.qs.flags.QsEditModeTabs import com.android.systemui.qs.panels.ui.compose.infinitegrid.DefaultEditTileGrid import com.android.systemui.qs.panels.ui.compose.infinitegrid.EditAction import com.android.systemui.qs.panels.ui.model.GridCell Loading @@ -50,11 +53,18 @@ import com.google.common.truth.Truth.assertThat import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalTestApi::class) @SmallTest @RunWith(AndroidJUnit4::class) class ResizingTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class ResizingTest(flags: FlagsParameterization) : SysuiTestCase() { init { mSetFlagsRule.setFlagsParameterization(flags) } @get:Rule val composeRule = createComposeRule() private val kosmos = testKosmos() Loading Loading @@ -90,13 +100,27 @@ class ResizingTest : SysuiTestCase() { } } private fun ComposeContentTestRule.setEditContent( listState: EditTileListState, tiles: List<EditTileViewModel> = TestEditTiles, largeTiles: Set<TileSpec> = TestLargeTilesSpecs, onResize: (EditAction.ResizeTile) -> Unit = {}, ) { setContent { EditTileGridUnderTest(listState, tiles, largeTiles, onResize) } waitForIdle() if (QsEditModeTabs.isEnabled) { // Tap on Layout tab to select onNodeWithText("Layout").performClick() } } @Test fun toggleIconTileWithA11yAction_shouldBeLarge() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileA") Loading @@ -114,8 +138,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD_large") Loading @@ -133,8 +156,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileA") Loading @@ -154,8 +176,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD_large") Loading @@ -175,8 +196,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileA") Loading @@ -196,8 +216,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(TestEditTiles, TestLargeTilesSpecs, columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD_large") Loading @@ -224,10 +243,7 @@ class ResizingTest : SysuiTestCase() { val listState = EditTileListState(testTiles, emptySet(), columns = 4, largeTilesSpan = 2) var resizedAction: EditAction.ResizeTile? = null composeRule.setContent { EditTileGridUnderTest(listState, testTiles) { resizedAction = it } } composeRule.waitForIdle() composeRule.setEditContent(listState, testTiles) { resizedAction = it } composeRule .onNodeWithContentDescription("tileD") Loading @@ -250,6 +266,11 @@ class ResizingTest : SysuiTestCase() { } companion object { @Parameters(name = "{0}") @JvmStatic fun data() = FlagsParameterization.progressionOf(QsEditModeTabs.FLAG_NAME) private fun createEditTile(tileSpec: String): EditTileViewModel { return EditTileViewModel( tileSpec = TileSpec.create(tileSpec), Loading