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 17 package android.test.mock; 18 19 import android.content.ContentProviderOperation; 20 import android.content.ContentProviderResult; 21 import android.content.ContentValues; 22 import android.content.EntityIterator; 23 import android.content.IContentProvider; 24 import android.content.res.AssetFileDescriptor; 25 import android.database.Cursor; 26 import android.net.Uri; 27 import android.os.Bundle; 28 import android.os.IBinder; 29 import android.os.ICancellationSignal; 30 import android.os.ParcelFileDescriptor; 31 import android.os.RemoteException; 32 33 import java.io.FileNotFoundException; 34 import 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 */ 43 public 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 IBinder callerToken) { 67 throw new UnsupportedOperationException("unimplemented mock method"); 68 } 69 70 public AssetFileDescriptor openAssetFile( 71 String callingPackage, Uri uri, String mode, ICancellationSignal signal) { 72 throw new UnsupportedOperationException("unimplemented mock method"); 73 } 74 75 public ContentProviderResult[] applyBatch(String callingPackage, 76 ArrayList<ContentProviderOperation> operations) { 77 throw new UnsupportedOperationException("unimplemented mock method"); 78 } 79 80 public Cursor query(String callingPackage, Uri url, String[] projection, String selection, 81 String[] selectionArgs, 82 String sortOrder, ICancellationSignal cancellationSignal) { 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(String callingPackage, Uri url, ContentValues values, String selection, 92 String[] selectionArgs) throws RemoteException { 93 throw new UnsupportedOperationException("unimplemented mock method"); 94 } 95 96 public Bundle call(String callingPackage, String method, String request, Bundle args) 97 throws RemoteException { 98 throw new UnsupportedOperationException("unimplemented mock method"); 99 } 100 101 public IBinder asBinder() { 102 throw new UnsupportedOperationException("unimplemented mock method"); 103 } 104 105 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { 106 throw new UnsupportedOperationException("unimplemented mock method"); 107 } 108 109 public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri url, String mimeType, 110 Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException { 111 throw new UnsupportedOperationException("unimplemented mock method"); 112 } 113 114 @Override 115 public ICancellationSignal createCancellationSignal() throws RemoteException { 116 throw new UnsupportedOperationException("unimplemented mock method"); 117 } 118 119 @Override 120 public Uri canonicalize(String callingPkg, Uri uri) throws RemoteException { 121 throw new UnsupportedOperationException("unimplemented mock method"); 122 } 123 124 @Override 125 public Uri uncanonicalize(String callingPkg, Uri uri) throws RemoteException { 126 throw new UnsupportedOperationException("unimplemented mock method"); 127 } 128 } 129