Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0cf69edf authored by Ram Peri's avatar Ram Peri Committed by Automerger Merge Worker
Browse files

Merge "Move Native Graphics initialization into ViewScreenshotTestRule." into...

Merge "Move Native Graphics initialization into ViewScreenshotTestRule." into udc-dev am: 05bdb35b am: 7502632f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23494571



Change-Id: I3a2f9948c1ef5bcc7f6d8c12b2c24faf9468968f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6f650ed5 7502632f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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)
    }