MockIContentProvider.java revision 1877d0158b529663b8315482e7346a7bcaa96166
1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.test.mock; 18 19import android.content.ContentProviderOperation; 20import android.content.ContentProviderResult; 21import android.content.ContentValues; 22import android.content.EntityIterator; 23import android.content.IContentProvider; 24import android.content.res.AssetFileDescriptor; 25import android.database.Cursor; 26import android.database.CursorWindow; 27import android.database.IBulkCursor; 28import android.database.IContentObserver; 29import android.net.Uri; 30import android.os.Bundle; 31import android.os.IBinder; 32import android.os.ParcelFileDescriptor; 33import android.os.RemoteException; 34 35import java.util.ArrayList; 36 37/** 38 * Mock implementation of IContentProvider. All methods are non-functional and throw 39 * {@link java.lang.UnsupportedOperationException}. Tests can extend this class to 40 * implement behavior needed for tests. 41 * 42 * @hide - @hide because this exposes bulkQuery() and call(), which must also be hidden. 43 */ 44public class MockIContentProvider implements IContentProvider { 45 public int bulkInsert(Uri url, ContentValues[] initialValues) { 46 throw new UnsupportedOperationException("unimplemented mock method"); 47 } 48 49 public IBulkCursor bulkQuery(Uri url, String[] projection, String selection, 50 String[] selectionArgs, String sortOrder, IContentObserver observer, 51 CursorWindow window) { 52 throw new UnsupportedOperationException("unimplemented mock method"); 53 } 54 55 @SuppressWarnings("unused") 56 public int delete(Uri url, String selection, String[] selectionArgs) 57 throws RemoteException { 58 throw new UnsupportedOperationException("unimplemented mock method"); 59 } 60 61 public String getType(Uri url) { 62 throw new UnsupportedOperationException("unimplemented mock method"); 63 } 64 65 @SuppressWarnings("unused") 66 public Uri insert(Uri url, ContentValues initialValues) throws RemoteException { 67 throw new UnsupportedOperationException("unimplemented mock method"); 68 } 69 70 public ParcelFileDescriptor openFile(Uri url, String mode) { 71 throw new UnsupportedOperationException("unimplemented mock method"); 72 } 73 74 public AssetFileDescriptor openAssetFile(Uri uri, String mode) { 75 throw new UnsupportedOperationException("unimplemented mock method"); 76 } 77 78 public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) { 79 throw new UnsupportedOperationException("unimplemented mock method"); 80 } 81 82 public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, 83 String sortOrder) { 84 throw new UnsupportedOperationException("unimplemented mock method"); 85 } 86 87 public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, 88 String sortOrder) { 89 throw new UnsupportedOperationException("unimplemented mock method"); 90 } 91 92 public int update(Uri url, ContentValues values, String selection, String[] selectionArgs) 93 throws RemoteException { 94 throw new UnsupportedOperationException("unimplemented mock method"); 95 } 96 97 public Bundle call(String method, String request, Bundle args) 98 throws RemoteException { 99 throw new UnsupportedOperationException("unimplemented mock method"); 100 } 101 102 public IBinder asBinder() { 103 throw new UnsupportedOperationException("unimplemented mock method"); 104 } 105} 106