1/* 2 * Copyright (C) 2015 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 com.android.documentsui.dirlist; 18 19import android.net.Uri; 20import android.os.Bundle; 21import android.provider.DocumentsContract; 22import android.test.mock.MockContentProvider; 23 24import com.android.documentsui.model.DocumentInfo; 25 26import java.util.ArrayList; 27import java.util.List; 28 29/** 30 * A very simple test double for ContentProvider. Useful in this package only. 31 */ 32class TestContentProvider extends MockContentProvider { 33 List<Uri> mDeleted = new ArrayList<>(); 34 35 @Override 36 public Bundle call(String method, String arg, Bundle extras) { 37 // Intercept and log delete method calls. 38 if (DocumentsContract.METHOD_DELETE_DOCUMENT.equals(method)) { 39 final Uri documentUri = extras.getParcelable(DocumentsContract.EXTRA_URI); 40 mDeleted.add(documentUri); 41 return new Bundle(); 42 } else { 43 return super.call(method, arg, extras); 44 } 45 } 46 47 public void assertWasDeleted(DocumentInfo doc) { 48 ModelTest.assertTrue(mDeleted.contains(doc.derivedUri)); 49 } 50}