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 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 20 | import android.content.ContentProviderOperation; |
| 21 | import android.content.ContentProviderResult; |
| 22 | import android.content.ContentValues; |
| 23 | import android.content.EntityIterator; |
| 24 | import android.content.IContentProvider; |
| 25 | import android.content.res.AssetFileDescriptor; |
| 26 | import android.database.Cursor; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 27 | import android.net.Uri; |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 28 | import android.os.Bundle; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 29 | import android.os.IBinder; |
Jeff Brown | a7771df | 2012-05-07 20:06:46 -0700 | [diff] [blame] | 30 | import android.os.ICancellationSignal; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 31 | import android.os.ParcelFileDescriptor; |
| 32 | import android.os.RemoteException; |
| 33 | |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 34 | import java.io.FileNotFoundException; |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 35 | import java.util.ArrayList; |
| 36 | |
| 37 | /** |
| 38 | * Mock implementation of IContentProvider. All methods are non-functional and throw |
| 39 | * {@link java.lang.UnsupportedOperationException}. Tests can extend this class to |
| 40 | * implement behavior needed for tests. |
| 41 | * |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 42 | * @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] | 43 | */ |
| 44 | public class MockIContentProvider implements IContentProvider { |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 45 | @Override |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 46 | public int bulkInsert(String callingPackage, Uri url, ContentValues[] initialValues) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 47 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 48 | } |
| 49 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 50 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 51 | @SuppressWarnings("unused") |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 52 | public int delete(String callingPackage, Uri url, String selection, String[] selectionArgs) |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 53 | throws RemoteException { |
| 54 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 55 | } |
| 56 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 57 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 58 | public String getType(Uri url) { |
| 59 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 60 | } |
| 61 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 62 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 63 | @SuppressWarnings("unused") |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 64 | public Uri insert(String callingPackage, Uri url, ContentValues initialValues) |
| 65 | throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 66 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 67 | } |
| 68 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 69 | @Override |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 70 | public ParcelFileDescriptor openFile( |
Dianne Hackborn | ff17024 | 2014-11-19 10:59:01 -0800 | [diff] [blame] | 71 | String callingPackage, Uri url, String mode, ICancellationSignal signal, |
| 72 | IBinder callerToken) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 73 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 74 | } |
| 75 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 76 | @Override |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 77 | public AssetFileDescriptor openAssetFile( |
| 78 | String callingPackage, Uri uri, String mode, ICancellationSignal signal) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 79 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 80 | } |
| 81 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 82 | @Override |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 83 | public ContentProviderResult[] applyBatch(String callingPackage, |
| 84 | ArrayList<ContentProviderOperation> operations) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 85 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 86 | } |
| 87 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 88 | @Override |
| 89 | public Cursor query(String callingPackage, Uri url, @Nullable String[] projection, |
| 90 | @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal) { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 91 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 92 | } |
| 93 | |
| 94 | public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, |
| 95 | String sortOrder) { |
| 96 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 97 | } |
| 98 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 99 | @Override |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 100 | public int update(String callingPackage, Uri url, ContentValues values, String selection, |
| 101 | String[] selectionArgs) throws RemoteException { |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 102 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 103 | } |
| 104 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 105 | @Override |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 106 | public Bundle call(String callingPackage, String method, String request, Bundle args) |
Brad Fitzpatrick | 1877d01 | 2010-03-04 17:48:13 -0800 | [diff] [blame] | 107 | throws RemoteException { |
| 108 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 109 | } |
| 110 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 111 | @Override |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 112 | public IBinder asBinder() { |
| 113 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 114 | } |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 115 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 116 | @Override |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 117 | public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException { |
| 118 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 119 | } |
| 120 | |
Steve McKay | ea93fe7 | 2016-12-02 11:35:35 -0800 | [diff] [blame] | 121 | @Override |
Dianne Hackborn | 35654b6 | 2013-01-14 17:38:02 -0800 | [diff] [blame] | 122 | public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri url, String mimeType, |
Jeff Sharkey | bd3b902 | 2013-08-20 15:20:04 -0700 | [diff] [blame] | 123 | Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException { |
Dianne Hackborn | 23fdaf6 | 2010-08-06 12:16:55 -0700 | [diff] [blame] | 124 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 125 | } |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 126 | |
| 127 | @Override |
Jeff Brown | 4c1241d | 2012-02-02 17:05:00 -0800 | [diff] [blame] | 128 | public ICancellationSignal createCancellationSignal() throws RemoteException { |
Jeff Brown | 75ea64f | 2012-01-25 19:37:13 -0800 | [diff] [blame] | 129 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 130 | } |
Dianne Hackborn | 38ed2a4 | 2013-09-06 16:17:22 -0700 | [diff] [blame] | 131 | |
| 132 | @Override |
| 133 | public Uri canonicalize(String callingPkg, Uri uri) throws RemoteException { |
| 134 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public Uri uncanonicalize(String callingPkg, Uri uri) throws RemoteException { |
| 139 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 140 | } |
Ben Lin | 1cf454f | 2016-11-10 13:50:54 -0800 | [diff] [blame] | 141 | |
| 142 | @Override |
| 143 | public boolean refresh(String callingPkg, Uri url, Bundle args, |
| 144 | ICancellationSignal cancellationSignal) throws RemoteException { |
| 145 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 146 | } |
Daisuke Miyakawa | 8280c2b | 2009-10-22 08:36:42 +0900 | [diff] [blame] | 147 | } |