Merge pull request #844 from vector-im/feature/bma/screenshotTest
Reduce filename size for screenshot test
This commit is contained in:
commit
0bb9070f0d
867 changed files with 34 additions and 55 deletions
|
|
@ -20,13 +20,14 @@ import android.app.Activity
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import com.airbnb.android.showkase.ui.ShowkaseBrowserActivity
|
import com.airbnb.android.showkase.models.Showkase
|
||||||
import com.bumble.appyx.core.modality.BuildContext
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
import com.bumble.appyx.core.node.Node
|
import com.bumble.appyx.core.node.Node
|
||||||
import com.bumble.appyx.core.plugin.Plugin
|
import com.bumble.appyx.core.plugin.Plugin
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
import dagger.assisted.AssistedInject
|
import dagger.assisted.AssistedInject
|
||||||
import io.element.android.anvilannotations.ContributesNode
|
import io.element.android.anvilannotations.ContributesNode
|
||||||
|
import io.element.android.libraries.designsystem.showkase.getBrowserIntent
|
||||||
import io.element.android.libraries.di.SessionScope
|
import io.element.android.libraries.di.SessionScope
|
||||||
|
|
||||||
@ContributesNode(SessionScope::class)
|
@ContributesNode(SessionScope::class)
|
||||||
|
|
@ -40,10 +41,7 @@ class DeveloperSettingsNode @AssistedInject constructor(
|
||||||
override fun View(modifier: Modifier) {
|
override fun View(modifier: Modifier) {
|
||||||
val activity = LocalContext.current as Activity
|
val activity = LocalContext.current as Activity
|
||||||
fun openShowkase() {
|
fun openShowkase() {
|
||||||
val intent = ShowkaseBrowserActivity.getIntent(
|
val intent = Showkase.getBrowserIntent(activity)
|
||||||
context = activity,
|
|
||||||
rootModuleCanonicalName = "io.element.android.libraries.designsystem.showkase.DesignSystemShowkaseRootModule"
|
|
||||||
)
|
|
||||||
activity.startActivity(intent)
|
activity.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,11 @@ import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
import androidx.compose.ui.text.TextLayoutResult
|
import androidx.compose.ui.text.TextLayoutResult
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
|
||||||
import androidx.compose.ui.text.font.FontStyle
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.TextUnit
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||||
|
|
@ -87,19 +84,9 @@ fun Text(
|
||||||
text: AnnotatedString,
|
text: AnnotatedString,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
color: Color = Color.Unspecified,
|
color: Color = Color.Unspecified,
|
||||||
// Will be removed, only style should be used
|
|
||||||
fontSize: TextUnit = TextUnit.Unspecified,
|
|
||||||
fontStyle: FontStyle? = null,
|
fontStyle: FontStyle? = null,
|
||||||
// Will be removed, only style should be used
|
|
||||||
fontWeight: FontWeight? = null,
|
|
||||||
// Will be removed, only style should be used
|
|
||||||
fontFamily: FontFamily? = null,
|
|
||||||
// Will be removed, only style should be used
|
|
||||||
letterSpacing: TextUnit = TextUnit.Unspecified,
|
|
||||||
textDecoration: TextDecoration? = null,
|
textDecoration: TextDecoration? = null,
|
||||||
textAlign: TextAlign? = null,
|
textAlign: TextAlign? = null,
|
||||||
// Will be removed, only style should be used
|
|
||||||
lineHeight: TextUnit = TextUnit.Unspecified,
|
|
||||||
overflow: TextOverflow = TextOverflow.Clip,
|
overflow: TextOverflow = TextOverflow.Clip,
|
||||||
softWrap: Boolean = true,
|
softWrap: Boolean = true,
|
||||||
minLines: Int = 1,
|
minLines: Int = 1,
|
||||||
|
|
@ -112,14 +99,9 @@ fun Text(
|
||||||
text = text,
|
text = text,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
color = color,
|
color = color,
|
||||||
fontSize = fontSize,
|
|
||||||
fontStyle = fontStyle,
|
fontStyle = fontStyle,
|
||||||
fontWeight = fontWeight,
|
|
||||||
fontFamily = fontFamily,
|
|
||||||
letterSpacing = letterSpacing,
|
|
||||||
textDecoration = textDecoration,
|
textDecoration = textDecoration,
|
||||||
textAlign = textAlign,
|
textAlign = textAlign,
|
||||||
lineHeight = lineHeight,
|
|
||||||
overflow = overflow,
|
overflow = overflow,
|
||||||
softWrap = softWrap,
|
softWrap = softWrap,
|
||||||
minLines = minLines,
|
minLines = minLines,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "io.element.android.tests.uitests"
|
// Keep it as short as possible
|
||||||
|
namespace = "ui"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround: `kover` tasks somehow trigger the screenshot tests with a broken configuration, removing
|
// Workaround: `kover` tasks somehow trigger the screenshot tests with a broken configuration, removing
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (c) 2022 New Vector Ltd
|
|
||||||
~
|
|
||||||
~ 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
|
|
||||||
~
|
|
||||||
~ http://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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<manifest/>
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import com.airbnb.android.showkase.annotation.ShowkaseRoot
|
import com.airbnb.android.showkase.annotation.ShowkaseRoot
|
||||||
import com.airbnb.android.showkase.annotation.ShowkaseRootModule
|
import com.airbnb.android.showkase.annotation.ShowkaseRootModule
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import app.cash.paparazzi.DeviceConfig
|
import app.cash.paparazzi.DeviceConfig
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
|
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
|
||||||
|
|
@ -28,4 +28,15 @@ class ComponentTestPreview(
|
||||||
override val name: String = showkaseBrowserComponent.componentName
|
override val name: String = showkaseBrowserComponent.componentName
|
||||||
|
|
||||||
override fun toString(): String = showkaseBrowserComponent.componentKey
|
override fun toString(): String = showkaseBrowserComponent.componentKey
|
||||||
|
// Strip common package beginning
|
||||||
|
.replace("io.element.android.features.", "f.")
|
||||||
|
.replace("io.element.android.libraries.", "l.")
|
||||||
|
.replace("io.element.android.", "")
|
||||||
|
// Reduce default group (if present)
|
||||||
|
.replace("_DefaultGroup_", "_")
|
||||||
|
// No need to include `Preview` suffix of function name
|
||||||
|
.replace("Preview_", "_")
|
||||||
|
// Also for preview annotated with @ElementPreview
|
||||||
|
.replace("Preview-", "-")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.LocaleList
|
import android.os.LocaleList
|
||||||
|
|
@ -48,15 +48,16 @@ import java.util.Locale
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BMA: Inspired from https://github.com/airbnb/Showkase/blob/master/showkase-screenshot-testing-paparazzi-sample/src/test/java/com/airbnb/android/showkase/screenshot/testing/paparazzi/sample/PaparazziSampleScreenshotTest.kt
|
* BMA: Inspired from https://github.com/airbnb/Showkase/blob/master/showkase-screenshot-testing-paparazzi-sample/src/test/java/com/airbnb/android/showkase/screenshot/testing/paparazzi/sample/PaparazziSampleScreenshotTest.kt
|
||||||
*/
|
*
|
||||||
|
|
||||||
/*
|
|
||||||
* Credit to Alex Vanyo for creating this sample in the Now In Android app by Google.
|
* Credit to Alex Vanyo for creating this sample in the Now In Android app by Google.
|
||||||
* PR here - https://github.com/android/nowinandroid/pull/101. Modified the test from that PR to
|
* PR here - https://github.com/android/nowinandroid/pull/101. Modified the test from that PR to
|
||||||
* my own needs for this sample.
|
* my own needs for this sample.
|
||||||
|
*
|
||||||
|
* *Note*: keep the class name as short as possible to get shorter filename for generated screenshot.
|
||||||
|
* Long name was ScreenshotTest.
|
||||||
*/
|
*/
|
||||||
@RunWith(TestParameterInjector::class)
|
@RunWith(TestParameterInjector::class)
|
||||||
class ScreenshotTest {
|
class S {
|
||||||
|
|
||||||
object PreviewProvider : TestParameter.TestParameterValuesProvider {
|
object PreviewProvider : TestParameter.TestParameterValuesProvider {
|
||||||
override fun provideValues(): List<TestPreview> {
|
override fun provideValues(): List<TestPreview> {
|
||||||
|
|
@ -79,8 +80,12 @@ class ScreenshotTest {
|
||||||
renderingMode = SessionParams.RenderingMode.NORMAL,
|
renderingMode = SessionParams.RenderingMode.NORMAL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *Note*: keep the method name as short as possible to get shorter filename for generated screenshot.
|
||||||
|
* Long name was preview_test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun preview_tests(
|
fun t(
|
||||||
@TestParameter(valuesProvider = PreviewProvider::class) componentTestPreview: TestPreview,
|
@TestParameter(valuesProvider = PreviewProvider::class) componentTestPreview: TestPreview,
|
||||||
@TestParameter baseDeviceConfig: BaseDeviceConfig,
|
@TestParameter baseDeviceConfig: BaseDeviceConfig,
|
||||||
@TestParameter(value = ["1.0"/*, "1.5"*/]) fontScale: Float,
|
@TestParameter(value = ["1.0"/*, "1.5"*/]) fontScale: Float,
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.element.android.tests.uitests
|
package ui
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue