Skip to content

Commit

Permalink
Update media player screenshots (#1836)
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored Nov 27, 2023
1 parent c10a024 commit f2444f8
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 21 deletions.
1 change: 1 addition & 0 deletions roboscreenshots/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ package com.google.android.horologist.screenshots {
}

public static final class ScreenshotTestRule.RecordMode.Companion {
method public com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode defaultRecordMode();
method public com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode fromProperty(String? property);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import coil.compose.LocalImageLoader
import com.google.android.horologist.annotations.ExperimentalHorologistApi
import com.google.android.horologist.compose.tools.coil.FakeImageLoader
import com.google.android.horologist.screenshots.RobolectricTempHelpers.capture
import com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode.Companion.defaultRecordMode
import com.google.android.horologist.screenshots.a11y.A11ySnapshotTransformer
import com.quickbird.snapshot.Diffing
import com.quickbird.snapshot.FileSnapshotting
Expand Down Expand Up @@ -335,7 +336,8 @@ public class ScreenshotTestRule(
public var enableA11y: Boolean = false
public var screenTimeText: @Composable () -> Unit = defaultScreenTimeText()
public var testLabel: String? = null
public var record: RecordMode = RecordMode.fromProperty(System.getProperty("screenshot.record"))
public var record: RecordMode = defaultRecordMode()

public var clipMode: ClipMode = ClipMode.Auto

public fun build(): ScreenshotTestRuleParams {
Expand Down Expand Up @@ -365,6 +367,10 @@ public class ScreenshotTestRule(
"repair" -> Repair
else -> Test
}

public fun defaultRecordMode(): RecordMode = RecordMode.fromProperty(
System.getProperty("screenshot.record"),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ import com.google.android.horologist.compose.pager.PagerScreen
import com.google.android.horologist.compose.tools.Device
import com.google.android.horologist.logo.R
import com.google.android.horologist.media.ui.components.animated.AnimatedMediaControlButtons
import com.google.android.horologist.media.ui.components.animated.AnimatedMediaInfoDisplay
import com.google.android.horologist.media.ui.components.background.radialBackgroundBrush
import com.google.android.horologist.media.ui.screens.player.DefaultMediaInfoDisplay
import com.google.android.horologist.media.ui.screens.player.PlayerScreen
import com.google.android.horologist.media.ui.state.PlayerUiState
import com.google.android.horologist.media.ui.state.model.MediaUiModel
import com.google.android.horologist.media.ui.state.model.TrackPositionUiModel
import kotlinx.coroutines.flow.flowOf
import kotlin.time.Duration.Companion.seconds

class MediaPlayerTest(device: Device) : ScreenSizeTest(device = device, showTimeText = true) {
class MediaPlayerTest(device: Device) : ScreenSizeTest(
device = device,
showTimeText = true,
) {

@Composable
override fun Content() {
Expand All @@ -72,7 +75,7 @@ fun MediaPlayerTestCase() {
playing = true,
media = MediaUiModel(
id = "",
title = "Weather with You",
title = "Four Seasons In One Day",
subtitle = "Crowded House",
),
trackPositionUiModel = TrackPositionUiModel.Actual(
Expand Down Expand Up @@ -125,7 +128,12 @@ fun MediaPlayerTestCase() {
}
}
},
mediaDisplay = { DefaultMediaInfoDisplay(playerUiState) },
mediaDisplay = {
AnimatedMediaInfoDisplay(
playerUiState.media,
loading = false,
)
},
controlButtons = {
AnimatedMediaControlButtons(
onPlayButtonClick = { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import com.google.android.horologist.compose.tools.SamsungGalaxyWatch5
import com.google.android.horologist.compose.tools.SamsungGalaxyWatch6Large
import com.google.android.horologist.compose.tools.copy
import com.google.android.horologist.screenshots.ScreenshotBaseTest
import com.google.android.horologist.screenshots.ScreenshotTestRule
import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams
import com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode.Companion.defaultRecordMode
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.ParameterizedRobolectricTestRunner
Expand All @@ -43,12 +45,14 @@ import org.robolectric.shadows.ShadowDisplay
abstract class ScreenSizeTest(
val device: Device,
val showTimeText: Boolean,
recordMode: ScreenshotTestRule.RecordMode = defaultRecordMode(),
) : ScreenshotBaseTest(
screenshotTestRuleParams {
if (!showTimeText) {
screenTimeText = { }
}
testLabel = device.name.lowercase().replace("\\W+".toRegex(), "")
record = recordMode
},
) {
@Composable
Expand Down
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 f2444f8

Please sign in to comment.