@Implements(value=android.app.Application.class) public class ShadowApplication extends ShadowContextWrapper
Application.| Modifier and Type | Class and Description |
|---|---|
class |
ShadowApplication.Wrapper |
| Constructor and Description |
|---|
ShadowApplication() |
| Modifier and Type | Method and Description |
|---|---|
void |
addWakeLock(android.os.PowerManager.WakeLock wl) |
void |
assertNoBroadcastListenersOfActionRegistered(android.content.Context context,
String action) |
void |
assertNoBroadcastListenersRegistered(android.content.Context context,
String type)
Iterates through all of the registered receivers on this
Application and if any of them match the given
Context object throws a RuntimeException |
void |
bind(org.robolectric.manifest.AndroidManifest appManifest,
org.robolectric.res.ResourceLoader resourceLoader)
Associates a
ResourceLoader with an Application instance. |
boolean |
bindService(android.content.Intent intent,
android.content.ServiceConnection serviceConnection,
int i) |
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). |
int |
checkPermission(String permission,
int pid,
int uid) |
void |
clearStartedServices()
Clears all
Intent started by startService(android.content.Intent) |
void |
clearWakeLocks() |
void |
declareActionUnbindable(String action) |
void |
denyPermissions(String... permissionNames) |
android.content.Context |
getApplicationContext() |
org.robolectric.manifest.AndroidManifest |
getAppManifest() |
android.appwidget.AppWidgetManager |
getAppWidgetManager()
Non-Android accessor.
|
android.content.res.AssetManager |
getAssets() |
org.robolectric.util.Scheduler |
getBackgroundThreadScheduler()
Return the background scheduler.
|
Object |
getBluetoothAdapter() |
List<android.content.ServiceConnection> |
getBoundServiceConnections() |
List<android.content.Intent> |
getBroadcastIntents() |
android.content.ContentResolver |
getContentResolver() |
org.robolectric.util.Scheduler |
getForegroundThreadScheduler()
Return the foreground scheduler.
|
static ShadowApplication |
getInstance() |
ShadowAlertDialog |
getLatestAlertDialog() |
ShadowDialog |
getLatestDialog() |
android.widget.ListPopupWindow |
getLatestListPopupWindow() |
ShadowPopupMenu |
getLatestPopupMenu() |
android.widget.PopupWindow |
getLatestPopupWindow() |
android.os.PowerManager.WakeLock |
getLatestWakeLock() |
android.view.LayoutInflater |
getLayoutInflater()
Non-Android accessor.
|
android.os.Looper |
getMainLooper() |
android.content.Intent |
getNextStartedActivity()
Consumes the most recent
Intent started by startActivity(android.content.Intent) and returns it. |
android.content.Intent |
getNextStartedService()
Consumes the most recent
Intent started by startService(android.content.Intent) and returns it. |
android.content.Intent |
getNextStoppedService()
Consumes the
Intent requested to stop a service by stopService(android.content.Intent)
from the bottom of the stack of stop requests. |
List<android.content.BroadcastReceiver> |
getReceiversForIntent(android.content.Intent intent) |
List<ShadowApplication.Wrapper> |
getRegisteredReceivers()
Non-Android accessor.
|
org.robolectric.res.ResourceLoader |
getResourceLoader()
Non-Android accessor (and a handy way to get a working
ResourceLoader |
android.content.res.Resources |
getResources() |
Map<String,Map<String,Object>> |
getSharedPreferenceMap() |
List<android.widget.Toast> |
getShownToasts() |
<T> T |
getSingleton(Class<T> clazz,
Provider<T> provider) |
List<android.content.ServiceConnection> |
getUnboundServiceConnections() |
void |
grantPermissions(String... permissionNames) |
boolean |
hasReceiverForIntent(android.content.Intent intent) |
boolean |
isStrictI18n() |
android.content.Intent |
peekNextStartedActivity()
Returns the most recent
Intent started by startActivity(android.content.Intent) without
consuming it. |
android.content.Intent |
peekNextStartedService()
Returns the most recent
Intent started by startService(android.content.Intent) without
consuming it. |
android.content.Intent |
registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter)
Always returns
null |
android.content.Intent |
registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter,
String broadcastPermission,
android.os.Handler scheduler) |
void |
resetResources()
Reset (set to null) resources instance, so they will be reloaded next time they are
gotten |
static void |
runBackgroundTasks()
Runs any background tasks previously queued by
AsyncTask.execute(Object[]). |
void |
sendBroadcast(android.content.Intent intent) |
void |
sendBroadcast(android.content.Intent intent,
String receiverPermission) |
void |
sendOrderedBroadcast(android.content.Intent intent,
String receiverPermission) |
void |
sendStickyBroadcast(android.content.Intent intent) |
void |
setComponentNameAndServiceForBindService(android.content.ComponentName name,
android.os.IBinder service) |
void |
setComponentNameAndServiceForBindServiceForIntent(android.content.Intent intent,
android.content.ComponentName name,
android.os.IBinder service) |
static void |
setDefaultDisplay(android.view.Display display) |
static void |
setDisplayMetricsDensity(float densityMultiplier) |
void |
setLatestAlertDialog(ShadowAlertDialog latestAlertDialog) |
void |
setLatestDialog(ShadowDialog latestDialog) |
void |
setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow) |
void |
setLatestPopupMenu(ShadowPopupMenu latestPopupMenu) |
void |
setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow) |
void |
setStrictI18n(boolean strictI18n) |
void |
setSystemService(String key,
Object service)
Deprecated.
|
void |
startActivity(android.content.Intent intent) |
void |
startActivity(android.content.Intent intent,
android.os.Bundle options) |
android.content.ComponentName |
startService(android.content.Intent intent) |
boolean |
stopService(android.content.Intent name) |
void |
unbindService(android.content.ServiceConnection serviceConnection) |
void |
unregisterReceiver(android.content.BroadcastReceiver broadcastReceiver) |
checkCallingOrSelfPermission, checkCallingPermission, getApplicationInfo, getClassLoader, getExternalCacheDir, getExternalFilesDir, getPackageManager, getPackageName, getShadowApplication, getSharedPreferences, getString, getString, getText, getUserId, isRestricted, setPackageName, startActivities, startActivitiescallAttachBaseContext, createAttributeSet, getResNamepublic static ShadowApplication getInstance()
public static void runBackgroundTasks()
AsyncTask.execute(Object[]).
Note: calling this method does not pause or un-pause the scheduler.
public static void setDisplayMetricsDensity(float densityMultiplier)
public static void setDefaultDisplay(android.view.Display display)
public void bind(org.robolectric.manifest.AndroidManifest appManifest,
org.robolectric.res.ResourceLoader resourceLoader)
ResourceLoader with an Application instance.appManifest - Android manifest.resourceLoader - Resource loader.public List<android.widget.Toast> getShownToasts()
public org.robolectric.util.Scheduler getForegroundThreadScheduler()
public org.robolectric.util.Scheduler getBackgroundThreadScheduler()
@Implementation public android.content.Context getApplicationContext()
getApplicationContext in class ShadowContextWrapper@Implementation public android.content.res.AssetManager getAssets()
getAssets in class ShadowContextWrapper@Implementation public android.content.res.Resources getResources()
getResources in class ShadowContextWrapperpublic void resetResources()
gotten@Implementation public android.content.ContentResolver getContentResolver()
getContentResolver in class ShadowContextWrapper@Implementation public void startActivity(android.content.Intent intent)
startActivity in class ShadowContextWrapper@Implementation
public void startActivity(android.content.Intent intent,
android.os.Bundle options)
startActivity in class ShadowContextWrapper@Implementation public android.content.ComponentName startService(android.content.Intent intent)
startService in class ShadowContextWrapper@Implementation public boolean stopService(android.content.Intent name)
stopService in class ShadowContextWrapperpublic 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)
@Implementation
public boolean bindService(android.content.Intent intent,
android.content.ServiceConnection serviceConnection,
int i)
bindService in class ShadowContextWrapperpublic List<android.content.ServiceConnection> getBoundServiceConnections()
@Implementation public void unbindService(android.content.ServiceConnection serviceConnection)
unbindService in class ShadowContextWrapperpublic List<android.content.ServiceConnection> getUnboundServiceConnections()
public android.content.Intent getNextStartedActivity()
Intent started by startActivity(android.content.Intent) and returns it.getNextStartedActivity in class ShadowContextWrapperIntentpublic android.content.Intent peekNextStartedActivity()
Intent started by startActivity(android.content.Intent) without
consuming it.peekNextStartedActivity in class ShadowContextWrapperIntentpublic android.content.Intent getNextStartedService()
Intent started by startService(android.content.Intent) and returns it.getNextStartedService in class ShadowContextWrapperIntentpublic android.content.Intent peekNextStartedService()
Intent started by startService(android.content.Intent) without
consuming it.peekNextStartedService in class ShadowContextWrapperIntentpublic void clearStartedServices()
Intent started by startService(android.content.Intent)clearStartedServices in class ShadowContextWrapperpublic android.content.Intent getNextStoppedService()
Intent requested to stop a service by stopService(android.content.Intent)
from the bottom of the stack of stop requests.getNextStoppedService in class ShadowContextWrapperIntent for the next service requested to be stoppedpublic org.robolectric.res.ResourceLoader getResourceLoader()
ResourceLoadergetResourceLoader in class ShadowContextWrapperResourceLoader associated with this Application@Implementation public void sendBroadcast(android.content.Intent intent)
sendBroadcast in class ShadowContextWrapper@Implementation
public void sendBroadcast(android.content.Intent intent,
String receiverPermission)
sendBroadcast in class ShadowContextWrapper@Implementation
public void sendOrderedBroadcast(android.content.Intent intent,
String receiverPermission)
sendOrderedBroadcast in class ShadowContextWrapperpublic List<android.content.Intent> getBroadcastIntents()
getBroadcastIntents in class ShadowContextWrapper@Implementation public void sendStickyBroadcast(android.content.Intent intent)
sendStickyBroadcast in class ShadowContextWrapper@Implementation
public android.content.Intent registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter)
nullregisterReceiver in class ShadowContextWrappernull@Implementation
public android.content.Intent registerReceiver(android.content.BroadcastReceiver receiver,
android.content.IntentFilter filter,
String broadcastPermission,
android.os.Handler scheduler)
registerReceiver in class ShadowContextWrapper@Implementation public void unregisterReceiver(android.content.BroadcastReceiver broadcastReceiver)
unregisterReceiver in class ShadowContextWrapperpublic void assertNoBroadcastListenersRegistered(android.content.Context context,
String type)
Application and if any of them match the given
Context object throws a RuntimeExceptioncontext - the Context to check for on each of the remaining registered receiverstype - the type to report for the context if an exception is thrownRuntimeException - if there are any recievers registered with the given Contextpublic void assertNoBroadcastListenersOfActionRegistered(android.content.Context context,
String action)
public boolean hasReceiverForIntent(android.content.Intent intent)
public List<android.content.BroadcastReceiver> getReceiversForIntent(android.content.Intent intent)
public List<ShadowApplication.Wrapper> getRegisteredReceivers()
ShadowApplication.Wrappers for registered receiverspublic android.view.LayoutInflater getLayoutInflater()
Applicationpublic android.appwidget.AppWidgetManager getAppWidgetManager()
Application@Implementation public android.os.Looper getMainLooper()
getMainLooper in class ShadowContextWrapperpublic ShadowAlertDialog getLatestAlertDialog()
public void setLatestAlertDialog(ShadowAlertDialog latestAlertDialog)
public ShadowDialog getLatestDialog()
public void setLatestDialog(ShadowDialog latestDialog)
public Object getBluetoothAdapter()
public void declareActionUnbindable(String action)
@Deprecated public void setSystemService(String key, Object service)
public android.os.PowerManager.WakeLock getLatestWakeLock()
public void addWakeLock(android.os.PowerManager.WakeLock wl)
public void clearWakeLocks()
public boolean isStrictI18n()
isStrictI18n in class ShadowContextpublic void setStrictI18n(boolean strictI18n)
public org.robolectric.manifest.AndroidManifest getAppManifest()
public void checkActivities(boolean checkActivities)
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.public ShadowPopupMenu getLatestPopupMenu()
public void setLatestPopupMenu(ShadowPopupMenu latestPopupMenu)
public android.widget.PopupWindow getLatestPopupWindow()
public void setLatestPopupWindow(android.widget.PopupWindow latestPopupWindow)
public android.widget.ListPopupWindow getLatestListPopupWindow()
public void setLatestListPopupWindow(android.widget.ListPopupWindow latestListPopupWindow)
@Implementation public int checkPermission(String permission, int pid, int uid)
checkPermission in class ShadowContextWrapperpublic void grantPermissions(String... permissionNames)
grantPermissions in class ShadowContextWrapperpublic void denyPermissions(String... permissionNames)
denyPermissions in class ShadowContextWrapperCopyright © 2015. All rights reserved.