Skip to content

Commit

Permalink
Improve scrollable screenshots (google#2140)
Browse files Browse the repository at this point in the history
yschimke authored Mar 18, 2024
1 parent ce8db23 commit 536a255
Showing 20 changed files with 41 additions and 61 deletions.
2 changes: 1 addition & 1 deletion auth/composables/api/current.api
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ package com.google.android.horologist.auth.composables.screens {
}

public final class SelectAccountScreenKt {
method @androidx.compose.runtime.Composable public static void SelectAccountScreen(java.util.List<com.google.android.horologist.auth.composables.model.AccountUiModel> accounts, kotlin.jvm.functions.Function2<? super java.lang.Integer,? super com.google.android.horologist.auth.composables.model.AccountUiModel,kotlin.Unit> onAccountClicked, com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, optional androidx.compose.ui.Modifier modifier, optional String title, optional com.google.android.horologist.images.base.paintable.Paintable? defaultAvatar);
method @androidx.compose.runtime.Composable public static void SelectAccountScreen(java.util.List<com.google.android.horologist.auth.composables.model.AccountUiModel> accounts, kotlin.jvm.functions.Function2<? super java.lang.Integer,? super com.google.android.horologist.auth.composables.model.AccountUiModel,kotlin.Unit> onAccountClicked, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, optional String title, optional com.google.android.horologist.images.base.paintable.Paintable? defaultAvatar);
}

public final class SignInPlaceholderScreenKt {
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ import com.google.android.horologist.auth.composables.chips.AccountChip
import com.google.android.horologist.auth.composables.model.AccountUiModel
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.layout.rememberResponsiveColumnState
import com.google.android.horologist.compose.material.Title
import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable
import com.google.android.horologist.images.base.paintable.Paintable
@@ -44,8 +45,8 @@ import com.google.android.horologist.images.base.paintable.Paintable
public fun SelectAccountScreen(
accounts: List<AccountUiModel>,
onAccountClicked: (index: Int, account: AccountUiModel) -> Unit,
columnState: ScalingLazyColumnState,
modifier: Modifier = Modifier,
columnState: ScalingLazyColumnState = rememberResponsiveColumnState(),
title: String = stringResource(id = R.string.horologist_select_account_title),
defaultAvatar: Paintable? = Icons.Default.AccountCircle.asPaintable(),
) {
Original file line number Diff line number Diff line change
@@ -26,18 +26,17 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.test.hasScrollToNodeAction
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeUp
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.Icon
import androidx.wear.compose.material.LocalTextStyle
import androidx.wear.compose.material.MaterialTheme
import androidx.wear.compose.material.Text
import androidx.wear.compose.material.dialog.Alert
import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.google.android.horologist.compose.layout.rememberColumnState
import com.google.android.horologist.compose.material.AlertContent
import com.google.android.horologist.compose.material.Button
import com.google.android.horologist.compose.material.ConfirmationContent
@@ -93,23 +92,14 @@ class DialogTest(device: Device) : ScreenSizeTest(

@Test
fun longDialogScreen1() {
lateinit var columnState: ScalingLazyColumnState

runTest(testFn = {
screenshotTestRule.interact {
runBlocking {
columnState.state.scrollToItem(999, 0)
}
onNode(hasScrollToNodeAction())
.performTouchInput { repeat(10) { swipeUp() } }
}

screenshotTestRule.takeScreenshot()
}) {
columnState = rememberColumnState(
ScalingLazyColumnDefaults.responsive(
additionalPaddingAtBottom = 0.dp,
),
)

AlertContent(
title = "Turn on Bedtime mode?",
message = "Watch screen, tilt-to-wake, and touch are turned off. " +
@@ -119,7 +109,6 @@ class DialogTest(device: Device) : ScreenSizeTest(
onCancel = {},
okButtonContentDescription = stringResource(R.string.ok),
cancelButtonContentDescription = stringResource(R.string.cancel),
state = columnState,
) {
item {
ToggleChip(
@@ -135,23 +124,16 @@ class DialogTest(device: Device) : ScreenSizeTest(

@Test
fun batterySaverScreen() {
lateinit var columnState: ScalingLazyColumnState

runTest(testFn = {
screenshotTestRule.interact {
runBlocking {
columnState.state.scrollToItem(999, 0)
onNode(hasScrollToNodeAction())
.performTouchInput { repeat(10) { swipeUp() } }
}
}

screenshotTestRule.takeScreenshot()
}) {
columnState = rememberColumnState(
ScalingLazyColumnDefaults.responsive(
additionalPaddingAtBottom = 0.dp,
),
)

AlertContent(
icon = {
Icon(
@@ -165,7 +147,6 @@ class DialogTest(device: Device) : ScreenSizeTest(
onCancel = {},
okButtonContentDescription = stringResource(R.string.ok),
cancelButtonContentDescription = stringResource(R.string.cancel),
state = columnState,
) {
item {
Chip(
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ package com.google.android.horologist.screensizes

import com.google.android.horologist.auth.composables.model.AccountUiModel
import com.google.android.horologist.auth.composables.screens.SelectAccountScreen
import com.google.android.horologist.compose.layout.rememberResponsiveColumnState
import com.google.android.horologist.screenshots.rng.WearDevice
import com.google.android.horologist.screenshots.rng.WearDeviceScreenshotTest
import org.junit.Test
@@ -32,7 +31,6 @@ class SelectAccountScreenTest(device: WearDevice) : WearDeviceScreenshotTest(dev
AccountUiModel(email = "thisisaverylongemail@example.com"),
),
onAccountClicked = { _, _ -> },
columnState = rememberResponsiveColumnState(),
)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 536a255

Please sign in to comment.