| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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.ContentValues; |
| 20 | import android.content.IContentProvider; |
| Fred Quintana | 6a8d5332f | 2009-05-07 17:35:38 -0700 | [diff] [blame] | 21 | import android.content.Entity; |
| 22 | import android.content.EntityIterator; |
| Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 23 | import android.content.ContentProviderResult; |
| 24 | import android.content.ContentProviderOperation; |
| 25 | import android.content.OperationApplicationException; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.res.AssetFileDescriptor; |
| 27 | import android.database.Cursor; |
| 28 | import android.database.CursorWindow; |
| 29 | import android.database.IBulkCursor; |
| 30 | import android.database.IContentObserver; |
| 31 | import android.net.Uri; |
| 32 | import android.os.RemoteException; |
| 33 | import android.os.IBinder; |
| 34 | import android.os.ParcelFileDescriptor; |
| 35 | |
| 36 | import java.io.FileNotFoundException; |
| Fred Quintana | 03d9490 | 2009-05-22 14:23:31 -0700 | [diff] [blame^] | 37 | import java.util.ArrayList; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Mock implementation of IContentProvider that does nothing. All methods are non-functional and |
| 41 | * throw {@link java.lang.UnsupportedOperationException}. Tests can extend this class to |
| 42 | * implement behavior needed for tests. |
| 43 | * |
| 44 | * @hide - Because IContentProvider hides bulkQuery(), this doesn't pass through JavaDoc |
| 45 | * without generating errors. |
| 46 | * |
| 47 | */ |
| 48 | public class MockContentProvider implements IContentProvider { |
| 49 | |
| 50 | @SuppressWarnings("unused") |
| 51 | public int bulkInsert(Uri url, ContentValues[] initialValues) throws RemoteException { |
| 52 | // TODO Auto-generated method stub |
| 53 | return 0; |
| 54 | } |
| 55 | |
| Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 56 | public Uri insertEntity(Uri uri, Entity entities) throws RemoteException { |
| Fred Quintana | 6a8d5332f | 2009-05-07 17:35:38 -0700 | [diff] [blame] | 57 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 58 | } |
| 59 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | @SuppressWarnings("unused") |
| 61 | public IBulkCursor bulkQuery(Uri url, String[] projection, String selection, |
| 62 | String[] selectionArgs, String sortOrder, IContentObserver observer, |
| 63 | CursorWindow window) throws RemoteException { |
| 64 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 65 | } |
| 66 | |
| 67 | @SuppressWarnings("unused") |
| 68 | public int delete(Uri url, String selection, String[] selectionArgs) |
| 69 | throws RemoteException { |
| 70 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 71 | } |
| 72 | |
| 73 | @SuppressWarnings("unused") |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | public String getType(Uri url) throws RemoteException { |
| 75 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 76 | } |
| 77 | |
| 78 | @SuppressWarnings("unused") |
| 79 | public Uri insert(Uri url, ContentValues initialValues) throws RemoteException { |
| 80 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 81 | } |
| 82 | |
| 83 | @SuppressWarnings("unused") |
| 84 | public ParcelFileDescriptor openFile(Uri url, String mode) throws RemoteException, |
| 85 | FileNotFoundException { |
| 86 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 87 | } |
| 88 | |
| 89 | @SuppressWarnings("unused") |
| 90 | public AssetFileDescriptor openAssetFile(Uri uri, String mode) |
| 91 | throws FileNotFoundException { |
| 92 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 93 | } |
| Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 94 | |
| Fred Quintana | 03d9490 | 2009-05-22 14:23:31 -0700 | [diff] [blame^] | 95 | public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) |
| 96 | throws RemoteException, OperationApplicationException { |
| Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 97 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 98 | } |
| 99 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | @SuppressWarnings("unused") |
| 101 | public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, |
| 102 | String sortOrder) throws RemoteException { |
| 103 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 104 | } |
| 105 | |
| Fred Quintana | 6a8d5332f | 2009-05-07 17:35:38 -0700 | [diff] [blame] | 106 | public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs, |
| 107 | String sortOrder) throws RemoteException { |
| 108 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 109 | } |
| 110 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | @SuppressWarnings("unused") |
| 112 | public int update(Uri url, ContentValues values, String selection, String[] selectionArgs) |
| 113 | throws RemoteException { |
| 114 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 115 | } |
| 116 | |
| Fred Quintana | 8943737 | 2009-05-15 15:10:40 -0700 | [diff] [blame] | 117 | public int updateEntity(Uri uri, Entity entity) throws RemoteException { |
| Fred Quintana | 6a8d5332f | 2009-05-07 17:35:38 -0700 | [diff] [blame] | 118 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 119 | } |
| 120 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | public IBinder asBinder() { |
| 122 | throw new UnsupportedOperationException("unimplemented mock method"); |
| 123 | } |
| 124 | |
| 125 | } |