MockIContentProvider.java revision a7771df3696954f0e279407e8894a916a7cb26cc
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.net.Uri; 27import android.os.Bundle; 28import android.os.IBinder; 29import android.os.ICancellationSignal; 30import android.os.ParcelFileDescriptor; 31import android.os.RemoteException; 32 33import java.io.FileNotFoundException; 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() and call(), 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 @SuppressWarnings("unused") 49 public int delete(Uri url, String selection, String[] selectionArgs) 50 throws RemoteException { 51 throw new UnsupportedOperationException("unimplemented mock method"); 52 } 53 54 public String getType(Uri url) { 55 throw new UnsupportedOperationException("unimplemented mock method"); 56 } 57 58 @SuppressWarnings("unused") 59 public Uri insert(Uri url, ContentValues initialValues) throws RemoteException { 60 throw new UnsupportedOperationException("unimplemented mock method"); 61 } 62 63 public ParcelFileDescriptor openFile(Uri url, String mode) { 64 throw new UnsupportedOperationException("unimplemented mock method"); 65 } 66 67 public AssetFileDescriptor openAssetFile(Uri uri, String mode) { 68 throw new UnsupportedOperationException("unimplemented mock method"); 69 } 70 71 public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) { 72 throw new UnsupportedOperationException("unimplemented mock method"); 73 } 74 75 public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, 76 String sortOrder, ICancellationSignal cancellationSignal) { 77 throw new UnsupportedOperationException("unimplemented mock method"); 78 } 79 80 public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, 81 String sortOrder) { 82 throw new UnsupportedOperationException("unimplemented mock method"); 83 } 84 85 public int update(Uri url, ContentValues values, String selection, String[] selectionArgs) 86 throws RemoteException { 87 throw new UnsupportedOperationException("unimplemented mock method"); 88 } 89 90 public Bundle call(String method, String request, Bundle args) 91 throws RemoteException { 92 throw new UnsupportedOperationException("unimplemented mock method"); 93 } 94 95 public IBinder asBinder() { 96 throw new UnsupportedOperationException("unimplemented mock method"); 97 } 98 99 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { 100 throw new UnsupportedOperationException("unimplemented mock method"); 101 } 102 103 public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts) 104 throws RemoteException, FileNotFoundException { 105 throw new UnsupportedOperationException("unimplemented mock method"); 106 } 107 108 @Override 109 public ICancellationSignal createCancellationSignal() throws RemoteException { 110 throw new UnsupportedOperationException("unimplemented mock method"); 111 } 112} 113