Package org.robolectric.shadows
Class ShadowContextWrapper
java.lang.Object
org.robolectric.shadows.ShadowContextWrapper
- Direct Known Subclasses:
- ShadowApplication,- ShadowContextThemeWrapper,- ShadowService
@Implements(android.content.ContextWrapper.class) public class ShadowContextWrapper extends Object
- 
Constructor SummaryConstructors Constructor Description ShadowContextWrapper()
- 
Method SummaryModifier and Type Method Description voidclearBroadcastIntents()Clears the broadcast intents sent during the tests (for all users).voidclearNextStartedActivities()Clears allIntents started byContextWrapper.startActivity(android.content.Intent).voidclearStartedServices()Clears allIntentstarted byContext.startService(android.content.Intent).voiddenyPermissions(int pid, int uid, String... permissions)Revoke the given permissions for the given process and user.voiddenyPermissions(String... permissionNames)Revoke the given permissions for the current process and user.List<Intent>getAllStartedServices()Returns allIntentstarted by#startService(android.content.Intent)without consuming them.List<Intent>getBroadcastIntents()Returns the broadcast intents sent during the tests (for all users).List<Intent>getBroadcastIntentsForUser(UserHandle userHandle)Returns the broadcast intents sent to the given user.BundlegetBroadcastOptions(Intent intent)Returns the broadcast options when the intent was last sent.IntentgetNextStartedActivity()Consumes the most recentIntentstarted byContextWrapper.startActivity(android.content.Intent)and returns it.ShadowActivity.IntentForResultgetNextStartedActivityForResult()Consumes the most recentIntentForResultstarted by {@link * ContextWrapper#startActivity(android.content.Intent, android.os.Bundle)} and returns it.IntentgetNextStartedService()Consumes the most recentIntentstarted byContext.startService(android.content.Intent)and returns it.IntentgetNextStoppedService()Consumes theIntentrequested to stop a service byContext.stopService(android.content.Intent)from the bottom of the stack of stop requests.voidgrantPermissions(int pid, int uid, String... permissions)Grant the given permissions for the given process and user.voidgrantPermissions(String... permissionNames)Grant the given permissions for the current process and user.IntentpeekNextStartedActivity()Returns the most recentIntentstarted byContextWrapper.startActivity(android.content.Intent)without consuming it.ShadowActivity.IntentForResultpeekNextStartedActivityForResult()Returns the most recentIntentForResultstarted byContextWrapper.startActivity(android.content.Intent, android.os.Bundle)without consuming it.IntentpeekNextStartedService()Returns the most recentIntentstarted byContext.startService(android.content.Intent)without consuming it.voidremoveSystemService(String name)MakesContext.getSystemService(String)returnnullfor the given system service name, mimicking a device that doesn't have that system service.
- 
Constructor Details- 
ShadowContextWrapperpublic ShadowContextWrapper()
 
- 
- 
Method Details- 
getBroadcastIntentsReturns the broadcast intents sent during the tests (for all users).
- 
getBroadcastOptionsReturns the broadcast options when the intent was last sent.
- 
getBroadcastIntentsForUserReturns the broadcast intents sent to the given user.
- 
clearBroadcastIntentspublic void clearBroadcastIntents()Clears the broadcast intents sent during the tests (for all users).
- 
getNextStartedActivityConsumes the most recentIntentstarted byContextWrapper.startActivity(android.content.Intent)and returns it.- Returns:
- the most recently started Intent
 
- 
peekNextStartedActivityReturns the most recentIntentstarted byContextWrapper.startActivity(android.content.Intent)without consuming it.- Returns:
- the most recently started Intent
 
- 
clearNextStartedActivitiespublic void clearNextStartedActivities()Clears allIntents started byContextWrapper.startActivity(android.content.Intent).
- 
getNextStartedActivityForResultConsumes the most recentIntentForResultstarted by {@link * ContextWrapper#startActivity(android.content.Intent, android.os.Bundle)} and returns it.- Returns:
- the most recently started IntentForResult
 
- 
peekNextStartedActivityForResultReturns the most recentIntentForResultstarted byContextWrapper.startActivity(android.content.Intent, android.os.Bundle)without consuming it.- Returns:
- the most recently started IntentForResult
 
- 
getNextStartedServiceConsumes the most recentIntentstarted byContext.startService(android.content.Intent)and returns it.- Returns:
- the most recently started Intent
 
- 
peekNextStartedServiceReturns the most recentIntentstarted byContext.startService(android.content.Intent)without consuming it.- Returns:
- the most recently started Intent
 
- 
getAllStartedServicesReturns allIntentstarted by#startService(android.content.Intent)without consuming them.- Returns:
- the list of Intent
 
- 
clearStartedServicespublic void clearStartedServices()Clears allIntentstarted byContext.startService(android.content.Intent).
- 
getNextStoppedServiceConsumes theIntentrequested to stop a service byContext.stopService(android.content.Intent)from the bottom of the stack of stop requests.
- 
grantPermissionsGrant the given permissions for the current process and user.
- 
grantPermissionsGrant the given permissions for the given process and user.
- 
denyPermissionsRevoke the given permissions for the current process and user.Has no effect if permissions were not previously granted. 
- 
denyPermissionsRevoke the given permissions for the given process and user.
- 
removeSystemServiceMakesContext.getSystemService(String)returnnullfor the given system service name, mimicking a device that doesn't have that system service.
 
-