@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(android.os.PowerManager.WakeLock wl) |
void |
assertNoBroadcastListenersOfActionRegistered(android.content.ContextWrapper context,
java.lang.String action) |
void |
callAttach(android.content.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 |
clearWakeLocks() |
void |
declareActionUnbindable(java.lang.String action) |
android.appwidget.AppWidgetManager |
getAppWidgetManager()
Deprecated.
Please use
Context#getSystemService(Context.APPWIDGET_SERVICE) intstead. |
Scheduler |
getBackgroundThreadScheduler()
Return the background scheduler.
|
java.lang.Object |
getBluetoothAdapter() |
java.util.List<android.content.ServiceConnection> |
getBoundServiceConnections() |
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. |
android.widget.ListPopupWindow |
getLatestListPopupWindow() |
ShadowPopupMenu |
getLatestPopupMenu()
Deprecated.
Use
ShadowPopupMenu.getLatestPopupMenu() instead. |
android.widget.PopupWindow |
getLatestPopupWindow() |
android.os.PowerManager.WakeLock |
getLatestWakeLock() |
java.util.List<android.content.BroadcastReceiver> |
getReceiversForIntent(android.content.Intent intent)
Deprecated.
use PackageManager.queryBroadcastReceivers instead
|
java.util.List<ShadowApplication.Wrapper> |
getRegisteredReceivers() |
java.util.List<android.widget.Toast> |
getShownToasts() |
<T> T |
getSingleton(java.lang.Class<T> clazz,
Provider<T> provider) |
java.util.List<android.content.ServiceConnection> |
getUnboundServiceConnections() |
boolean |
hasReceiverForIntent(android.content.Intent intent)
Deprecated.
use PackageManager.queryBroadcastReceivers instead
|
static void |
runBackgroundTasks()
Runs any background tasks previously queued by
AsyncTask.execute(Object[]) . |
void |
setComponentNameAndServiceForBindService(android.content.ComponentName name,
android.os.IBinder service) |
void |
setComponentNameAndServiceForBindServiceForIntent(android.content.Intent intent,
android.content.ComponentName name,
android.os.IBinder service) |
protected void |
setLatestAlertDialog(ShadowAlertDialog latestAlertDialog) |
protected void |
setLatestDialog(ShadowDialog latestDialog) |
protected void |
setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow) |
protected void |
setLatestPopupMenu(ShadowPopupMenu latestPopupMenu) |
protected void |
setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow) |
void |
setSystemService(java.lang.String key,
java.lang.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, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, 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(android.content.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 java.util.List<android.widget.Toast> getShownToasts()
public Scheduler getForegroundThreadScheduler()
Return the foreground scheduler.
public Scheduler getBackgroundThreadScheduler()
Return the background scheduler.
public void setComponentNameAndServiceForBindService(android.content.ComponentName name, android.os.IBinder service)
public void setComponentNameAndServiceForBindServiceForIntent(android.content.Intent intent, android.content.ComponentName name, android.os.IBinder service)
public void assertNoBroadcastListenersOfActionRegistered(android.content.ContextWrapper context, java.lang.String action)
public java.util.List<android.content.ServiceConnection> getBoundServiceConnections()
public void setUnbindServiceShouldThrowIllegalArgument(boolean flag)
public java.util.List<android.content.ServiceConnection> getUnboundServiceConnections()
@Deprecated public boolean hasReceiverForIntent(android.content.Intent intent)
@Deprecated public java.util.List<android.content.BroadcastReceiver> getReceiversForIntent(android.content.Intent intent)
public java.util.List<ShadowApplication.Wrapper> getRegisteredReceivers()
ShadowApplication.Wrapper
s for registered receivers@Deprecated public android.appwidget.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 java.lang.Object getBluetoothAdapter()
public void declareActionUnbindable(java.lang.String action)
public android.os.PowerManager.WakeLock getLatestWakeLock()
public void addWakeLock(android.os.PowerManager.WakeLock wl)
public void clearWakeLocks()
public <T> T getSingleton(java.lang.Class<T> clazz, Provider<T> provider)
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 android.widget.PopupWindow getLatestPopupWindow()
protected void setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow)
public android.widget.ListPopupWindow getLatestListPopupWindow()
protected void setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow)
@Deprecated public void setSystemService(java.lang.String key, java.lang.Object service)