• 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.database.CursorWindow;
27 import android.database.IBulkCursor;
28 import android.database.IContentObserver;
29 import android.net.Uri;
30 import android.os.Bundle;
31 import android.os.IBinder;
32 import android.os.ParcelFileDescriptor;
33 import android.os.RemoteException;
34 
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  *
42  * @hide - @hide because this exposes bulkQuery() and call(), which must also be hidden.
43  */
44 public class MockIContentProvider implements IContentProvider {
bulkInsert(Uri url, ContentValues[] initialValues)45     public int bulkInsert(Uri url, ContentValues[] initialValues) {
46         throw new UnsupportedOperationException("unimplemented mock method");
47     }
48 
bulkQuery(Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder, IContentObserver observer, CursorWindow window)49     public IBulkCursor bulkQuery(Uri url, String[] projection, String selection,
50             String[] selectionArgs, String sortOrder, IContentObserver observer,
51             CursorWindow window) {
52         throw new UnsupportedOperationException("unimplemented mock method");
53     }
54 
55     @SuppressWarnings("unused")
delete(Uri url, String selection, String[] selectionArgs)56     public int delete(Uri url, String selection, String[] selectionArgs)
57             throws RemoteException {
58         throw new UnsupportedOperationException("unimplemented mock method");
59     }
60 
getType(Uri url)61     public String getType(Uri url) {
62         throw new UnsupportedOperationException("unimplemented mock method");
63     }
64 
65     @SuppressWarnings("unused")
insert(Uri url, ContentValues initialValues)66     public Uri insert(Uri url, ContentValues initialValues) throws RemoteException {
67         throw new UnsupportedOperationException("unimplemented mock method");
68     }
69 
openFile(Uri url, String mode)70     public ParcelFileDescriptor openFile(Uri url, String mode) {
71         throw new UnsupportedOperationException("unimplemented mock method");
72     }
73 
openAssetFile(Uri uri, String mode)74     public AssetFileDescriptor openAssetFile(Uri uri, String mode) {
75         throw new UnsupportedOperationException("unimplemented mock method");
76     }
77 
applyBatch(ArrayList<ContentProviderOperation> operations)78     public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) {
79         throw new UnsupportedOperationException("unimplemented mock method");
80     }
81 
query(Uri url, String[] projection, String selection, String[] selectionArgs, String sortOrder)82     public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs,
83             String sortOrder) {
84         throw new UnsupportedOperationException("unimplemented mock method");
85     }
86 
queryEntities(Uri url, String selection, String[] selectionArgs, String sortOrder)87     public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs,
88             String sortOrder) {
89         throw new UnsupportedOperationException("unimplemented mock method");
90     }
91 
update(Uri url, ContentValues values, String selection, String[] selectionArgs)92     public int update(Uri url, ContentValues values, String selection, String[] selectionArgs)
93             throws RemoteException {
94         throw new UnsupportedOperationException("unimplemented mock method");
95     }
96 
call(String method, String request, Bundle args)97     public Bundle call(String method, String request, Bundle args)
98             throws RemoteException {
99         throw new UnsupportedOperationException("unimplemented mock method");
100     }
101 
asBinder()102     public IBinder asBinder() {
103         throw new UnsupportedOperationException("unimplemented mock method");
104     }
105 }
106