aboutsummaryrefslogtreecommitdiff
path: root/shadows
diff options
context:
space:
mode:
authorTsung-Mao Fang <tmfang@google.com>2021-03-04 15:34:23 +0800
committerTsung-Mao Fang <tmfang@google.com>2021-03-05 04:16:15 +0000
commit6b27a2a5528fdeb3b7742a739d70ceb727bf7003 (patch)
tree30daf068b82e2f2bee5ea0e4d5f8f227a85b3d6e /shadows
parentfed9f5d71095e13880b6f0b19e91ba5db226f793 (diff)
downloadrobolectric-shadows-6b27a2a5528fdeb3b7742a739d70ceb727bf7003.tar.gz
Fix the broken test
attach() of Activity is added a new parameter, so we should modify robolectric code accordingly. Root cause: ag/13449290 Test: Run robo test and pass Fix: 181725244 Change-Id: If4ddf13e67297d54a991c12b82b6bbbc8c56fdc6
Diffstat (limited to 'shadows')
-rw-r--r--shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java
index 64ac51e6a..4a81b003d 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowActivity.java
@@ -210,7 +210,7 @@ public class ShadowActivity extends ShadowContextThemeWrapper {
ReflectionHelpers.ClassParameter.from(
ViewRootImpl.ActivityConfigCallback.class, null) // ADDED
);
- } else if (apiLevel >= Build.VERSION_CODES.Q) {
+ } else if (apiLevel <= Build.VERSION_CODES.R) {
ReflectionHelpers.callInstanceMethod(
Activity.class,
realActivity,
@@ -237,6 +237,34 @@ public class ShadowActivity extends ShadowContextThemeWrapper {
ViewRootImpl.ActivityConfigCallback.class, null),
ReflectionHelpers.ClassParameter.from(IBinder.class, null) // ADDED
);
+ } else if (apiLevel >= Build.VERSION_CODES.S) {
+ ReflectionHelpers.callInstanceMethod(
+ Activity.class,
+ realActivity,
+ "attach",
+ ReflectionHelpers.ClassParameter.from(Context.class, baseContext),
+ ReflectionHelpers.ClassParameter.from(
+ ActivityThread.class, RuntimeEnvironment.getActivityThread()),
+ ReflectionHelpers.ClassParameter.from(Instrumentation.class, instrumentation),
+ ReflectionHelpers.ClassParameter.from(IBinder.class, null),
+ ReflectionHelpers.ClassParameter.from(int.class, 0),
+ ReflectionHelpers.ClassParameter.from(Application.class, application),
+ ReflectionHelpers.ClassParameter.from(Intent.class, intent),
+ ReflectionHelpers.ClassParameter.from(ActivityInfo.class, activityInfo),
+ ReflectionHelpers.ClassParameter.from(CharSequence.class, activityTitle),
+ ReflectionHelpers.ClassParameter.from(Activity.class, null),
+ ReflectionHelpers.ClassParameter.from(String.class, "id"),
+ ReflectionHelpers.ClassParameter.from(nonConfigurationInstancesClass, null),
+ ReflectionHelpers.ClassParameter.from(
+ Configuration.class, application.getResources().getConfiguration()),
+ ReflectionHelpers.ClassParameter.from(String.class, "referrer"),
+ ReflectionHelpers.ClassParameter.from(IVoiceInteractor.class, null),
+ ReflectionHelpers.ClassParameter.from(Window.class, null),
+ ReflectionHelpers.ClassParameter.from(
+ ViewRootImpl.ActivityConfigCallback.class, null),
+ ReflectionHelpers.ClassParameter.from(IBinder.class, null), // ADDED
+ ReflectionHelpers.ClassParameter.from(IBinder.class, null) // ADDED
+ );
} else {
throw new RuntimeException("Could not find AndroidRuntimeAdapter for API level: " + apiLevel);
}