Skip to content

Commit 53cb650

Browse files
committed
Add new compareScreenshot function that receives a SemanticsNodeInteraction
1 parent c4be180 commit 53cb650

File tree

1 file changed

+11
-0
lines changed
  • android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots

1 file changed

+11
-0
lines changed

android-snaptesting/src/main/java/com/telefonica/androidsnaptesting/screenshots/ScreenshotsRule.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import android.widget.HorizontalScrollView
1111
import android.widget.ScrollView
1212
import androidx.annotation.RequiresApi
1313
import androidx.compose.ui.graphics.asAndroidBitmap
14+
import androidx.compose.ui.test.SemanticsNodeInteraction
1415
import androidx.compose.ui.test.captureToImage
1516
import androidx.compose.ui.test.junit4.ComposeTestRule
1617
import androidx.compose.ui.test.onRoot
@@ -65,6 +66,16 @@ public class ScreenshotsRule(
6566
compareScreenshot(bitmap, name)
6667
}
6768

69+
@RequiresApi(Build.VERSION_CODES.O)
70+
public fun compareScreenshot(
71+
node: SemanticsNodeInteraction,
72+
name: String? = null
73+
) {
74+
disableFlakyComponentsAndWaitForIdle()
75+
val bitmap = node.captureToImage().asAndroidBitmap()
76+
compareScreenshot(bitmap, name)
77+
}
78+
6879
public fun compareScreenshot(
6980
activity: Activity,
7081
name: String? = null,

0 commit comments

Comments
 (0)