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.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.ParcelFileDescriptor;
     30 import android.os.RemoteException;
     31 
     32 import java.io.FileNotFoundException;
     33 import java.util.ArrayList;
     34 
     35 /**
     36  * Mock implementation of IContentProvider.  All methods are non-functional and throw
     37  * {@link java.lang.UnsupportedOperationException}.  Tests can extend this class to
     38  * implement behavior needed for tests.
     39  *
     40  * @hide - @hide because this exposes bulkQuery() and call(), which must also be hidden.
     41  */
     42 public class MockIContentProvider implements IContentProvider {
     43     public int bulkInsert(Uri url, ContentValues[] initialValues) {
     44         throw new UnsupportedOperationException("unimplemented mock method");
     45     }
     46 
     47     @SuppressWarnings("unused")
     48     public int delete(Uri url, String selection, String[] selectionArgs)
     49             throws RemoteException {
     50         throw new UnsupportedOperationException("unimplemented mock method");
     51     }
     52 
     53     public String getType(Uri url) {
     54         throw new UnsupportedOperationException("unimplemented mock method");
     55     }
     56 
     57     @SuppressWarnings("unused")
     58     public Uri insert(Uri url, ContentValues initialValues) throws RemoteException {
     59         throw new UnsupportedOperationException("unimplemented mock method");
     60     }
     61 
     62     public ParcelFileDescriptor openFile(Uri url, String mode) {
     63         throw new UnsupportedOperationException("unimplemented mock method");
     64     }
     65 
     66     public AssetFileDescriptor openAssetFile(Uri uri, String mode) {
     67         throw new UnsupportedOperationException("unimplemented mock method");
     68     }
     69 
     70     public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) {
     71         throw new UnsupportedOperationException("unimplemented mock method");
     72     }
     73 
     74     public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs,
     75             String sortOrder) {
     76         throw new UnsupportedOperationException("unimplemented mock method");
     77     }
     78 
     79     public EntityIterator queryEntities(Uri url, String selection, String[] selectionArgs,
     80             String sortOrder) {
     81         throw new UnsupportedOperationException("unimplemented mock method");
     82     }
     83 
     84     public int update(Uri url, ContentValues values, String selection, String[] selectionArgs)
     85             throws RemoteException {
     86         throw new UnsupportedOperationException("unimplemented mock method");
     87     }
     88 
     89     public Bundle call(String method, String request, Bundle args)
     90             throws RemoteException {
     91         throw new UnsupportedOperationException("unimplemented mock method");
     92     }
     93 
     94     public IBinder asBinder() {
     95         throw new UnsupportedOperationException("unimplemented mock method");
     96     }
     97 
     98     public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
     99         throw new UnsupportedOperationException("unimplemented mock method");
    100     }
    101 
    102     public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts)
    103             throws RemoteException, FileNotFoundException {
    104         throw new UnsupportedOperationException("unimplemented mock method");
    105     }
    106 }
    107