• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
bulkInsert(Uri url, ContentValues[] initialValues)44     public int bulkInsert(Uri url, ContentValues[] initialValues) {
45         throw new UnsupportedOperationException("unimplemented mock method");
46     }
47 
48     @SuppressWarnings("unused")
delete(Uri url, String selection, String[] selectionArgs)49     public int delete(Uri url, String selection, String[] selectionArgs)
50             throws RemoteException {
51         throw new UnsupportedOperationException("unimplemented mock method");
52     }
53 
getType(Uri url)54     public String getType(Uri url) {
55         throw new UnsupportedOperationException("unimplemented mock method");
56     }
57 
58     @SuppressWarnings("unused")
insert(Uri url, ContentValues initialValues)59     public Uri insert(Uri url, ContentValues initialValues) throws RemoteException {
60         throw new UnsupportedOperationException("unimplemented mock method");
61     }
62 
openFile(Uri url, String mode)63     public ParcelFileDescriptor openFile(Uri url, String mode) {
64         throw new UnsupportedOperationException("unimplemented mock method");
65     }
66 
openAssetFile(Uri uri, String mode)67     public AssetFileDescriptor openAssetFile(Uri uri, String mode) {
68         throw new UnsupportedOperationException("unimplemented mock method");
69     }
70 
applyBatch(ArrayList<ContentProviderOperation> operations)71     public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) {
72         throw new UnsupportedOperationException("unimplemented mock method");
73     }
74 
query(Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder, ICancellationSignal cancellationSignal)75     public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs,
76             String sortOrder, ICancellationSignal cancellationSignal) {
77         throw new UnsupportedOperationException("unimplemented mock method");
78     }
79 
queryEntities(Uri url, String selection, String[] selectionArgs, String sortOrder)80     public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs,
81             String sortOrder) {
82         throw new UnsupportedOperationException("unimplemented mock method");
83     }
84 
update(Uri url, ContentValues values, String selection, String[] selectionArgs)85     public int update(Uri url, ContentValues values, String selection, String[] selectionArgs)
86             throws RemoteException {
87         throw new UnsupportedOperationException("unimplemented mock method");
88     }
89 
call(String method, String request, Bundle args)90     public Bundle call(String method, String request, Bundle args)
91             throws RemoteException {
92         throw new UnsupportedOperationException("unimplemented mock method");
93     }
94 
asBinder()95     public IBinder asBinder() {
96         throw new UnsupportedOperationException("unimplemented mock method");
97     }
98 
getStreamTypes(Uri url, String mimeTypeFilter)99     public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
100         throw new UnsupportedOperationException("unimplemented mock method");
101     }
102 
openTypedAssetFile(Uri url, String mimeType, Bundle opts)103     public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts)
104             throws RemoteException, FileNotFoundException {
105         throw new UnsupportedOperationException("unimplemented mock method");
106     }
107 
108     @Override
createCancellationSignal()109     public ICancellationSignal createCancellationSignal() throws RemoteException {
110         throw new UnsupportedOperationException("unimplemented mock method");
111     }
112 }
113