Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke committed Nov 23, 2024
1 parent 4f27c18 commit 3e4f66b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.google.samples.apps.nowinandroid.core.testing.util

import android.graphics.Bitmap.CompressFormat.PNG
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
Expand All @@ -44,10 +45,12 @@ 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.AccessibilityViewCheckResult
import com.google.android.apps.common.testing.accessibility.framework.integrations.espresso.AccessibilityViewCheckException
import com.google.android.apps.common.testing.accessibility.framework.utils.contrast.BitmapImage
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import org.hamcrest.Matcher
import org.hamcrest.Matchers
import org.robolectric.RuntimeEnvironment
import java.io.FileOutputStream

val DefaultRoborazziOptions =
RoborazziOptions(
Expand Down Expand Up @@ -111,7 +114,7 @@ fun <A : ComponentActivity> AndroidComposeTestRule<ActivityScenarioRule<A>, A>.c
failureLevel = CheckLevel.Warning,
checker = RoborazziATFAccessibilityChecker(
preset = AccessibilityCheckPreset.LATEST,
suppressions = accessibilitySuppressions
suppressions = accessibilitySuppressions,
),
),
)
Expand All @@ -128,6 +131,18 @@ fun <A : ComponentActivity> AndroidComposeTestRule<ActivityScenarioRule<A>, A>.c

// Rethrow the Accessibility exception once screenshots have passed
if (accessibilityException != null) {
accessibilityException.results.forEachIndexed { index, check ->
val viewImage = check.viewImage
if (viewImage is BitmapImage) {
FileOutputStream(
"build/outputs/roborazzi/" +
"${screenshotName}_${deviceName}_$index.png",
).use {
viewImage.bitmap.compress(PNG, 100, it)
}
}
}

throw accessibilityException
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class ForYouScreenScreenshotTests {
matchesElements(withText("Done")),

// TODO investigate, seems a false positive
matchesElements(withText("What are you interested in?")),
matchesElements(withText("UI")),
// matchesElements(withText("What are you interested in?")),
// matchesElements(withText("UI")),
),
),
) {
Expand Down

0 comments on commit 3e4f66b

Please sign in to comment.