diff options
| author | 2023-05-31 13:13:57 -0700 | |
|---|---|---|
| committer | 2023-05-31 13:13:57 -0700 | |
| commit | 87e0e30e7bbbde9a1518c7c46c1dce45f872f689 (patch) | |
| tree | 5b36710a087c8f8cd7345e2de9d509d3bcd73be7 | |
| parent | 0b0a96a857a4c7f085ab1f96db5282688b906e3a (diff) | |
Move Native Graphics initialization into ViewScreenshotTestRule.
Test: atest SystemUIGoogleRoboRNGTests
Bug: 276453135
Change-Id: I7cdcd01c20b8d9c377404c57de6fc375bfeb0648
| -rw-r--r-- | packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt index f96d1e3d7fef..e075abe157d2 100644 --- a/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt +++ b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt @@ -62,6 +62,15 @@ open class ViewScreenshotTestRule( private val isRobolectric = if (Build.FINGERPRINT.contains("robolectric")) true else false override fun apply(base: Statement, description: Description): Statement { + if (isRobolectric) { + // In robolectric mode, we enable NATIVE graphics and unpack font and icu files. + // We need to use reflection, as this library is only needed and therefore + // only available in deviceless mode. + val nativeLoaderClassName = "org.robolectric.nativeruntime.DefaultNativeRuntimeLoader" + val defaultNativeRuntimeLoader = Class.forName(nativeLoaderClassName) + System.setProperty("robolectric.graphicsMode", "NATIVE") + defaultNativeRuntimeLoader.getMethod("injectAndLoad").invoke(null) + } val ruleToApply = if (isRobolectric) roboRule else delegateRule return ruleToApply.apply(base, description) } |