Import Compound tests from project https://github.com/element-hq/compound-android
This commit is contained in:
@@ -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