English | Site Directory

Android - An Open Handset Alliance Project

android.test.mock
public class

android.test.mock.MockContext

java.lang.Object
android.content.Context
android.test.mock.MockContext

A mock context. Override it to provide the operations that you need.

Summary

Constants inherited from class android.content.Context

Public Constructors

          MockContext()

Public Methods

        boolean  bindService(Intent service, ServiceConnection conn, int flags)
Connect to an application service, creating it if needed.
        void  broadcastIntent(Intent intent, String receiverPermission)
Broadcast the given intent to all interested IntentReceivers, allowing an optional required permission to be enforced.
        void  broadcastIntent(Intent intent, String receiverPermission, IntentReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Version of broadcastIntent(Intent) that allows you to receive data back from the broadcast.
        void  broadcastIntent(Intent intent)
Broadcast the given intent to all interested IntentReceivers.
        void  broadcastIntentSerialized(Intent intent, String receiverPermission)
Broadcast the given intent to all interested IntentReceivers, delivering them one at a time to allow more preferred receivers to consume the broadcast before it is delivered to less preferred receivers.
        void  broadcastStickyIntent(Intent intent)
Perform a broadcastIntent(Intent) that is "sticky," meaning the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(IntentReceiver, IntentFilter).
        int  checkCallingOrSelfPermission(String permission)
Determine whether the calling process of an IPC or you have been granted a particular permission.
        int  checkCallingPermission(String permission)
Determine whether the calling process of an IPC you are handling has been granted a particular permission.
        int  checkPermission(String permission, int pid, int uid)
Determine whether the given permission is allowed for a particular process and user ID running in the system.
        void  clearWallpaper()
Remove any currently set wallpaper, reverting to the system's default wallpaper.
        SQLiteDatabase  createDatabase(String name, int version, int mode, CursorFactory factory)
Create a new private SQLiteDatabase associate with this Context's application package.
        Context  createPackageContext(String packageName, int flags)
Return a new Context object for the given application name.
        boolean  deleteDatabase(String name)
Delete an existing private SQLiteDatabase associated with this Context's application package.
        boolean  deleteFile(String name)
Delete the given private file associated with this Context's application package.
        String[]  fileList()
Returns an array of strings naming the private files associated with this Context's application package.
        AssetManager  getAssets()
Return an AssetManager instance for your application's package.
        ClassLoader  getClassLoader()
Return a class loader you can use to retrieve classes in this package.
        ContentResolver  getContentResolver()
Return a ContentResolver instance for your application's package.
        File  getDatabasePath(String name)
Returns the absolute path on the filesystem where a database created with createDatabase(String, int, int, SQLiteDatabase.CursorFactory) is stored.
        File  getDir(String name, int mode)
Retrieve, creating if needed, a new directly in which the application can place its own custom data files.
        File  getFileStreamPath(String name)
Returns the absolute path on the filesystem where a file created with openFileOutput(String, int) is stored.
        File  getFilesDir()
Returns the absolute path to the directory on the filesystem where files created with openFileOutput(String, int) are stored.
        PackageManager  getPackageManager()
Return PackageManager instance to find global package information.
        String  getPackageName()
Return the name of this application's package.
        String  getPackagePath()
Return the full path to this context's application package.
        Resources  getResources()
Return a Resources instance for your application's package.
        SharedPreferences  getSharedPreferences(String name, int mode)
Retrieve and hold the contents of the preferences file 'name', returning a SharedPreferences through which you can retrieve and modify its values.
        Object  getSystemService(String name)
Return the handle to a system-level service by name.
        Theme  getTheme()
Return the Theme object associated with this Context.
        Drawable  getWallpaper()
Like peekWallpaper(), but always returns a valid Drawable.
        SQLiteDatabase  openDatabase(String file, CursorFactory factory)
Open an existing private SQLiteDatabase associated with this Context's application package.
        FileInputStream  openFileInput(String name)
Open a private file associated with this Context's application package for reading.
        FileOutputStream  openFileOutput(String name, int mode)
Open a private file associated with this Context's application package for writing.
        Drawable  peekWallpaper()
Retrieve the current system wallpaper.
        Intent  registerReceiver(IntentReceiver receiver, IntentFilter filter)
Register an IntentReceiver to be run in the main activity thread.
        Intent  registerReceiver(IntentReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler)
Register to receive intent broadcasts, to run in the context of scheduler.
        void  setTheme(int resid)
Set the base theme for this context.
        void  setThreadPriority(int threadId, int priority)
Change the priority of a thread running in your process.
        void  setWallpaper(InputStream data)
Change the current system wallpaper to a specific byte stream.
        void  setWallpaper(Bitmap bitmap)
Change the current system wallpaper to a bitmap.
        DialogInterface  showAlert(CharSequence title, int iconId, CharSequence message, CharSequence button1Text, OnClickListener button1Listener, CharSequence button2Text, OnClickListener button2Listener, CharSequence button3Text, OnClickListener button3Listener, boolean cancelable, OnCancelListener cancelListener)
Display a simple, non-blocking two button alert dialog.
        DialogInterface  showAlert(CharSequence title, CharSequence message, CharSequence button1Text, Message button1Callback, CharSequence button2Text, Message button2Callback, boolean cancellable, Message cancelCallback)
This method is deprecated. use showAlert(CharSequence, int, CharSequence, CharSequence, DialogInterface.OnClickListener, CharSequence, DialogInterface.OnClickListener, boolean, DialogInterface.OnCancelListener)
        DialogInterface  showAlert(CharSequence title, int iconId, CharSequence message, CharSequence button1Text, OnClickListener button1Listener, CharSequence button2Text, OnClickListener button2Listener, boolean cancelable, OnCancelListener cancelListener)
Display a simple, non-blocking two button alert dialog.
        DialogInterface  showAlert(CharSequence title, int iconId, CharSequence message, CharSequence buttonText, boolean cancelable)
Display a simple, non-blocking one button alert dialog.
        DialogInterface  showAlert(CharSequence title, int iconId, CharSequence message, CharSequence buttonText, OnClickListener buttonListener, boolean cancelable, OnCancelListener cancelListener)
Display a simple, non-blocking one button alert dialog.
        void  startActivity(Intent intent)
Launch a new activity.
        boolean  startInstrumentation(ComponentName className, String profileFile, Bundle arguments)
Start executing an Instrumentation class.
        ComponentName  startService(Intent service, Bundle args)
Request that a given application service be started.
        boolean  stopService(Intent service)
Request that a given application service be stopped.
        void  unbindService(ServiceConnection conn)
Disconnect from an application service.
        void  unbroadcastStickyIntent(Intent intent)
Remove the data previously sent with broadcastStickyIntent(Intent), so that it is as if the sticky broadcast had never happened.
        void  unregisterReceiver(IntentReceiver receiver)
Unregister a previously registered IntentReceiver.
Methods inherited from class android.content.Context
Methods inherited from class java.lang.Object