Skip to content

Commit

Permalink
Use ComposeTestRule interface instead of concrete AndroidComposeTestR…
Browse files Browse the repository at this point in the history
…ule class

This restores Roborazzi's compatibility with customized test rules.
  • Loading branch information
GisoBartels authored and takahirom committed Jan 9, 2024
1 parent c13682c commit 036fbfa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.takahirom.roborazzi

import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.test.espresso.ViewInteraction
import org.junit.rules.TestWatcher
import org.junit.runner.Description
Expand Down Expand Up @@ -86,7 +86,7 @@ class RoborazziRule private constructor(
internal sealed interface CaptureRoot {
object None : CaptureRoot
class Compose(
val composeRule: AndroidComposeTestRule<*, *>,
val composeRule: ComposeTestRule,
val semanticsNodeInteraction: SemanticsNodeInteraction
) : CaptureRoot

Expand All @@ -102,7 +102,7 @@ class RoborazziRule private constructor(
)

constructor(
composeRule: AndroidComposeTestRule<*, *>,
composeRule: ComposeTestRule,
captureRoot: SemanticsNodeInteraction,
options: Options = Options()
) : this(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.core.view.drawToBitmap
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.Espresso.onIdle
Expand Down Expand Up @@ -236,7 +236,7 @@ fun SemanticsNodeInteraction.captureRoboImage(
}

fun SemanticsNodeInteraction.captureRoboGif(
composeRule: AndroidComposeTestRule<*, *>,
composeRule: ComposeTestRule,
filePath: String = DefaultFileNameGenerator.generateFilePath("gif"),
roborazziOptions: RoborazziOptions = provideRoborazziContext().options,
block: () -> Unit
Expand All @@ -255,7 +255,7 @@ fun SemanticsNodeInteraction.captureRoboGif(
}

fun SemanticsNodeInteraction.captureRoboGif(
composeRule: AndroidComposeTestRule<*, *>,
composeRule: ComposeTestRule,
file: File,
roborazziOptions: RoborazziOptions = provideRoborazziContext().options,
block: () -> Unit
Expand Down Expand Up @@ -420,7 +420,7 @@ private fun saveLastImage(

// Only for library, please don't use this directly
fun SemanticsNodeInteraction.captureComposeNode(
composeRule: AndroidComposeTestRule<*, *>,
composeRule: ComposeTestRule,
roborazziOptions: RoborazziOptions = provideRoborazziContext().options,
block: () -> Unit
): CaptureInternalResult {
Expand Down

0 comments on commit 036fbfa

Please sign in to comment.