diff options
author | Julia Sullivan <juliansull@google.com> | 2024-04-17 13:41:22 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-04-17 13:42:03 -0700 |
commit | 7c563e9b476b301af28757896040057a5256fbed (patch) | |
tree | 4429cc4a652f6842700759338d5defb250ed3ddb | |
parent | 92fc90561cdb93bee3bc622ec9af11166e5d2660 (diff) | |
download | robolectric-7c563e9b476b301af28757896040057a5256fbed.tar.gz |
Add pickInstrumentation to allow different versions of Instrumentation.
By being protected, any service loaded versions of AndroidTestEnvironment can overwrite the Instrumentation version.
PiperOrigin-RevId: 625792840
-rwxr-xr-x | robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java b/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java index e21545d9f..15918a0c4 100755 --- a/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java +++ b/robolectric/src/main/java/org/robolectric/android/internal/AndroidTestEnvironment.java @@ -594,8 +594,12 @@ public class AndroidTestEnvironment implements TestEnvironment { } } + protected Instrumentation pickInstrumentation() { + return new RoboMonitoringInstrumentation(); + } + private Instrumentation createInstrumentation() { - Instrumentation androidInstrumentation = new RoboMonitoringInstrumentation(); + Instrumentation androidInstrumentation = pickInstrumentation(); androidInstrumentation.runOnMainSync( () -> { ActivityThread activityThread = ReflectionHelpers.callConstructor(ActivityThread.class); |