Home | History | Annotate | Download | only in mock
      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.annotation.Nullable;
     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;
     27 import android.net.Uri;
     28 import android.os.Bundle;
     29 import android.os.IBinder;
     30 import android.os.ICancellationSignal;
     31 import android.os.ParcelFileDescriptor;
     32 import android.os.RemoteException;
     33 
     34 import java.io.FileNotFoundException;
     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 {
     45     @Override
     46     public int bulkInsert(String callingPackage, Uri url, ContentValues[] initialValues) {
     47         throw new UnsupportedOperationException("unimplemented mock method");
     48     }
     49 
     50     @Override
     51     @SuppressWarnings("unused")
     52     public int delete(String callingPackage, Uri url, String selection, String[] selectionArgs)
     53             throws RemoteException {
     54         throw new UnsupportedOperationException("unimplemented mock method");
     55     }
     56 
     57     @Override
     58     public String getType(Uri url) {
     59         throw new UnsupportedOperationException("unimplemented mock method");
     60     }
     61 
     62     @Override
     63     @SuppressWarnings("unused")
     64     public Uri insert(String callingPackage, Uri url, ContentValues initialValues)
     65             throws RemoteException {
     66         throw new UnsupportedOperationException("unimplemented mock method");
     67     }
     68 
     69     @Override
     70     public ParcelFileDescriptor openFile(
     71             String callingPackage, Uri url, String mode, ICancellationSignal signal,
     72             IBinder callerToken) {
     73         throw new UnsupportedOperationException("unimplemented mock method");
     74     }
     75 
     76     @Override
     77     public AssetFileDescriptor openAssetFile(
     78             String callingPackage, Uri uri, String mode, ICancellationSignal signal) {
     79         throw new UnsupportedOperationException("unimplemented mock method");
     80     }
     81 
     82     @Override
     83     public ContentProviderResult[] applyBatch(String callingPackage,
     84             ArrayList<ContentProviderOperation> operations) {
     85         throw new UnsupportedOperationException("unimplemented mock method");
     86     }
     87 
     88     @Override
     89     public Cursor query(String callingPackage, Uri url, @Nullable String[] projection,
     90             @Nullable Bundle queryArgs, @Nullable ICancellationSignal cancellationSignal) {
     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 
     99     @Override
    100     public int update(String callingPackage, Uri url, ContentValues values, String selection,
    101             String[] selectionArgs) throws RemoteException {
    102         throw new UnsupportedOperationException("unimplemented mock method");
    103     }
    104 
    105     @Override
    106     public Bundle call(String callingPackage, String method, String request, Bundle args)
    107             throws RemoteException {
    108         throw new UnsupportedOperationException("unimplemented mock method");
    109     }
    110 
    111     @Override
    112     public IBinder asBinder() {
    113         throw new UnsupportedOperationException("unimplemented mock method");
    114     }
    115 
    116     @Override
    117     public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
    118         throw new UnsupportedOperationException("unimplemented mock method");
    119     }
    120 
    121     @Override
    122     public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri url, String mimeType,
    123             Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException {
    124         throw new UnsupportedOperationException("unimplemented mock method");
    125     }
    126 
    127     @Override
    128     public ICancellationSignal createCancellationSignal() throws RemoteException {
    129         throw new UnsupportedOperationException("unimplemented mock method");
    130     }
    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     }
    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     }
    147 }
    148