@Implements(value=android.app.Application.class) public class ShadowApplication extends ShadowContextWrapper
| Modifier and Type | Class and Description |
|---|---|
static class |
ShadowApplication.Wrapper |
| Constructor and Description |
|---|
ShadowApplication() |
| Modifier and Type | Method and Description |
|---|---|
void |
addWakeLock(PowerManager.WakeLock wl) |
void |
assertNoBroadcastListenersOfActionRegistered(ContextWrapper context,
String action) |
void |
callAttach(Context context)
Attaches an application to a base context.
|
void |
checkActivities(boolean checkActivities)
Set to true if you’d like Robolectric to strictly simulate the real Android behavior when calling
Context.startActivity(android.content.Intent). |
void |
clearRegisteredReceivers()
Removes all registered receivers.
|
void |
clearWakeLocks() |
void |
declareActionUnbindable(String action) |
AppWidgetManager |
getAppWidgetManager()
Deprecated.
Please use
Context#getSystemService(Context.APPWIDGET_SERVICE) intstead. |
org.robolectric.util.Scheduler |
getBackgroundThreadScheduler()
Return the background scheduler.
|
Object |
getBluetoothAdapter() |
List<ServiceConnection> |
getBoundServiceConnections() |
org.robolectric.util.Scheduler |
getForegroundThreadScheduler()
Return the foreground scheduler.
|
static ShadowApplication |
getInstance()
Deprecated.
Use
shadowOf( instead. |
ShadowAlertDialog |
getLatestAlertDialog()
Deprecated.
Use
ShadowAlertDialog.getLatestAlertDialog() instead. |
ShadowDialog |
getLatestDialog()
Deprecated.
Use
ShadowDialog.getLatestDialog() instead. |
ListPopupWindow |
getLatestListPopupWindow() |
ShadowPopupMenu |
getLatestPopupMenu()
Deprecated.
Use
ShadowPopupMenu.getLatestPopupMenu() instead. |
PopupWindow |
getLatestPopupWindow() |
PowerManager.WakeLock |
getLatestWakeLock() |
List<BroadcastReceiver> |
getReceiversForIntent(Intent intent)
Deprecated.
use PackageManager.queryBroadcastReceivers instead
|
List<ShadowApplication.Wrapper> |
getRegisteredReceivers() |
List<Toast> |
getShownToasts() |
<T> T |
getSingleton(Class<T> clazz,
Provider<T> provider) |
List<ServiceConnection> |
getUnboundServiceConnections() |
boolean |
hasReceiverForIntent(Intent intent)
Deprecated.
use PackageManager.queryBroadcastReceivers instead
|
static void |
runBackgroundTasks()
Runs any background tasks previously queued by
AsyncTask.execute(Object[]). |
void |
setComponentNameAndServiceForBindService(ComponentName name,
IBinder service) |
void |
setComponentNameAndServiceForBindServiceForIntent(Intent intent,
ComponentName name,
IBinder service) |
protected void |
setLatestAlertDialog(ShadowAlertDialog latestAlertDialog) |
protected void |
setLatestDialog(ShadowDialog latestDialog) |
protected void |
setLatestListPopupWindow(ListPopupWindow latestListPopupWindow) |
protected void |
setLatestPopupMenu(ShadowPopupMenu latestPopupMenu) |
protected void |
setLatestPopupWindow(PopupWindow latestPopupWindow) |
void |
setSystemService(String key,
Object service)
Deprecated.
Do not depend on this method to override services as it will be removed in a future update. The preferered method is use the shadow of the corresponding service.
|
void |
setUnbindServiceShouldThrowIllegalArgument(boolean flag) |
clearNextStartedActivities, clearStartedServices, denyPermissions, denyPermissions, getBroadcastIntents, getNextStartedActivity, getNextStartedActivityForResult, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, peekNextStartedActivityForResult, peekNextStartedService, removeSystemService@Deprecated public static ShadowApplication getInstance()
shadowOf(androidx.test.core.app.ApplicationProvider#getApplicationContext) instead.public static void runBackgroundTasks()
Runs any background tasks previously queued by AsyncTask.execute(Object[]).
Note: calling this method does not pause or un-pause the scheduler.
public void callAttach(Context context)
Attaches an application to a base context.
context - The context with which to initialize the application, whose base context will be attached to the applicationpublic org.robolectric.util.Scheduler getForegroundThreadScheduler()
Return the foreground scheduler.
public org.robolectric.util.Scheduler getBackgroundThreadScheduler()
Return the background scheduler.
public void setComponentNameAndServiceForBindService(ComponentName name, IBinder service)
public void setComponentNameAndServiceForBindServiceForIntent(Intent intent, ComponentName name, IBinder service)
public void assertNoBroadcastListenersOfActionRegistered(ContextWrapper context, String action)
public List<ServiceConnection> getBoundServiceConnections()
public void setUnbindServiceShouldThrowIllegalArgument(boolean flag)
public List<ServiceConnection> getUnboundServiceConnections()
@Deprecated public boolean hasReceiverForIntent(Intent intent)
@Deprecated public List<BroadcastReceiver> getReceiversForIntent(Intent intent)
public List<ShadowApplication.Wrapper> getRegisteredReceivers()
ShadowApplication.Wrappers for registered receiverspublic void clearRegisteredReceivers()
Removes all registered receivers.
@Deprecated public AppWidgetManager getAppWidgetManager()
Context#getSystemService(Context.APPWIDGET_SERVICE) intstead.@Deprecated public ShadowAlertDialog getLatestAlertDialog()
ShadowAlertDialog.getLatestAlertDialog() instead.protected void setLatestAlertDialog(ShadowAlertDialog latestAlertDialog)
@Deprecated public ShadowDialog getLatestDialog()
ShadowDialog.getLatestDialog() instead.protected void setLatestDialog(ShadowDialog latestDialog)
public Object getBluetoothAdapter()
public void declareActionUnbindable(String action)
public PowerManager.WakeLock getLatestWakeLock()
public void addWakeLock(PowerManager.WakeLock wl)
public void clearWakeLocks()
public void checkActivities(boolean checkActivities)
Set to true if you’d like Robolectric to strictly simulate the real Android behavior when calling Context.startActivity(android.content.Intent). Real Android throws a ActivityNotFoundException if given an Intent that is not known to the PackageManager
By default, this behavior is off (false).
checkActivities - True to validate activities.@Deprecated public ShadowPopupMenu getLatestPopupMenu()
ShadowPopupMenu.getLatestPopupMenu() instead.protected void setLatestPopupMenu(ShadowPopupMenu latestPopupMenu)
public PopupWindow getLatestPopupWindow()
protected void setLatestPopupWindow(PopupWindow latestPopupWindow)
public ListPopupWindow getLatestListPopupWindow()
protected void setLatestListPopupWindow(ListPopupWindow latestListPopupWindow)
@Deprecated public void setSystemService(String key, Object service)