Skip to content

Commit

Permalink
Remove TODOs in Roborazzi tests
Browse files Browse the repository at this point in the history
The first TODO, about `robolectric.screenshot.hwrdr.native`, has been here for a couple of versions now.

The second one refers to an issue which has been fixed.
  • Loading branch information
MGaetan89 authored and hoisie committed Nov 19, 2024
1 parent 81b1f61 commit 8ad59e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ class RoborazziCaptureTest {
}

companion object {
// TODO(hoisie): `robolectric.screenshot.hwrdr.native` is obsolete, remove it after the next
// Robolectric point release.
const val USE_HARDWARE_RENDERER_NATIVE_ENV = "robolectric.screenshot.hwrdr.native"
const val PIXEL_COPY_RENDER_MODE = "robolectric.pixelCopyRenderMode"
}
}
Expand All @@ -114,24 +111,15 @@ private fun registerActivityToPackageManager(activity: String) {
.addActivityIfNotPresent(ComponentName(appContext.packageName, activity))
}

@Suppress("ForbiddenComment")
private fun hardwareRendererEnvironment(block: () -> Unit) {
val originalHwrdrOption =
System.getProperty(RoborazziCaptureTest.USE_HARDWARE_RENDERER_NATIVE_ENV, null)
val originalPixelCopyOption =
System.getProperty(RoborazziCaptureTest.PIXEL_COPY_RENDER_MODE, null)
// This cause ClassNotFoundException: java.nio.NioUtils
// TODO: Remove comment out after fix this issue
// https://github.com/robolectric/robolectric/issues/8081#issuecomment-1858726896
// System.setProperty(USE_HARDWARE_RENDERER_NATIVE_ENV, "true")
try {
block()
} finally {
if (originalHwrdrOption == null) {
System.clearProperty(RoborazziCaptureTest.USE_HARDWARE_RENDERER_NATIVE_ENV)
if (originalPixelCopyOption == null) {
System.clearProperty(RoborazziCaptureTest.PIXEL_COPY_RENDER_MODE)
} else {
System.setProperty(RoborazziCaptureTest.USE_HARDWARE_RENDERER_NATIVE_ENV, originalHwrdrOption)
System.setProperty(RoborazziCaptureTest.PIXEL_COPY_RENDER_MODE, originalPixelCopyOption)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ private HardwareRenderingScreenshot() {}

/**
* Indicates whether {@link #takeScreenshot(View, Bitmap)} can run, by validating the API level,
* the presence of the {@link #USE_HARDWARE_RENDERER_NATIVE_ENV} property, and the {@link
* GraphicsMode}.
* the value of the {@link #PIXEL_COPY_RENDER_MODE} property, and the {@link GraphicsMode}.
*/
static boolean canTakeScreenshot(View view) {
return RuntimeEnvironment.getApiLevel() >= P
Expand Down

0 comments on commit 8ad59e2

Please sign in to comment.