MockIContentProvider.java revision 12093976a4842a795491cfd2b1d3b71e18503f2d
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.IBinder; 31import android.os.ParcelFileDescriptor; 32import android.os.RemoteException; 33 34import java.util.ArrayList; 35 36/** 37 * Mock implementation of IContentProvider. All methods are non-functional and throw 38 * {@link java.lang.UnsupportedOperationException}. Tests can extend this class to 39 * implement behavior needed for tests. 40 * 41 * @hide - @hide because this exposes bulkQuery(), which must also be hidden. 42 */ 43public class MockIContentProvider implements IContentProvider { 44 public int bulkInsert(Uri url, ContentValues[] initialValues) { 45 throw new UnsupportedOperationException("unimplemented mock method"); 46 } 47 48 public IBulkCursor bulkQuery(Uri url, String[] projection, String selection, 49 String[] selectionArgs, String sortOrder, IContentObserver observer, 50 CursorWindow window) { 51 throw new UnsupportedOperationException("unimplemented mock method"); 52 } 53 54 @SuppressWarnings("unused") 55 public int delete(Uri url, String selection, String[] selectionArgs) 56 throws RemoteException { 57 throw new UnsupportedOperationException("unimplemented mock method"); 58 } 59 60 public String getType(Uri url) { 61 throw new UnsupportedOperationException("unimplemented mock method"); 62 } 63 64 @SuppressWarnings("unused") 65 public Uri insert(Uri url, ContentValues initialValues) throws RemoteException { 66 throw new UnsupportedOperationException("unimplemented mock method"); 67 } 68 69 public ParcelFileDescriptor openFile(Uri url, String mode) { 70 throw new UnsupportedOperationException("unimplemented mock method"); 71 } 72 73 public AssetFileDescriptor openAssetFile(Uri uri, String mode) { 74 throw new UnsupportedOperationException("unimplemented mock method"); 75 } 76 77 public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) { 78 throw new UnsupportedOperationException("unimplemented mock method"); 79 } 80 81 public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, 82 String sortOrder) { 83 throw new UnsupportedOperationException("unimplemented mock method"); 84 } 85 86 public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, 87 String sortOrder) { 88 throw new UnsupportedOperationException("unimplemented mock method"); 89 } 90 91 public int update(Uri url, ContentValues values, String selection, String[] selectionArgs) 92 throws RemoteException { 93 throw new UnsupportedOperationException("unimplemented mock method"); 94 } 95 96 public IBinder asBinder() { 97 throw new UnsupportedOperationException("unimplemented mock method"); 98 } 99} 100