1 /* 2 * Copyright (C) 2016 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 com.android.documentsui.services; 18 19 import static com.google.common.collect.Lists.newArrayList; 20 21 import android.net.Uri; 22 import android.provider.DocumentsContract; 23 import android.test.suitebuilder.annotation.MediumTest; 24 25 import com.android.documentsui.model.DocumentInfo; 26 import com.android.documentsui.model.DocumentStack; 27 28 import java.util.List; 29 30 @MediumTest 31 public class DeleteJobTest extends AbstractJobTest<DeleteJob> { 32 33 public void testDeleteFiles() throws Exception { 34 Uri testFile1 = mDocs.createDocument(mSrcRoot, "text/plain", "test1.txt"); 35 mDocs.writeDocument(testFile1, HAM_BYTES); 36 37 Uri testFile2 = mDocs.createDocument(mSrcRoot, "text/plain", "test2.txt"); 38 mDocs.writeDocument(testFile2, FRUITY_BYTES); 39 40 createJob(newArrayList(testFile1, testFile2), 41 DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId)).run(); 42 mJobListener.waitForFinished(); 43 44 mDocs.assertChildCount(mSrcRoot, 0); 45 } 46 47 /** 48 * Creates a job with a stack consisting to the default src directory. 49 */ 50 private final DeleteJob createJob(List<Uri> srcs, Uri srcParent) throws Exception { 51 Uri stack = DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId); 52 return createJob(srcs, srcParent, stack); 53 } 54 55 @Override 56 // TODO: Remove inheritance, as stack is not used for deleting, nor srcParent. 57 DeleteJob createJob(List<DocumentInfo> srcs, DocumentInfo srcParent, DocumentStack stack) 58 throws Exception { 59 return new DeleteJob( 60 mContext, mContext, mJobListener, FileOperations.createJobId(), stack, srcs, 61 srcParent); 62 } 63 } 64