blob: 2b4fce620938fe091419ed3b6cb89ef838a7bdb0 [file] [log] [blame]
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +09001/*
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
17package android.test.mock;
18
19import android.content.ContentProviderOperation;
20import android.content.ContentProviderResult;
21import android.content.ContentValues;
22import android.content.EntityIterator;
23import android.content.IContentProvider;
24import android.content.res.AssetFileDescriptor;
25import android.database.Cursor;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090026import android.net.Uri;
Brad Fitzpatrick1877d012010-03-04 17:48:13 -080027import android.os.Bundle;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090028import android.os.IBinder;
Jeff Browna7771df2012-05-07 20:06:46 -070029import android.os.ICancellationSignal;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090030import android.os.ParcelFileDescriptor;
31import android.os.RemoteException;
32
Dianne Hackborn23fdaf62010-08-06 12:16:55 -070033import java.io.FileNotFoundException;
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090034import 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 Fitzpatrick1877d012010-03-04 17:48:13 -080041 * @hide - @hide because this exposes bulkQuery() and call(), which must also be hidden.
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090042 */
43public class MockIContentProvider implements IContentProvider {
Dianne Hackborn35654b62013-01-14 17:38:02 -080044 public int bulkInsert(String callingPackage, Uri url, ContentValues[] initialValues) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090045 throw new UnsupportedOperationException("unimplemented mock method");
46 }
47
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090048 @SuppressWarnings("unused")
Dianne Hackborn35654b62013-01-14 17:38:02 -080049 public int delete(String callingPackage, Uri url, String selection, String[] selectionArgs)
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090050 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 Hackborn35654b62013-01-14 17:38:02 -080059 public Uri insert(String callingPackage, Uri url, ContentValues initialValues)
60 throws RemoteException {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090061 throw new UnsupportedOperationException("unimplemented mock method");
62 }
63
Dianne Hackborn35654b62013-01-14 17:38:02 -080064 public ParcelFileDescriptor openFile(String callingPackage, Uri url, String mode) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090065 throw new UnsupportedOperationException("unimplemented mock method");
66 }
67
Dianne Hackborn35654b62013-01-14 17:38:02 -080068 public AssetFileDescriptor openAssetFile(String callingPackage, Uri uri, String mode) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090069 throw new UnsupportedOperationException("unimplemented mock method");
70 }
71
Dianne Hackborn35654b62013-01-14 17:38:02 -080072 public ContentProviderResult[] applyBatch(String callingPackage,
73 ArrayList<ContentProviderOperation> operations) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090074 throw new UnsupportedOperationException("unimplemented mock method");
75 }
76
Dianne Hackborn35654b62013-01-14 17:38:02 -080077 public Cursor query(String callingPackage, Uri url, String[] projection, String selection,
78 String[] selectionArgs,
Jeff Brown4c1241d2012-02-02 17:05:00 -080079 String sortOrder, ICancellationSignal cancellationSignal) {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090080 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 Hackborn35654b62013-01-14 17:38:02 -080088 public int update(String callingPackage, Uri url, ContentValues values, String selection,
89 String[] selectionArgs) throws RemoteException {
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090090 throw new UnsupportedOperationException("unimplemented mock method");
91 }
92
Dianne Hackborn35654b62013-01-14 17:38:02 -080093 public Bundle call(String callingPackage, String method, String request, Bundle args)
Brad Fitzpatrick1877d012010-03-04 17:48:13 -080094 throws RemoteException {
95 throw new UnsupportedOperationException("unimplemented mock method");
96 }
97
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +090098 public IBinder asBinder() {
99 throw new UnsupportedOperationException("unimplemented mock method");
100 }
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700101
102 public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
103 throw new UnsupportedOperationException("unimplemented mock method");
104 }
105
Dianne Hackborn35654b62013-01-14 17:38:02 -0800106 public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri url, String mimeType,
107 Bundle opts) throws RemoteException, FileNotFoundException {
Dianne Hackborn23fdaf62010-08-06 12:16:55 -0700108 throw new UnsupportedOperationException("unimplemented mock method");
109 }
Jeff Brown75ea64f2012-01-25 19:37:13 -0800110
111 @Override
Jeff Brown4c1241d2012-02-02 17:05:00 -0800112 public ICancellationSignal createCancellationSignal() throws RemoteException {
Jeff Brown75ea64f2012-01-25 19:37:13 -0800113 throw new UnsupportedOperationException("unimplemented mock method");
114 }
Daisuke Miyakawa8280c2b2009-10-22 08:36:42 +0900115}