|
|
@ -31,6 +31,7 @@ import androidx.compose.ui.test.DarkMode
|
|
|
|
import androidx.compose.ui.test.DeviceConfigurationOverride
|
|
|
|
import androidx.compose.ui.test.DeviceConfigurationOverride
|
|
|
|
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
|
|
|
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
|
|
|
import androidx.compose.ui.test.onRoot
|
|
|
|
import androidx.compose.ui.test.onRoot
|
|
|
|
|
|
|
|
import androidx.compose.ui.test.printToString
|
|
|
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
|
|
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
|
|
|
import com.github.takahirom.roborazzi.ExperimentalRoborazziApi
|
|
|
|
import com.github.takahirom.roborazzi.ExperimentalRoborazziApi
|
|
|
|
import com.github.takahirom.roborazzi.RoborazziATFAccessibilityCheckOptions
|
|
|
|
import com.github.takahirom.roborazzi.RoborazziATFAccessibilityCheckOptions
|
|
|
@ -42,7 +43,10 @@ import com.github.takahirom.roborazzi.RoborazziOptions.RecordOptions
|
|
|
|
import com.github.takahirom.roborazzi.captureRoboImage
|
|
|
|
import com.github.takahirom.roborazzi.captureRoboImage
|
|
|
|
import com.github.takahirom.roborazzi.checkRoboAccessibility
|
|
|
|
import com.github.takahirom.roborazzi.checkRoboAccessibility
|
|
|
|
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckPreset
|
|
|
|
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckPreset
|
|
|
|
|
|
|
|
import com.google.android.apps.common.testing.accessibility.framework.AccessibilityViewCheckResult
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
|
|
|
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
|
|
|
|
|
|
|
|
import org.hamcrest.Matcher
|
|
|
|
|
|
|
|
import org.hamcrest.Matchers
|
|
|
|
import org.robolectric.RuntimeEnvironment
|
|
|
|
import org.robolectric.RuntimeEnvironment
|
|
|
|
|
|
|
|
|
|
|
|
val DefaultRoborazziOptions =
|
|
|
|
val DefaultRoborazziOptions =
|
|
|
@ -61,10 +65,11 @@ enum class DefaultTestDevices(val description: String, val spec: String) {
|
|
|
|
|
|
|
|
|
|
|
|
fun <A : ComponentActivity> AndroidComposeTestRule<ActivityScenarioRule<A>, A>.captureMultiDevice(
|
|
|
|
fun <A : ComponentActivity> AndroidComposeTestRule<ActivityScenarioRule<A>, A>.captureMultiDevice(
|
|
|
|
screenshotName: String,
|
|
|
|
screenshotName: String,
|
|
|
|
|
|
|
|
accessibilitySuppressions: Matcher<in AccessibilityViewCheckResult> = Matchers.not(Matchers.anything()),
|
|
|
|
body: @Composable () -> Unit,
|
|
|
|
body: @Composable () -> Unit,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
DefaultTestDevices.entries.forEach {
|
|
|
|
listOf(DefaultTestDevices.FOLDABLE).forEach {
|
|
|
|
this.captureForDevice(it.description, it.spec, screenshotName, body = body)
|
|
|
|
this.captureForDevice(it.description, it.spec, screenshotName, body = body, accessibilitySuppressions = accessibilitySuppressions)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -73,6 +78,7 @@ fun <A : ComponentActivity> AndroidComposeTestRule<ActivityScenarioRule<A>, A>.c
|
|
|
|
deviceSpec: String,
|
|
|
|
deviceSpec: String,
|
|
|
|
screenshotName: String,
|
|
|
|
screenshotName: String,
|
|
|
|
roborazziOptions: RoborazziOptions = DefaultRoborazziOptions,
|
|
|
|
roborazziOptions: RoborazziOptions = DefaultRoborazziOptions,
|
|
|
|
|
|
|
|
accessibilitySuppressions: Matcher<in AccessibilityViewCheckResult> = Matchers.not(Matchers.anything()),
|
|
|
|
darkMode: Boolean = false,
|
|
|
|
darkMode: Boolean = false,
|
|
|
|
body: @Composable () -> Unit,
|
|
|
|
body: @Composable () -> Unit,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
@ -102,6 +108,7 @@ fun <A : ComponentActivity> AndroidComposeTestRule<ActivityScenarioRule<A>, A>.c
|
|
|
|
failureLevel = CheckLevel.Warning,
|
|
|
|
failureLevel = CheckLevel.Warning,
|
|
|
|
checker = RoborazziATFAccessibilityChecker(
|
|
|
|
checker = RoborazziATFAccessibilityChecker(
|
|
|
|
preset = AccessibilityCheckPreset.LATEST,
|
|
|
|
preset = AccessibilityCheckPreset.LATEST,
|
|
|
|
|
|
|
|
suppressions = accessibilitySuppressions
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|