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(String callingPackage, Uri url, ContentValues[] initialValues) { 45 throw new UnsupportedOperationException("unimplemented mock method"); 46 } 47 48 @SuppressWarnings("unused") 49 public int delete(String callingPackage, 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(String callingPackage, Uri url, ContentValues initialValues) 60 throws RemoteException { 61 throw new UnsupportedOperationException("unimplemented mock method"); 62 } 63 64 public ParcelFileDescriptor openFile( 65 String callingPackage, Uri url, String mode, ICancellationSignal signal) { 66 throw new UnsupportedOperationException("unimplemented mock method"); 67 } 68 69 public AssetFileDescriptor openAssetFile( 70 String callingPackage, Uri uri, String mode, ICancellationSignal signal) { 71 throw new UnsupportedOperationException("unimplemented mock method"); 72 } 73 74 public ContentProviderResult[] applyBatch(String callingPackage, 75 ArrayList<ContentProviderOperation> operations) { 76 throw new UnsupportedOperationException("unimplemented mock method"); 77 } 78 79 public Cursor query(String callingPackage, Uri url, String[] projection, String selection, 80 String[] selectionArgs, 81 String sortOrder, ICancellationSignal cancellationSignal) { 82 throw new UnsupportedOperationException("unimplemented mock method"); 83 } 84 85 public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, 86 String sortOrder) { 87 throw new UnsupportedOperationException("unimplemented mock method"); 88 } 89 90 public int update(String callingPackage, Uri url, ContentValues values, String selection, 91 String[] selectionArgs) throws RemoteException { 92 throw new UnsupportedOperationException("unimplemented mock method"); 93 } 94 95 public Bundle call(String callingPackage, String method, String request, Bundle args) 96 throws RemoteException { 97 throw new UnsupportedOperationException("unimplemented mock method"); 98 } 99 100 public IBinder asBinder() { 101 throw new UnsupportedOperationException("unimplemented mock method"); 102 } 103 104 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { 105 throw new UnsupportedOperationException("unimplemented mock method"); 106 } 107 108 public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri url, String mimeType, 109 Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException { 110 throw new UnsupportedOperationException("unimplemented mock method"); 111 } 112 113 @Override 114 public ICancellationSignal createCancellationSignal() throws RemoteException { 115 throw new UnsupportedOperationException("unimplemented mock method"); 116 } 117 118 @Override 119 public Uri canonicalize(String callingPkg, Uri uri) throws RemoteException { 120 throw new UnsupportedOperationException("unimplemented mock method"); 121 } 122 123 @Override 124 public Uri uncanonicalize(String callingPkg, Uri uri) throws RemoteException { 125 throw new UnsupportedOperationException("unimplemented mock method"); 126 } 127} 128