Import Compound tests from project https://github.com/element-hq/compound-android
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,4 +1,5 @@
|
||||
screenshots/**/*.png filter=lfs diff=lfs merge=lfs -text
|
||||
libraries/compound/screenshots/** filter=lfs diff=lfs merge=lfs -text
|
||||
**/snapshots/**/*.png filter=lfs diff=lfs merge=lfs -text
|
||||
**/docs/images-lfs/*.png filter=lfs diff=lfs merge=lfs -text
|
||||
libraries/mediaupload/impl/src/test/assets/* filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
@@ -56,6 +56,9 @@ echo "Deleting previous screenshots"
|
||||
echo "Record screenshots"
|
||||
./gradlew recordPaparazziDebug --stacktrace $GRADLE_ARGS
|
||||
|
||||
echo "Record screenshots (Compound)"
|
||||
./gradlew :libraries:compound:recordRoborazziDebug --stacktrace -PpreDexEnable=false --max-workers 4 --warn $GRADLE_ARGS
|
||||
|
||||
echo "Committing changes"
|
||||
git config http.sslVerify false
|
||||
|
||||
|
||||
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
@@ -78,6 +78,7 @@ jobs:
|
||||
name: tests-and-screenshot-tests-results
|
||||
path: |
|
||||
**/build/paparazzi/failures/
|
||||
**/build/roborazzi/failures/
|
||||
**/build/reports/tests/*UnitTest/
|
||||
|
||||
# https://github.com/codecov/codecov-action
|
||||
|
||||
@@ -15,6 +15,7 @@ plugins {
|
||||
alias(libs.plugins.compose.compiler) apply false
|
||||
alias(libs.plugins.ksp) apply false
|
||||
alias(libs.plugins.dependencycheck) apply false
|
||||
alias(libs.plugins.roborazzi) apply false
|
||||
alias(libs.plugins.dependencyanalysis)
|
||||
alias(libs.plugins.detekt)
|
||||
alias(libs.plugins.ktlint)
|
||||
@@ -180,16 +181,22 @@ tasks.register("runQualityChecks") {
|
||||
// Make sure to delete old screenshots before recording new ones
|
||||
subprojects {
|
||||
val snapshotsDir = File("${project.projectDir}/src/test/snapshots")
|
||||
val snapshotsDir2 = File("${project.projectDir}/screenshots")
|
||||
val removeOldScreenshotsTask = tasks.register("removeOldSnapshots") {
|
||||
onlyIf { snapshotsDir.exists() }
|
||||
onlyIf { snapshotsDir.exists() || snapshotsDir2.exists() }
|
||||
doFirst {
|
||||
println("Delete previous screenshots located at $snapshotsDir\n")
|
||||
snapshotsDir.deleteRecursively()
|
||||
println("Delete previous screenshots located at $snapshotsDir2\n")
|
||||
snapshotsDir2.deleteRecursively()
|
||||
}
|
||||
}
|
||||
tasks.findByName("recordPaparazzi")?.dependsOn(removeOldScreenshotsTask)
|
||||
tasks.findByName("recordPaparazziDebug")?.dependsOn(removeOldScreenshotsTask)
|
||||
tasks.findByName("recordPaparazziRelease")?.dependsOn(removeOldScreenshotsTask)
|
||||
tasks.findByName("recordRoborazzi")?.dependsOn(removeOldScreenshotsTask)
|
||||
tasks.findByName("recordRoborazziDebug")?.dependsOn(removeOldScreenshotsTask)
|
||||
tasks.findByName("recordRoborazziRelease")?.dependsOn(removeOldScreenshotsTask)
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
@@ -54,3 +54,7 @@ ksp.allow.all.target.configuration=false
|
||||
|
||||
# Used to prevent detekt from reusing invalid cached rules
|
||||
detekt.use.worker.api=true
|
||||
|
||||
# Let test include roborazzi verification
|
||||
# https://github.com/takahirom/roborazzi?tab=readme-ov-file#roborazzitest
|
||||
roborazzi.test.verify=true
|
||||
|
||||
@@ -32,6 +32,7 @@ accompanist = "0.37.3"
|
||||
|
||||
# Test
|
||||
test_core = "1.7.0"
|
||||
roborazzi = "1.46.1"
|
||||
|
||||
# Jetbrain
|
||||
datetime = "0.7.1"
|
||||
@@ -226,6 +227,11 @@ google_autoservice_annotations = { module = "com.google.auto.service:auto-servic
|
||||
# Miscellaneous
|
||||
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
|
||||
|
||||
# Test
|
||||
test_roborazzi = { module = "io.github.takahirom.roborazzi:roborazzi", version.ref = "roborazzi" }
|
||||
test_roborazzi_compose = { module = "io.github.takahirom.roborazzi:roborazzi-compose", version.ref = "roborazzi" }
|
||||
test_roborazzi_junit = { module = "io.github.takahirom.roborazzi:roborazzi-junit-rule", version.ref = "roborazzi" }
|
||||
|
||||
[bundles]
|
||||
|
||||
[plugins]
|
||||
@@ -243,6 +249,7 @@ dependencygraph = "com.savvasdalkitsis.module-dependency-graph:0.12"
|
||||
dependencycheck = "org.owasp.dependencycheck:12.1.6"
|
||||
dependencyanalysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependencyAnalysis" }
|
||||
paparazzi = "app.cash.paparazzi:2.0.0-alpha02"
|
||||
roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
|
||||
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
|
||||
firebaseAppDistribution = { id = "com.google.firebase.appdistribution", version.ref = "firebaseAppDistribution" }
|
||||
knit = { id = "org.jetbrains.kotlinx.knit", version = "0.5.0" }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import extension.testCommonDependencies
|
||||
|
||||
/*
|
||||
* Copyright 2022, 2025 New Vector Ltd.
|
||||
*
|
||||
@@ -7,12 +9,21 @@
|
||||
|
||||
plugins {
|
||||
id("io.element.android-compose-library")
|
||||
alias(libs.plugins.roborazzi)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "io.element.android.compound"
|
||||
|
||||
testOptions {
|
||||
unitTests.isIncludeAndroidResources = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.showkase)
|
||||
testCommonDependencies(libs)
|
||||
testImplementation(libs.test.roborazzi)
|
||||
testImplementation(libs.test.roborazzi.compose)
|
||||
testImplementation(libs.test.roborazzi.junit)
|
||||
}
|
||||
}
|
||||
|
||||
BIN
libraries/compound/screenshots/Avatar Colors - Dark.png
LFS
Normal file
BIN
libraries/compound/screenshots/Avatar Colors - Dark.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Avatar Colors - Light.png
LFS
Normal file
BIN
libraries/compound/screenshots/Avatar Colors - Light.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Icons - Dark.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Icons - Dark.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Icons - Light.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Icons - Light.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Icons - Rtl.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Icons - Rtl.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Semantic Colors - Dark HC.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Semantic Colors - Dark HC.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Semantic Colors - Dark.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Semantic Colors - Dark.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Semantic Colors - Light HC.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Semantic Colors - Light HC.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Semantic Colors - Light.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Semantic Colors - Light.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Typography.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Typography.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Vector Icons - Dark.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Vector Icons - Dark.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Compound Vector Icons - Light.png
LFS
Normal file
BIN
libraries/compound/screenshots/Compound Vector Icons - Light.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/ForcedDarkElementTheme.png
LFS
Normal file
BIN
libraries/compound/screenshots/ForcedDarkElementTheme.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Legacy Colors.png
LFS
Normal file
BIN
libraries/compound/screenshots/Legacy Colors.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Material Typography.png
LFS
Normal file
BIN
libraries/compound/screenshots/Material Typography.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Material3 Colors - Dark HC.png
LFS
Normal file
BIN
libraries/compound/screenshots/Material3 Colors - Dark HC.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Material3 Colors - Dark.png
LFS
Normal file
BIN
libraries/compound/screenshots/Material3 Colors - Dark.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Material3 Colors - Light HC.png
LFS
Normal file
BIN
libraries/compound/screenshots/Material3 Colors - Light HC.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/Material3 Colors - Light.png
LFS
Normal file
BIN
libraries/compound/screenshots/Material3 Colors - Light.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/MaterialText Colors.png
LFS
Normal file
BIN
libraries/compound/screenshots/MaterialText Colors.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/MaterialYou Theme - Dark.png
LFS
Normal file
BIN
libraries/compound/screenshots/MaterialYou Theme - Dark.png
LFS
Normal file
Binary file not shown.
BIN
libraries/compound/screenshots/MaterialYou Theme - Light.png
LFS
Normal file
BIN
libraries/compound/screenshots/MaterialYou Theme - Light.png
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.AvatarColorsPreviewDark
|
||||
import io.element.android.compound.theme.AvatarColorsPreviewLight
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class AvatarColorsTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "xxhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("Avatar Colors - Light.png")) {
|
||||
AvatarColorsPreviewLight()
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Avatar Colors - Dark.png")) {
|
||||
AvatarColorsPreviewDark()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.previews.IconsCompoundPreviewDark
|
||||
import io.element.android.compound.previews.IconsCompoundPreviewLight
|
||||
import io.element.android.compound.previews.IconsCompoundPreviewRtl
|
||||
import io.element.android.compound.previews.IconsPreview
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class CompoundIconTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "w1024dp-h2048dp")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("Compound Icons - Light.png")) {
|
||||
IconsCompoundPreviewLight()
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Compound Icons - Rtl.png")) {
|
||||
IconsCompoundPreviewRtl()
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Compound Icons - Dark.png")) {
|
||||
IconsCompoundPreviewDark()
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Compound Vector Icons - Light.png")) {
|
||||
val content: List<@Composable ColumnScope.() -> Unit> = CompoundIcons.all.map {
|
||||
@Composable { Icon(imageVector = it, contentDescription = null) }
|
||||
}
|
||||
ElementTheme {
|
||||
IconsPreview(
|
||||
title = "Compound Vector Icons",
|
||||
content = content.toImmutableList()
|
||||
)
|
||||
}
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Compound Vector Icons - Dark.png")) {
|
||||
val content: List<@Composable ColumnScope.() -> Unit> = CompoundIcons.all.map {
|
||||
@Composable { Icon(imageVector = it, contentDescription = null) }
|
||||
}
|
||||
ElementTheme(darkTheme = true) {
|
||||
IconsPreview(
|
||||
title = "Compound Vector Icons",
|
||||
content = content.toImmutableList()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.tokens.generated.TypographyTokens
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class CompoundTypographyTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "h2048dp-xxhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("Compound Typography.png")) {
|
||||
ElementTheme {
|
||||
Surface {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
with(TypographyTokens) {
|
||||
TypographyTokenPreview(fontHeadingXlBold, "Heading XL Bold")
|
||||
TypographyTokenPreview(fontHeadingXlRegular, "Heading XL Regular")
|
||||
TypographyTokenPreview(fontHeadingLgBold, "Heading LG Bold")
|
||||
TypographyTokenPreview(fontHeadingLgRegular, "Heading LG Regular")
|
||||
TypographyTokenPreview(fontHeadingMdBold, "Heading MD Bold")
|
||||
TypographyTokenPreview(fontHeadingMdRegular, "Heading MD Regular")
|
||||
TypographyTokenPreview(fontHeadingSmMedium, "Heading SM Medium")
|
||||
TypographyTokenPreview(fontHeadingSmRegular, "Heading SM Regular")
|
||||
TypographyTokenPreview(fontBodyLgMedium, "Body LG Medium")
|
||||
TypographyTokenPreview(fontBodyLgRegular, "Body LG Regular")
|
||||
TypographyTokenPreview(fontBodyMdMedium, "Body MD Medium")
|
||||
TypographyTokenPreview(fontBodyMdRegular, "Body MD Regular")
|
||||
TypographyTokenPreview(fontBodySmMedium, "Body SM Medium")
|
||||
TypographyTokenPreview(fontBodySmRegular, "Body SM Regular")
|
||||
TypographyTokenPreview(fontBodyXsMedium, "Body XS Medium")
|
||||
TypographyTokenPreview(fontBodyXsRegular, "Body XS Regular")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TypographyTokenPreview(style: TextStyle, text: String) {
|
||||
Text(text = text, style = style)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.theme.ForcedDarkElementTheme
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class ForcedDarkElementThemeTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "xxhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("ForcedDarkElementTheme.png")) {
|
||||
ElementTheme {
|
||||
Surface {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
Text(text = "Outside")
|
||||
ForcedDarkElementTheme {
|
||||
Surface {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
Text(text = "Inside ForcedDarkElementTheme", modifier = Modifier.align(Alignment.Center))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.previews.ColorPreview
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.theme.LinkColor
|
||||
import io.element.android.compound.theme.SnackBarLabelColorDark
|
||||
import io.element.android.compound.theme.SnackBarLabelColorLight
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class LegacyColorsTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "xxhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("Legacy Colors.png")) {
|
||||
ElementTheme {
|
||||
Surface {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(text = "Legacy Colors")
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
LegacyColorPreview(
|
||||
color = LinkColor,
|
||||
name = "Link"
|
||||
)
|
||||
LegacyColorPreview(
|
||||
color = SnackBarLabelColorLight,
|
||||
name = "SnackBar Label - Light"
|
||||
)
|
||||
LegacyColorPreview(
|
||||
color = SnackBarLabelColorDark,
|
||||
name = "SnackBar Label - Dark"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LegacyColorPreview(color: Color, name: String) {
|
||||
ColorPreview(
|
||||
backgroundColor = Color.White,
|
||||
foregroundColor = Color.Black,
|
||||
name = name,
|
||||
color = color
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.ColorsSchemeDarkHcPreview
|
||||
import io.element.android.compound.theme.ColorsSchemeDarkPreview
|
||||
import io.element.android.compound.theme.ColorsSchemeLightHcPreview
|
||||
import io.element.android.compound.theme.ColorsSchemeLightPreview
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class MaterialColorSchemeTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "h2048dp-xhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("Material3 Colors - Light.png")) {
|
||||
ElementTheme {
|
||||
Surface {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "M3 Light colors",
|
||||
style = TextStyle.Default.copy(fontSize = 18.sp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
ColorsSchemeLightPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Material3 Colors - Light HC.png")) {
|
||||
ElementTheme {
|
||||
Surface {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "M3 Light HC colors",
|
||||
style = TextStyle.Default.copy(fontSize = 18.sp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
ColorsSchemeLightHcPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Material3 Colors - Dark.png")) {
|
||||
ElementTheme {
|
||||
Surface {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "M3 Dark colors",
|
||||
style = TextStyle.Default.copy(fontSize = 18.sp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
ColorsSchemeDarkPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("Material3 Colors - Dark HC.png")) {
|
||||
ElementTheme {
|
||||
Surface {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "M3 Dark HC colors",
|
||||
style = TextStyle.Default.copy(fontSize = 18.sp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
ColorsSchemeDarkHcPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.MaterialTextPreview
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class MaterialTextTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "w480dp-h1200dp-xxhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("MaterialText Colors.png")) {
|
||||
MaterialTextPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.previews.TypographyPreview
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class MaterialTypographyTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "h2048dp-xxhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("Material Typography.png")) {
|
||||
TypographyPreview()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.previews.ColorsSchemePreview
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class MaterialYouThemeTest {
|
||||
@Test
|
||||
@Config(sdk = [35], qualifiers = "h2048dp-xhdpi")
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("MaterialYou Theme - Light.png")) {
|
||||
ElementTheme(dynamicColor = true) {
|
||||
Surface {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
Text(text = "Material You Theme - Light")
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
ColorsSchemePreview(Color.White, Color.Black, ElementTheme.materialColors)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
captureRoboImage(file = screenshotFile("MaterialYou Theme - Dark.png")) {
|
||||
ElementTheme(dynamicColor = true, darkTheme = true) {
|
||||
Surface {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
Text(text = "Material You Theme - Dark")
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
ColorsSchemePreview(Color.White, Color.Black, ElementTheme.materialColors)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import io.element.android.compound.previews.CompoundSemanticColorsDark
|
||||
import io.element.android.compound.previews.CompoundSemanticColorsDarkHc
|
||||
import io.element.android.compound.previews.CompoundSemanticColorsLight
|
||||
import io.element.android.compound.previews.CompoundSemanticColorsLightHc
|
||||
import io.element.android.compound.screenshot.utils.screenshotFile
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
class SemanticColorsTest {
|
||||
@Config(sdk = [35], qualifiers = "h2000dp-xhdpi")
|
||||
@Test
|
||||
fun screenshots() {
|
||||
captureRoboImage(file = screenshotFile("Compound Semantic Colors - Light.png")) {
|
||||
CompoundSemanticColorsLight()
|
||||
}
|
||||
|
||||
captureRoboImage(file = screenshotFile("Compound Semantic Colors - Light HC.png")) {
|
||||
CompoundSemanticColorsLightHc()
|
||||
}
|
||||
|
||||
captureRoboImage(file = screenshotFile("Compound Semantic Colors - Dark.png")) {
|
||||
CompoundSemanticColorsDark()
|
||||
}
|
||||
|
||||
captureRoboImage(file = screenshotFile("Compound Semantic Colors - Dark HC.png")) {
|
||||
CompoundSemanticColorsDarkHc()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2023, 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.compound.screenshot.utils
|
||||
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Returns a [File] object for a screenshot with the given [filename].
|
||||
* This is to ensure we have a consistent location for all screenshots.
|
||||
*/
|
||||
fun screenshotFile(filename: String): File {
|
||||
return File("screenshots", filename)
|
||||
}
|
||||
Reference in New Issue
Block a user