forked from Splitties/ComposeOClock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Splitties#4 from yschimke/screenshot
Add device specific screenshot tests
- Loading branch information
Showing
29 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
[plugins] | ||
|
||
roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" } | ||
|
||
[versions] | ||
composeOClock = "0.1.0-SNAPSHOT" | ||
roborazzi = "1.10.1" | ||
|
||
[libraries] | ||
compose-oclock-core = { group = "org.splitties.compose.oclock", name = "core", version.ref = "composeOClock" } | ||
compose-oclock-watchface-renderer = { group = "org.splitties.compose.oclock", name = "watchface-renderer", version.ref = "composeOClock" } | ||
roborazzi = { group = "io.github.takahirom.roborazzi", name = "roborazzi", version.ref = "roborazzi" } | ||
roborazzi-compose = { group = "io.github.takahirom.roborazzi", name = "roborazzi-compose", version.ref = "roborazzi" } | ||
roborazzi-rule = { group = "io.github.takahirom.roborazzi", name = "roborazzi-junit-rule", version.ref = "roborazzi" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ed/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/BasicAnalogClockTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.splitties.compose.oclock.sample.watchfaces | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
class BasicAnalogClockTest(device: WearDevice) : DeviceClockScreenshotTest(device) { | ||
@Composable | ||
override fun Clock() { | ||
BasicAnalogClock() | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/ClockScreenshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.splitties.compose.oclock.sample.watchfaces | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onRoot | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.github.takahirom.roborazzi.captureRoboImage | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.ParameterizedRobolectricTestRunner | ||
import org.robolectric.RuntimeEnvironment | ||
import org.robolectric.annotation.Config | ||
import org.robolectric.annotation.GraphicsMode | ||
import org.splitties.compose.oclock.OClockRootCanvas | ||
|
||
@Config( | ||
sdk = [33], | ||
qualifiers = "w227dp-h227dp-small-notlong-round-watch-xhdpi-keyshidden-nonav", | ||
) | ||
@GraphicsMode(GraphicsMode.Mode.NATIVE) | ||
abstract class ClockScreenshotTest { | ||
@get:Rule | ||
val composeRule = createComposeRule() | ||
|
||
abstract val device: WearDevice | ||
|
||
fun runTest(isAmbient: Boolean = false, clock: @Composable () -> Unit) { | ||
RuntimeEnvironment.setQualifiers("+w${device.dp}dp-h${device.dp}dp") | ||
|
||
composeRule.setContent { | ||
OClockRootCanvas( | ||
modifier = Modifier.fillMaxSize(), isAmbientFlow = MutableStateFlow(isAmbient) | ||
) { | ||
clock() | ||
} | ||
} | ||
|
||
composeRule.onRoot() | ||
.captureRoboImage("src/test/screenshots/${this.javaClass.simpleName}_${device.id}${if (isAmbient) "_ambient" else ""}.png") | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/ComposeFanClockTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.splitties.compose.oclock.sample.watchfaces | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
class ComposeFanClockTest(device: WearDevice) : DeviceClockScreenshotTest(device) { | ||
@Composable | ||
override fun Clock() { | ||
ComposeFanClock() | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...c/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/DeviceClockScreenshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.splitties.compose.oclock.sample.watchfaces | ||
|
||
import androidx.compose.runtime.Composable | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.ParameterizedRobolectricTestRunner | ||
import org.splitties.compose.oclock.sample.watchfaces.WearDevice.Companion.GooglePixelWatch | ||
import org.splitties.compose.oclock.sample.watchfaces.WearDevice.Companion.MobvoiTicWatchPro5 | ||
import org.splitties.compose.oclock.sample.watchfaces.WearDevice.Companion.SamsungGalaxyWatch5 | ||
|
||
@RunWith(ParameterizedRobolectricTestRunner::class) | ||
abstract class DeviceClockScreenshotTest(override val device: WearDevice): ClockScreenshotTest() { | ||
|
||
@Test | ||
fun interactive() = runTest { | ||
Clock() | ||
} | ||
|
||
@Test | ||
fun ambient() = runTest(isAmbient = true) { | ||
Clock() | ||
} | ||
|
||
@Composable | ||
abstract fun Clock() | ||
|
||
companion object { | ||
@JvmStatic | ||
@ParameterizedRobolectricTestRunner.Parameters | ||
fun devices() = listOf( | ||
MobvoiTicWatchPro5, | ||
SamsungGalaxyWatch5, | ||
GooglePixelWatch, | ||
) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/Devices.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.splitties.compose.oclock.sample.watchfaces | ||
|
||
import kotlin.math.roundToInt | ||
|
||
data class WearDevice( | ||
val id: String, | ||
val modelName: String, | ||
val px: Int, | ||
val density: Float | ||
) { | ||
val dp: Int = (px / density).roundToInt() | ||
|
||
companion object { | ||
val MobvoiTicWatchPro5: WearDevice = WearDevice( | ||
id = "ticwatch_pro_5", | ||
modelName = "Mobvoi TicWatch Pro 5", | ||
px = 466, | ||
density = 2.0f, | ||
) | ||
|
||
val SamsungGalaxyWatch5: WearDevice = WearDevice( | ||
id = "galaxy_watch_5", | ||
modelName = "Samsung Galaxy Watch 5", | ||
px = 396, | ||
density = 2.0f, | ||
) | ||
|
||
val GooglePixelWatch: WearDevice = WearDevice( | ||
id = "pixelwatch", | ||
modelName = "Google Pixel Watch", | ||
px = 384, | ||
density = 2.0f, | ||
) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
shared/src/test/kotlin/org/splitties/compose/oclock/sample/watchfaces/KotlinFanClockTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.splitties.compose.oclock.sample.watchfaces | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
class KotlinFanClockTest(device: WearDevice) : DeviceClockScreenshotTest(device) { | ||
@Composable | ||
override fun Clock() { | ||
KotlinFanClock() | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.6 KB
shared/src/test/screenshots/BasicAnalogClockTest_galaxy_watch_5_ambient.png
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.
Binary file added
BIN
+11.7 KB
shared/src/test/screenshots/BasicAnalogClockTest_pixelwatch_ambient.png
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.
Binary file added
BIN
+13.6 KB
shared/src/test/screenshots/BasicAnalogClockTest_ticwatch_pro_5_ambient.png
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.
Binary file added
BIN
+52.2 KB
shared/src/test/screenshots/ComposeFanClockTest_galaxy_watch_5_ambient.png
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.
Binary file added
BIN
+50.1 KB
shared/src/test/screenshots/ComposeFanClockTest_pixelwatch_ambient.png
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.
Binary file added
BIN
+64.1 KB
shared/src/test/screenshots/ComposeFanClockTest_ticwatch_pro_5_ambient.png
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.
Binary file added
BIN
+25.5 KB
shared/src/test/screenshots/KotlinFanClockTest_galaxy_watch_5_ambient.png
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.
Binary file added
BIN
+25.7 KB
shared/src/test/screenshots/KotlinFanClockTest_pixelwatch_ambient.png
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.
Binary file added
BIN
+30 KB
shared/src/test/screenshots/KotlinFanClockTest_ticwatch_pro_5_ambient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters