summaryrefslogtreecommitdiffstats
path: root/test-runner/src/android/test/mock
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2010-02-18 17:56:11 -0800
committerBrett Chabot <brettchabot@android.com>2010-02-19 09:58:29 -0800
commit12093976a4842a795491cfd2b1d3b71e18503f2d (patch)
tree04d06cdfe57151ca3856eab6c405f260583cf1fa /test-runner/src/android/test/mock
parent5df3a9017eaac2aef2ad360ce8f298b2d60b5536 (diff)
downloadframeworks_base-12093976a4842a795491cfd2b1d3b71e18503f2d.zip
frameworks_base-12093976a4842a795491cfd2b1d3b71e18503f2d.tar.gz
frameworks_base-12093976a4842a795491cfd2b1d3b71e18503f2d.tar.bz2
Move framework test-runner unit tests to be closer to their source.
Move the test-runner source into a separate src folder to accommodate the test move.
Diffstat (limited to 'test-runner/src/android/test/mock')
-rw-r--r--test-runner/src/android/test/mock/MockApplication.java46
-rw-r--r--test-runner/src/android/test/mock/MockContentProvider.java218
-rw-r--r--test-runner/src/android/test/mock/MockContentResolver.java70
-rw-r--r--test-runner/src/android/test/mock/MockContext.java431
-rw-r--r--test-runner/src/android/test/mock/MockCursor.java264
-rw-r--r--test-runner/src/android/test/mock/MockDialogInterface.java20
-rw-r--r--test-runner/src/android/test/mock/MockIContentProvider.java99
-rw-r--r--test-runner/src/android/test/mock/MockPackageManager.java452
-rw-r--r--test-runner/src/android/test/mock/MockResources.java222
-rw-r--r--test-runner/src/android/test/mock/package.html5
10 files changed, 1827 insertions, 0 deletions
diff --git a/test-runner/src/android/test/mock/MockApplication.java b/test-runner/src/android/test/mock/MockApplication.java
new file mode 100644
index 0000000..572dfbf
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockApplication.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.app.Application;
+import android.content.res.Configuration;
+
+/**
+ * A mock {@link android.app.Application} class. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}. Override it as necessary to provide the
+ * operations that you need.
+ */
+public class MockApplication extends Application {
+
+ public MockApplication() {
+ }
+
+ @Override
+ public void onCreate() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void onTerminate() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/test-runner/src/android/test/mock/MockContentProvider.java b/test-runner/src/android/test/mock/MockContentProvider.java
new file mode 100644
index 0000000..4078622
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockContentProvider.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.content.ContentProvider;
+import android.content.ContentProviderOperation;
+import android.content.ContentProviderResult;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.EntityIterator;
+import android.content.IContentProvider;
+import android.content.OperationApplicationException;
+import android.content.pm.PathPermission;
+import android.content.pm.ProviderInfo;
+import android.content.res.AssetFileDescriptor;
+import android.database.Cursor;
+import android.database.CursorWindow;
+import android.database.IBulkCursor;
+import android.database.IContentObserver;
+import android.net.Uri;
+import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+
+/**
+ * Mock implementation of ContentProvider. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}. Tests can extend this class to
+ * implement behavior needed for tests.
+ */
+public class MockContentProvider extends ContentProvider {
+ /*
+ * Note: if you add methods to ContentProvider, you must add similar methods to
+ * MockContentProvider.
+ */
+
+ /**
+ * IContentProvider that directs all calls to this MockContentProvider.
+ */
+ private class InversionIContentProvider implements IContentProvider {
+ @SuppressWarnings("unused")
+ public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
+ throws RemoteException, OperationApplicationException {
+ return MockContentProvider.this.applyBatch(operations);
+ }
+
+ @SuppressWarnings("unused")
+ public int bulkInsert(Uri url, ContentValues[] initialValues) throws RemoteException {
+ return MockContentProvider.this.bulkInsert(url, initialValues);
+ }
+
+ @SuppressWarnings("unused")
+ public IBulkCursor bulkQuery(Uri url, String[] projection, String selection,
+ String[] selectionArgs, String sortOrder, IContentObserver observer,
+ CursorWindow window) throws RemoteException {
+ throw new UnsupportedOperationException("Must not come here");
+ }
+
+ @SuppressWarnings("unused")
+ public int delete(Uri url, String selection, String[] selectionArgs)
+ throws RemoteException {
+ return MockContentProvider.this.delete(url, selection, selectionArgs);
+ }
+
+ @SuppressWarnings("unused")
+ public String getType(Uri url) throws RemoteException {
+ return MockContentProvider.this.getType(url);
+ }
+
+ @SuppressWarnings("unused")
+ public Uri insert(Uri url, ContentValues initialValues) throws RemoteException {
+ return MockContentProvider.this.insert(url, initialValues);
+ }
+
+ @SuppressWarnings("unused")
+ public AssetFileDescriptor openAssetFile(Uri url, String mode) throws RemoteException,
+ FileNotFoundException {
+ return MockContentProvider.this.openAssetFile(url, mode);
+ }
+
+ @SuppressWarnings("unused")
+ public ParcelFileDescriptor openFile(Uri url, String mode) throws RemoteException,
+ FileNotFoundException {
+ return MockContentProvider.this.openFile(url, mode);
+ }
+
+ @SuppressWarnings("unused")
+ public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) throws RemoteException {
+ return MockContentProvider.this.query(url, projection, selection,
+ selectionArgs, sortOrder);
+ }
+
+ @SuppressWarnings("unused")
+ public int update(Uri url, ContentValues values, String selection, String[] selectionArgs)
+ throws RemoteException {
+ return MockContentProvider.this.update(url, values, selection, selectionArgs);
+ }
+
+ public IBinder asBinder() {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+ private final InversionIContentProvider mIContentProvider = new InversionIContentProvider();
+
+ /**
+ * A constructor using {@link MockContext} instance as a Context in it.
+ */
+ protected MockContentProvider() {
+ super(new MockContext(), "", "", null);
+ }
+
+ /**
+ * A constructor accepting a Context instance, which is supposed to be the subclasss of
+ * {@link MockContext}.
+ */
+ public MockContentProvider(Context context) {
+ super(context, "", "", null);
+ }
+
+ /**
+ * A constructor which initialize four member variables which
+ * {@link android.content.ContentProvider} have internally.
+ *
+ * @param context A Context object which should be some mock instance (like the
+ * instance of {@link android.test.mock.MockContext}).
+ * @param readPermission The read permision you want this instance should have in the
+ * test, which is available via {@link #getReadPermission()}.
+ * @param writePermission The write permission you want this instance should have
+ * in the test, which is available via {@link #getWritePermission()}.
+ * @param pathPermissions The PathPermissions you want this instance should have
+ * in the test, which is available via {@link #getPathPermissions()}.
+ */
+ public MockContentProvider(Context context,
+ String readPermission,
+ String writePermission,
+ PathPermission[] pathPermissions) {
+ super(context, readPermission, writePermission, pathPermissions);
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @Override
+ public boolean onCreate() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ /**
+ * If you're reluctant to implement this manually, please just call super.bulkInsert().
+ */
+ @Override
+ public int bulkInsert(Uri uri, ContentValues[] values) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @Override
+ public void attachInfo(Context context, ProviderInfo info) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @Override
+ public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ /**
+ * Returns IContentProvider which calls back same methods in this class.
+ * By overriding this class, we avoid the mechanism hidden behind ContentProvider
+ * (IPC, etc.)
+ *
+ * @hide
+ */
+ @Override
+ public final IContentProvider getIContentProvider() {
+ return mIContentProvider;
+ }
+}
diff --git a/test-runner/src/android/test/mock/MockContentResolver.java b/test-runner/src/android/test/mock/MockContentResolver.java
new file mode 100644
index 0000000..3a1dc36c
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockContentResolver.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.content.ContentProvider;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.IContentProvider;
+import android.database.ContentObserver;
+import android.net.Uri;
+
+import com.google.android.collect.Maps;
+
+import java.util.Map;
+
+/**
+ * A mock {@link android.content.ContentResolver} class that isolates the test code from the real
+ * content system. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}.
+ *
+ * <p>This only isolates the test code in ways that have proven useful so far. More should be
+ * added as they become a problem.
+ */
+public class MockContentResolver extends ContentResolver {
+ Map<String, ContentProvider> mProviders;
+
+ public MockContentResolver() {
+ super(null);
+ mProviders = Maps.newHashMap();
+ }
+
+ public void addProvider(String name, ContentProvider provider) {
+ mProviders.put(name, provider);
+ }
+
+ /** @hide */
+ @Override
+ protected IContentProvider acquireProvider(Context context, String name) {
+ final ContentProvider provider = mProviders.get(name);
+ if (provider != null) {
+ return provider.getIContentProvider();
+ } else {
+ return null;
+ }
+ }
+
+ /** @hide */
+ @Override
+ public boolean releaseProvider(IContentProvider provider) {
+ return true;
+ }
+
+ @Override
+ public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
+ }
+}
diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java
new file mode 100644
index 0000000..ffd757c
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockContext.java
@@ -0,0 +1,431 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.BroadcastReceiver;
+import android.content.IntentSender;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.AssetManager;
+import android.content.res.Resources;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A mock {@link android.content.Context} class. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}. You can use this to inject other dependencies,
+ * mocks, or monitors into the classes you are testing.
+ */
+public class MockContext extends Context {
+
+ @Override
+ public AssetManager getAssets() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Resources getResources() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public PackageManager getPackageManager() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ContentResolver getContentResolver() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Looper getMainLooper() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Context getApplicationContext() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setTheme(int resid) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Resources.Theme getTheme() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getPackageName() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ApplicationInfo getApplicationInfo() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getPackageResourcePath() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** @hide */
+ @Override
+ public File getSharedPrefsFile(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getPackageCodePath() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SharedPreferences getSharedPreferences(String name, int mode) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public FileInputStream openFileInput(String name) throws FileNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public FileOutputStream openFileOutput(String name, int mode) throws FileNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean deleteFile(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public File getFileStreamPath(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] fileList() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public File getFilesDir() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public File getExternalFilesDir(String type) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public File getCacheDir() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public File getExternalCacheDir() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public File getDir(String name, int mode) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SQLiteDatabase openOrCreateDatabase(String file, int mode,
+ SQLiteDatabase.CursorFactory factory) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public File getDatabasePath(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] databaseList() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean deleteDatabase(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getWallpaper() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable peekWallpaper() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getWallpaperDesiredMinimumWidth() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getWallpaperDesiredMinimumHeight() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setWallpaper(Bitmap bitmap) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setWallpaper(InputStream data) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clearWallpaper() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void startActivity(Intent intent) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void startIntentSender(IntentSender intent,
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
+ throws IntentSender.SendIntentException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void sendBroadcast(Intent intent) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void sendBroadcast(Intent intent, String receiverPermission) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void sendOrderedBroadcast(Intent intent,
+ String receiverPermission) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void sendOrderedBroadcast(Intent intent, String receiverPermission,
+ BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData,
+ Bundle initialExtras) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void sendStickyBroadcast(Intent intent) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void sendStickyOrderedBroadcast(Intent intent,
+ BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData,
+ Bundle initialExtras) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeStickyBroadcast(Intent intent) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter,
+ String broadcastPermission, Handler scheduler) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void unregisterReceiver(BroadcastReceiver receiver) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ComponentName startService(Intent service) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean stopService(Intent service) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean bindService(Intent service, ServiceConnection conn, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void unbindService(ServiceConnection conn) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean startInstrumentation(ComponentName className,
+ String profileFile, Bundle arguments) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object getSystemService(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkPermission(String permission, int pid, int uid) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkCallingPermission(String permission) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkCallingOrSelfPermission(String permission) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void enforcePermission(
+ String permission, int pid, int uid, String message) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void enforceCallingPermission(String permission, String message) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void enforceCallingOrSelfPermission(String permission, String message) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void grantUriPermission(String toPackage, Uri uri, int modeFlags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void revokeUriPermission(Uri uri, int modeFlags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkCallingUriPermission(Uri uri, int modeFlags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkCallingOrSelfUriPermission(Uri uri, int modeFlags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkUriPermission(Uri uri, String readPermission,
+ String writePermission, int pid, int uid, int modeFlags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void enforceUriPermission(
+ Uri uri, int pid, int uid, int modeFlags, String message) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void enforceCallingUriPermission(
+ Uri uri, int modeFlags, String message) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void enforceCallingOrSelfUriPermission(
+ Uri uri, int modeFlags, String message) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void enforceUriPermission(
+ Uri uri, String readPermission, String writePermission,
+ int pid, int uid, int modeFlags, String message) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Context createPackageContext(String packageName, int flags)
+ throws PackageManager.NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isRestricted() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/test-runner/src/android/test/mock/MockCursor.java b/test-runner/src/android/test/mock/MockCursor.java
new file mode 100644
index 0000000..9b1c0ef
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockCursor.java
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.content.ContentResolver;
+import android.database.CharArrayBuffer;
+import android.database.ContentObserver;
+import android.database.Cursor;
+import android.database.DataSetObserver;
+import android.net.Uri;
+import android.os.Bundle;
+
+import java.util.Map;
+
+/**
+ * <P>
+ * A mock {@link android.database.Cursor} class that isolates the test code from real
+ * Cursor implementation.
+ * </P>
+ * <P>
+ * All methods including ones related to querying the state of the cursor are
+ * are non-functional and throw {@link java.lang.UnsupportedOperationException}.
+ * </P>
+ */
+public class MockCursor implements Cursor {
+ public int getColumnCount() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public int getColumnIndex(String columnName) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public int getColumnIndexOrThrow(String columnName) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public String getColumnName(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public String[] getColumnNames() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public int getCount() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean isNull(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public int getInt(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public long getLong(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public short getShort(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public float getFloat(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public double getDouble(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public byte[] getBlob(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public String getString(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public Bundle getExtras() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public int getPosition() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean isAfterLast() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean isBeforeFirst() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean isFirst() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean isLast() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean move(int offset) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean moveToFirst() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean moveToLast() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean moveToNext() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean moveToPrevious() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean moveToPosition(int position) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public void deactivate() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public void close() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean isClosed() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean requery() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public void registerContentObserver(ContentObserver observer) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public void registerDataSetObserver(DataSetObserver observer) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public Bundle respond(Bundle extras) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public boolean getWantsAllOnMoveCalls() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean commitUpdates() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean commitUpdates(Map<? extends Long, ? extends Map<String, Object>> values) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean hasUpdates() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setNotificationUri(ContentResolver cr, Uri uri) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean supportsUpdates() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean deleteRow() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public void unregisterContentObserver(ContentObserver observer) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public void unregisterDataSetObserver(DataSetObserver observer) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateBlob(int columnIndex, byte[] value) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateDouble(int columnIndex, double value) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateFloat(int columnIndex, float value) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateInt(int columnIndex, int value) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateLong(int columnIndex, long value) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateShort(int columnIndex, short value) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateString(int columnIndex, String value) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean updateToNull(int columnIndex) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("deprecation")
+ public void abortUpdates() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+} \ No newline at end of file
diff --git a/test-runner/src/android/test/mock/MockDialogInterface.java b/test-runner/src/android/test/mock/MockDialogInterface.java
new file mode 100644
index 0000000..e4dd0ba
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockDialogInterface.java
@@ -0,0 +1,20 @@
+// Copyright 2008 The Android Open Source Project
+
+package android.test.mock;
+
+import android.content.DialogInterface;
+
+/**
+ * A mock {@link android.content.DialogInterface} class. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you
+ * need.
+ */
+public class MockDialogInterface implements DialogInterface {
+ public void cancel() {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void dismiss() {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+}
diff --git a/test-runner/src/android/test/mock/MockIContentProvider.java b/test-runner/src/android/test/mock/MockIContentProvider.java
new file mode 100644
index 0000000..7c0a1e2
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockIContentProvider.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.content.ContentProviderOperation;
+import android.content.ContentProviderResult;
+import android.content.ContentValues;
+import android.content.EntityIterator;
+import android.content.IContentProvider;
+import android.content.res.AssetFileDescriptor;
+import android.database.Cursor;
+import android.database.CursorWindow;
+import android.database.IBulkCursor;
+import android.database.IContentObserver;
+import android.net.Uri;
+import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+
+import java.util.ArrayList;
+
+/**
+ * Mock implementation of IContentProvider. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}. Tests can extend this class to
+ * implement behavior needed for tests.
+ *
+ * @hide - @hide because this exposes bulkQuery(), which must also be hidden.
+ */
+public class MockIContentProvider implements IContentProvider {
+ public int bulkInsert(Uri url, ContentValues[] initialValues) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public IBulkCursor bulkQuery(Uri url, String[] projection, String selection,
+ String[] selectionArgs, String sortOrder, IContentObserver observer,
+ CursorWindow window) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("unused")
+ public int delete(Uri url, String selection, String[] selectionArgs)
+ throws RemoteException {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public String getType(Uri url) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ @SuppressWarnings("unused")
+ public Uri insert(Uri url, ContentValues initialValues) throws RemoteException {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public ParcelFileDescriptor openFile(Uri url, String mode) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public AssetFileDescriptor openAssetFile(Uri uri, String mode) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs,
+ String sortOrder) {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public int update(Uri url, ContentValues values, String selection, String[] selectionArgs)
+ throws RemoteException {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public IBinder asBinder() {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+}
diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java
new file mode 100644
index 0000000..f1ba44a
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockPackageManager.java
@@ -0,0 +1,452 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.IntentSender;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.FeatureInfo;
+import android.content.pm.IPackageDeleteObserver;
+import android.content.pm.IPackageDataObserver;
+import android.content.pm.IPackageInstallObserver;
+import android.content.pm.IPackageStatsObserver;
+import android.content.pm.InstrumentationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageParser;
+import android.content.pm.PermissionGroupInfo;
+import android.content.pm.PermissionInfo;
+import android.content.pm.ProviderInfo;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.os.RemoteException;
+
+import java.util.List;
+
+/**
+ * A mock {@link android.content.pm.PackageManager} class. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you
+ * need.
+ */
+public class MockPackageManager extends PackageManager {
+
+ @Override
+ public PackageInfo getPackageInfo(String packageName, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] currentToCanonicalPackageNames(String[] names) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] canonicalToCurrentPackageNames(String[] names) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Intent getLaunchIntentForPackage(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int[] getPackageGids(String packageName) throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public PermissionInfo getPermissionInfo(String name, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public PermissionGroupInfo getPermissionGroupInfo(String name,
+ int flags) throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ApplicationInfo getApplicationInfo(String packageName, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ActivityInfo getActivityInfo(ComponentName className, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ActivityInfo getReceiverInfo(ComponentName className, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ServiceInfo getServiceInfo(ComponentName className, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<PackageInfo> getInstalledPackages(int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkPermission(String permName, String pkgName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addPermission(PermissionInfo info) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removePermission(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkSignatures(String pkg1, String pkg2) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int checkSignatures(int uid1, int uid2) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] getPackagesForUid(int uid) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getNameForUid(int uid) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public int getUidForSharedUser(String sharedUserName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ApplicationInfo> getInstalledApplications(int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ResolveInfo resolveActivity(Intent intent, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller,
+ Intent[] specifics, Intent intent, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ResolveInfo resolveService(Intent intent, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ResolveInfo> queryIntentServices(Intent intent, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ProviderInfo resolveContentProvider(String name, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<InstrumentationInfo> queryInstrumentation(
+ String targetPackage, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getActivityIcon(ComponentName activityName)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getActivityIcon(Intent intent) throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getDefaultActivityIcon() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getApplicationIcon(ApplicationInfo info) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Drawable getApplicationIcon(String packageName) throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public XmlResourceParser getXml(String packageName, int resid,
+ ApplicationInfo appInfo) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public CharSequence getApplicationLabel(ApplicationInfo info) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Resources getResourcesForActivity(ComponentName activityName)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Resources getResourcesForApplication(ApplicationInfo app) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Resources getResourcesForApplication(String appPackageName)
+ throws NameNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void installPackage(Uri packageURI, IPackageInstallObserver observer,
+ int flags, String installerPackageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getInstallerPackageName(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void clearApplicationUserData(
+ String packageName, IPackageDataObserver observer) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void deleteApplicationCacheFiles(
+ String packageName, IPackageDataObserver observer) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void freeStorageAndNotify(
+ long idealStorageSize, IPackageDataObserver observer) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void freeStorage(
+ long idealStorageSize, IntentSender pi) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void deletePackage(
+ String packageName, IPackageDeleteObserver observer, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void addPackageToPreferred(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removePackageFromPreferred(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<PackageInfo> getPreferredPackages(int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setComponentEnabledSetting(ComponentName componentName,
+ int newState, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getComponentEnabledSetting(ComponentName componentName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setApplicationEnabledSetting(String packageName, int newState, int flags) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getApplicationEnabledSetting(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void addPreferredActivity(IntentFilter filter,
+ int match, ComponentName[] set, ComponentName activity) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void replacePreferredActivity(IntentFilter filter,
+ int match, ComponentName[] set, ComponentName activity) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public void clearPackagePreferredActivities(String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @hide - to match hiding in superclass
+ */
+ @Override
+ public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int getPreferredActivities(List<IntentFilter> outFilters,
+ List<ComponentName> outActivities, String packageName) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String[] getSystemSharedLibraryNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public FeatureInfo[] getSystemAvailableFeatures() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean hasSystemFeature(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isSafeMode() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/test-runner/src/android/test/mock/MockResources.java b/test-runner/src/android/test/mock/MockResources.java
new file mode 100644
index 0000000..18752ce
--- /dev/null
+++ b/test-runner/src/android/test/mock/MockResources.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.test.mock;
+
+import android.content.res.AssetManager;
+import android.content.res.Resources;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
+import android.content.res.ColorStateList;
+import android.content.res.XmlResourceParser;
+import android.content.res.AssetFileDescriptor;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+import android.util.AttributeSet;
+import android.graphics.drawable.Drawable;
+import android.graphics.Movie;
+
+import java.io.InputStream;
+
+/**
+ * A mock {@link android.content.res.Resources} class. All methods are non-functional and throw
+ * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you
+ * need.
+ */
+public class MockResources extends Resources {
+
+ public MockResources() {
+ super(new AssetManager(), null, null);
+ }
+
+ @Override
+ public void updateConfiguration(Configuration config, DisplayMetrics metrics) {
+ // this method is called from the constructor, so we just do nothing
+ }
+
+ @Override
+ public CharSequence getText(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public CharSequence getQuantityText(int id, int quantity) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getString(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getString(int id, Object... formatArgs) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getQuantityString(int id, int quantity, Object... formatArgs)
+ throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getQuantityString(int id, int quantity) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public CharSequence getText(int id, CharSequence def) {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public CharSequence[] getTextArray(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String[] getStringArray(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public int[] getIntArray(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public TypedArray obtainTypedArray(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public float getDimension(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public int getDimensionPixelOffset(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public int getDimensionPixelSize(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public Drawable getDrawable(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public Movie getMovie(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public int getColor(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public ColorStateList getColorStateList(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public int getInteger(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public XmlResourceParser getLayout(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public XmlResourceParser getAnimation(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public XmlResourceParser getXml(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public InputStream openRawResource(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public AssetFileDescriptor openRawResourceFd(int id) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public void getValue(int id, TypedValue outValue, boolean resolveRefs)
+ throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public void getValue(String name, TypedValue outValue, boolean resolveRefs)
+ throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public TypedArray obtainAttributes(AttributeSet set, int[] attrs) {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public DisplayMetrics getDisplayMetrics() {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public int getIdentifier(String name, String defType, String defPackage) {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getResourceName(int resid) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getResourcePackageName(int resid) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getResourceTypeName(int resid) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+
+ @Override
+ public String getResourceEntryName(int resid) throws NotFoundException {
+ throw new UnsupportedOperationException("mock object, not implemented");
+ }
+}
diff --git a/test-runner/src/android/test/mock/package.html b/test-runner/src/android/test/mock/package.html
new file mode 100644
index 0000000..0f1bc6f4
--- /dev/null
+++ b/test-runner/src/android/test/mock/package.html
@@ -0,0 +1,5 @@
+<HTML>
+<BODY>
+Utility classes providing stubs or mocks of various Android framework building blocks.
+</BODY>
+</HTML>