Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 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; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 26 | import android.net.Uri; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 27 | import android.os.Bundle; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 28 | import android.os.IBinder; |
Jeff Brown | a7771df | 2012-05-07 20:06:46 -0700 | [diff] [blame] | 29 | import android.os.ICancellationSignal; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 30 | import android.os.ParcelFileDescriptor; |
| 31 | import android.os.RemoteException; |
| 32 | |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 33 | import java.io.FileNotFoundException; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 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 | * |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 41 | * @hide - @hide because this exposes bulkQuery() and call(), which must also be hidden. |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 42 | */ |
| 43 | public class MockIContentProvider implements IContentProvider { |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 44 | public int bulkInsert(String callingPackage, Uri url, ContentValues[] initialValues) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 45 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 46 | } |
| 47 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 48 | @SuppressWarnings("unused") |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 49 | public int delete(String callingPackage, Uri url, String selection, String[] selectionArgs) |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 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") |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 59 | public Uri insert(String callingPackage, Uri url, ContentValues initialValues) |
| 60 | throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 61 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 62 | } |
| 63 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 64 | public ParcelFileDescriptor openFile(String callingPackage, Uri url, String mode) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 65 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 66 | } |
| 67 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 68 | public AssetFileDescriptor openAssetFile(String callingPackage, Uri uri, String mode) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 69 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 70 | } |
| 71 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 72 | public ContentProviderResult[] applyBatch(String callingPackage, |
| 73 | ArrayList<ContentProviderOperation> operations) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 74 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 75 | } |
| 76 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 77 | public Cursor query(String callingPackage, Uri url, String[] projection, String selection, |
| 78 | String[] selectionArgs, |
Jeff Brown | 4c1241d | 2012-02-02 17:05:00 -0800 | [diff] [blame] | 79 | String sortOrder, ICancellationSignal cancellationSignal) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 80 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 81 | } |
| 82 | |
| 83 | public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, |
| 84 | String sortOrder) { |
| 85 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 86 | } |
| 87 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 88 | public int update(String callingPackage, Uri url, ContentValues values, String selection, |
| 89 | String[] selectionArgs) throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 90 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 91 | } |
| 92 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 93 | public Bundle call(String callingPackage, String method, String request, Bundle args) |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 94 | throws RemoteException { |
| 95 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 96 | } |
| 97 | |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 98 | public IBinder asBinder() { |
| 99 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 100 | } |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 101 | |
| 102 | public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { |
| 103 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 104 | } |
| 105 | |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame^] | 106 | public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri url, String mimeType, |
| 107 | Bundle opts) throws RemoteException, FileNotFoundException { |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 108 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 109 | } |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 110 | |
| 111 | @Override |
Jeff Brown | 4c1241d | 2012-02-02 17:05:00 -0800 | [diff] [blame] | 112 | public ICancellationSignal createCancellationSignal() throws RemoteException { |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 113 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 114 | } |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 115 | } |