summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Schimke <yuri@schimke.ee>2024-05-01 12:04:28 +0100
committerGitHub <noreply@github.com>2024-05-01 12:04:28 +0100
commitcb4d8f06acfbca9b723792a9e48371acefc4374d (patch)
tree427581830994a615a02fe233ecd61d97dfcd2767
parenta37665aef6fafc1173b2873f442f54aee95248f3 (diff)
downloadhorologist-cb4d8f06acfbca9b723792a9e48371acefc4374d.tar.gz
Extreme font scaling screenshot (#2213)
--------- Co-authored-by: yschimke <yschimke@users.noreply.github.com>
-rw-r--r--media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerFontScaleTest.kt117
-rw-r--r--media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_large.png3
-rw-r--r--media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_small.png3
-rw-r--r--media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_large.png3
-rw-r--r--media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_small.png3
-rw-r--r--media/ui/src/test/screenshots/MediaPlayerFontScaleTest_square_large.png3
-rw-r--r--roboscreenshots/api/current.api60
-rw-r--r--roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearDevice.kt112
-rw-r--r--roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt2
9 files changed, 234 insertions, 72 deletions
diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerFontScaleTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerFontScaleTest.kt
new file mode 100644
index 00000000..f00bff40
--- /dev/null
+++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerFontScaleTest.kt
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.android.horologist.media.ui
+
+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 com.google.android.horologist.media.ui.uamp.UampColors
+import com.google.android.horologist.screenshots.rng.WearDevice
+import com.google.android.horologist.screenshots.rng.WearDeviceScreenshotTest
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.ParameterizedRobolectricTestRunner
+import org.robolectric.ParameterizedRobolectricTestRunner.Parameters
+import kotlin.time.Duration.Companion.seconds
+
+@RunWith(ParameterizedRobolectricTestRunner::class)
+class MediaPlayerFontScaleTest(device: WearDevice) : WearDeviceScreenshotTest(device) {
+
+ @Test
+ fun mediaPlayerLargeRound() {
+ mediaPlayerScreen()
+ }
+
+ @Test
+ fun mediaPlayerScreen() {
+ val playerUiState = PlayerUiState(
+ playEnabled = true,
+ pauseEnabled = true,
+ seekBackEnabled = true,
+ seekForwardEnabled = true,
+ seekInCurrentMediaItemEnabled = true,
+ seekToPreviousEnabled = false,
+ seekToNextEnabled = true,
+ shuffleEnabled = false,
+ shuffleOn = false,
+ playPauseEnabled = true,
+ playing = true,
+ media = MediaUiModel.Ready(
+ id = "",
+ title = "Outro - Totally Here and Now (feat. Alan Watts)",
+ subtitle = "The Kyoto Connection",
+ ),
+ trackPositionUiModel = TrackPositionUiModel.Actual(
+ position = 30.seconds,
+ duration = 225.seconds,
+ percent = 0.133f,
+ ),
+ connected = true,
+ )
+
+ runTest {
+ MediaPlayerTestCase(
+ colors = UampColors,
+ playerUiState = playerUiState,
+ )
+ }
+ }
+
+ companion object {
+ @JvmStatic
+ @Parameters
+ fun devices() = listOf(
+
+ WearDevice(
+ id = "small_round_small",
+ modelName = "Generic Small Round",
+ screenSizePx = 384,
+ density = 2.0f,
+ fontScale = 0.94f,
+ ),
+ WearDevice(
+ id = "large_round_small",
+ modelName = "Generic Large Round",
+ screenSizePx = 454,
+ density = 2.0f,
+ fontScale = 0.94f,
+ ),
+ WearDevice(
+ id = "small_round_large",
+ modelName = "Generic Small Round",
+ screenSizePx = 384,
+ density = 2.0f,
+ fontScale = 1.24f,
+ ),
+ WearDevice(
+ id = "large_round_large",
+ modelName = "Generic Large Round",
+ screenSizePx = 454,
+ density = 2.0f,
+ fontScale = 1.24f,
+ ),
+ WearDevice(
+ id = "square_large",
+ modelName = "Generic Large Round",
+ screenSizePx = 360,
+ density = 2.0f,
+ fontScale = 1.24f,
+ isRound = false,
+ ),
+ )
+ }
+}
diff --git a/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_large.png b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_large.png
new file mode 100644
index 00000000..daf97c6c
--- /dev/null
+++ b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_large.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:61eb5b6514d7bccdafec30c5cfc530dce7a03a683ca4a7bd207f972088f9b5e0
+size 110959
diff --git a/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_small.png b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_small.png
new file mode 100644
index 00000000..64631213
--- /dev/null
+++ b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_large_round_small.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:380de3e1639fc25738c0e3f80842bfb8e19d1d291bc9ae1060e5a111437eab54
+size 109251
diff --git a/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_large.png b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_large.png
new file mode 100644
index 00000000..96a4c3f2
--- /dev/null
+++ b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_large.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:102a55ddb0d5b01a9a82eed8ad31098abd7f04cdb598bb6d22097b02b7abf09a
+size 84615
diff --git a/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_small.png b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_small.png
new file mode 100644
index 00000000..9338bdc0
--- /dev/null
+++ b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_small_round_small.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5479f71560aaa90a14a6daf972c44d902db4d633abd5ee8e1182d410a4ad4c89
+size 83833
diff --git a/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_square_large.png b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_square_large.png
new file mode 100644
index 00000000..782c49e5
--- /dev/null
+++ b/media/ui/src/test/screenshots/MediaPlayerFontScaleTest_square_large.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:34b74562ec8420d13d212ca4ee0916d2fe8d05c540f2e5325d945d5bd5a9d84d
+size 73270
diff --git a/roboscreenshots/api/current.api b/roboscreenshots/api/current.api
index 325256bc..133ff64a 100644
--- a/roboscreenshots/api/current.api
+++ b/roboscreenshots/api/current.api
@@ -14,29 +14,51 @@ package com.google.android.horologist.screenshots.rng {
public interface ScreenshotTest {
}
- public enum WearDevice {
- method public final float getDensity();
- method public final int getDp();
- method public final float getFontScale();
- method public final String! getId();
- method public final String! getModelName();
- method public final int getScreenSizePx();
- method public static com.google.android.horologist.screenshots.rng.WearDevice valueOf(String value) throws java.lang.IllegalArgumentException, java.lang.NullPointerException;
- method public static com.google.android.horologist.screenshots.rng.WearDevice[] values();
+ public final class WearDevice {
+ ctor public WearDevice(String id, String modelName, int screenSizePx, float density, optional float fontScale, optional boolean isRound);
+ method public String component1();
+ method public String component2();
+ method public int component3();
+ method public float component4();
+ method public float component5();
+ method public boolean component6();
+ method public com.google.android.horologist.screenshots.rng.WearDevice copy(String id, String modelName, int screenSizePx, float density, float fontScale, boolean isRound);
+ method public float getDensity();
+ method public int getDp();
+ method public float getFontScale();
+ method public String getId();
+ method public String getModelName();
+ method public int getScreenSizePx();
+ method public boolean isRound();
property public final float density;
property public final int dp;
property public final float fontScale;
- property public final String! id;
- property public final String! modelName;
+ property public final String id;
+ property public final boolean isRound;
+ property public final String modelName;
property public final int screenSizePx;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice GenericLargeRound;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice GenericSmallRound;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice GooglePixelWatch;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice GooglePixelWatchLargeFont;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice MobvoiTicWatchPro5;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice SamsungGalaxyWatch5;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice SamsungGalaxyWatch6;
- enum_constant public static final com.google.android.horologist.screenshots.rng.WearDevice SamsungGalaxyWatch6SmallFont;
+ field public static final com.google.android.horologist.screenshots.rng.WearDevice.Companion Companion;
+ }
+
+ public static final class WearDevice.Companion {
+ method public java.util.List<com.google.android.horologist.screenshots.rng.WearDevice> getEntries();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getGenericLargeRound();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getGenericSmallRound();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getGooglePixelWatch();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getGooglePixelWatchLargeFont();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getMobvoiTicWatchPro5();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getSamsungGalaxyWatch5();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getSamsungGalaxyWatch6();
+ method public com.google.android.horologist.screenshots.rng.WearDevice getSamsungGalaxyWatch6SmallFont();
+ property public final com.google.android.horologist.screenshots.rng.WearDevice GenericLargeRound;
+ property public final com.google.android.horologist.screenshots.rng.WearDevice GenericSmallRound;
+ property public final com.google.android.horologist.screenshots.rng.WearDevice GooglePixelWatch;
+ property public final com.google.android.horologist.screenshots.rng.WearDevice GooglePixelWatchLargeFont;
+ property public final com.google.android.horologist.screenshots.rng.WearDevice MobvoiTicWatchPro5;
+ property public final com.google.android.horologist.screenshots.rng.WearDevice SamsungGalaxyWatch5;
+ property public final com.google.android.horologist.screenshots.rng.WearDevice SamsungGalaxyWatch6;
+ property public final com.google.android.horologist.screenshots.rng.WearDevice SamsungGalaxyWatch6SmallFont;
+ property public final java.util.List<com.google.android.horologist.screenshots.rng.WearDevice> entries;
}
@org.junit.runner.RunWith(ParameterizedRobolectricTestRunner::class) public abstract class WearDeviceScreenshotTest extends com.google.android.horologist.screenshots.rng.WearScreenshotTest {
diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearDevice.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearDevice.kt
index 05609766..3b6f6a82 100644
--- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearDevice.kt
+++ b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearDevice.kt
@@ -18,64 +18,72 @@ package com.google.android.horologist.screenshots.rng
import kotlin.math.roundToInt
-public enum class WearDevice(
+public data class WearDevice(
public val id: String,
public val modelName: String,
public val screenSizePx: Int,
public val density: Float,
public val fontScale: Float = 1f,
+ public val isRound: Boolean = true,
) {
- MobvoiTicWatchPro5(
- id = "ticwatch_pro_5",
- modelName = "Mobvoi TicWatch Pro 5",
- screenSizePx = 466,
- density = 2.0f,
- ),
- SamsungGalaxyWatch5(
- id = "galaxy_watch_5",
- modelName = "Samsung Galaxy Watch 5",
- screenSizePx = 396,
- density = 2.0f,
- ),
- SamsungGalaxyWatch6(
- id = "galaxy_watch_6",
- modelName = "Samsung Galaxy Watch 6 Large",
- screenSizePx = 480,
- density = 2.125f,
- ),
- GooglePixelWatch(
- id = "pixel_watch",
- modelName = "Google Pixel Watch",
- screenSizePx = 384,
- density = 2.0f,
- ),
- GenericSmallRound(
- id = "small_round",
- modelName = "Generic Small Round",
- screenSizePx = 384,
- density = 2.0f,
- ),
- GenericLargeRound(
- id = "large_round",
- modelName = "Generic Large Round",
- screenSizePx = 454,
- density = 2.0f,
- ),
- SamsungGalaxyWatch6SmallFont(
- id = "galaxy_watch_6_small_font",
- modelName = "Samsung Galaxy Watch 6 Large",
- screenSizePx = 480,
- density = 2.125f,
- fontScale = 0.94f,
- ),
- GooglePixelWatchLargeFont(
- id = "pixel_watch_large_font",
- modelName = "Google Pixel Watch",
- screenSizePx = 384,
- density = 2.0f,
- fontScale = 1.24f,
- ),
- ;
+ public companion object {
+ public val MobvoiTicWatchPro5: WearDevice = WearDevice(
+ id = "ticwatch_pro_5",
+ modelName = "Mobvoi TicWatch Pro 5",
+ screenSizePx = 466,
+ density = 2.0f,
+ )
+ public val SamsungGalaxyWatch5: WearDevice = WearDevice(
+ id = "galaxy_watch_5",
+ modelName = "Samsung Galaxy Watch 5",
+ screenSizePx = 396,
+ density = 2.0f,
+ )
+ public val SamsungGalaxyWatch6: WearDevice = WearDevice(
+ id = "galaxy_watch_6",
+ modelName = "Samsung Galaxy Watch 6 Large",
+ screenSizePx = 480,
+ density = 2.125f,
+ )
+ public val GooglePixelWatch: WearDevice = WearDevice(
+ id = "pixel_watch",
+ modelName = "Google Pixel Watch",
+ screenSizePx = 384,
+ density = 2.0f,
+ )
+ public val GenericSmallRound: WearDevice = WearDevice(
+ id = "small_round",
+ modelName = "Generic Small Round",
+ screenSizePx = 384,
+ density = 2.0f,
+ )
+ public val GenericLargeRound: WearDevice = WearDevice(
+ id = "large_round",
+ modelName = "Generic Large Round",
+ screenSizePx = 454,
+ density = 2.0f,
+ )
+ public val SamsungGalaxyWatch6SmallFont: WearDevice = SamsungGalaxyWatch6.copy(
+ id = "galaxy_watch_6_small_font",
+ modelName = "Samsung Galaxy Watch 6 Large",
+ fontScale = 0.94f,
+ )
+ public val GooglePixelWatchLargeFont: WearDevice = GooglePixelWatch.copy(
+ id = "pixel_watch_large_font",
+ modelName = "Google Pixel Watch",
+ fontScale = 1.24f,
+ )
+ public val entries: List<WearDevice> = listOf(
+ MobvoiTicWatchPro5,
+ SamsungGalaxyWatch5,
+ SamsungGalaxyWatch6,
+ GooglePixelWatch,
+ GenericSmallRound,
+ GenericLargeRound,
+ SamsungGalaxyWatch6SmallFont,
+ GooglePixelWatchLargeFont,
+ )
+ }
public val dp: Int = (screenSizePx / density).roundToInt()
}
diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt
index 20c417ce..feb95198 100644
--- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt
+++ b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt
@@ -82,7 +82,7 @@ public abstract class WearScreenshotTest {
) {
withDrawingEnabled(forceHardware) {
if (applyDeviceConfig && device != null) {
- RuntimeEnvironment.setQualifiers("+w${device.dp}dp-h${device.dp}dp")
+ RuntimeEnvironment.setQualifiers("+w${device.dp}dp-h${device.dp}dp" + (if (device.isRound) "" else "-notround"))
RuntimeEnvironment.setFontScale(device.fontScale)
}