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 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.Document; 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 CopyJobTest extends AbstractCopyJobTest<CopyJob> { 32 33 public void testCopyFiles() throws Exception { 34 runCopyFilesTest(); 35 } 36 37 public void testCopyVirtualTypedFile() throws Exception { 38 runCopyVirtualTypedFileTest(); 39 } 40 41 public void testCopyVirtualNonTypedFile() throws Exception { 42 runCopyVirtualNonTypedFileTest(); 43 } 44 45 public void testCopy_BackendSideVirtualTypedFile_Fallback() throws Exception { 46 mDocs.assertChildCount(mDestRoot, 0); 47 48 Uri testFile = mDocs.createDocumentWithFlags( 49 mSrcRoot.documentId, "virtual/mime-type", "tokyo.sth", 50 Document.FLAG_VIRTUAL_DOCUMENT | Document.FLAG_SUPPORTS_COPY 51 | Document.FLAG_SUPPORTS_MOVE, "application/pdf"); 52 53 createJob(newArrayList(testFile)).run(); 54 55 mJobListener.waitForFinished(); 56 mDocs.assertChildCount(mDestRoot, 1); 57 mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf"); // Copy should convert file to PDF. 58 } 59 60 public void testCopyEmptyDir() throws Exception { 61 runCopyEmptyDirTest(); 62 } 63 64 public void testCopyDirRecursively() throws Exception { 65 runCopyDirRecursivelyTest(); 66 } 67 68 public void testNoCopyDirToSelf() throws Exception { 69 runNoCopyDirToSelfTest(); 70 } 71 72 public void testNoCopyDirToDescendent() throws Exception { 73 runNoCopyDirToDescendentTest(); 74 } 75 76 public void testCopyFileWithReadErrors() throws Exception { 77 runCopyFileWithReadErrorsTest(); 78 } 79 80 @Override 81 // TODO: Stop passing srcParent here, as it's not used for copying. 82 CopyJob createJob(List<DocumentInfo> srcs, DocumentInfo srcParent, DocumentStack stack) 83 throws Exception { 84 return new CopyJob( 85 mContext, mContext, mJobListener, FileOperations.createJobId(), stack, srcs); 86 } 87 } 88