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.android.documentsui.services.FileOperationService.OPERATION_COPY; 20 21 import static com.google.common.collect.Lists.newArrayList; 22 23 import android.net.Uri; 24 import android.provider.DocumentsContract.Document; 25 26 import androidx.test.filters.MediumTest; 27 28 @MediumTest 29 public class CopyJobTest extends AbstractCopyJobTest<CopyJob> { 30 CopyJobTest()31 public CopyJobTest() { 32 super(OPERATION_COPY); 33 } 34 testCopyFiles()35 public void testCopyFiles() throws Exception { 36 runCopyFilesTest(); 37 } 38 testCopyVirtualTypedFile()39 public void testCopyVirtualTypedFile() throws Exception { 40 runCopyVirtualTypedFileTest(); 41 } 42 testCopyVirtualNonTypedFile()43 public void testCopyVirtualNonTypedFile() throws Exception { 44 runCopyVirtualNonTypedFileTest(); 45 } 46 testCopy_BackendSideVirtualTypedFile_Fallback()47 public void testCopy_BackendSideVirtualTypedFile_Fallback() throws Exception { 48 mDocs.assertChildCount(mDestRoot, 0); 49 50 Uri testFile = mDocs.createDocumentWithFlags( 51 mSrcRoot.documentId, "virtual/mime-type", "tokyo.sth", 52 Document.FLAG_VIRTUAL_DOCUMENT | Document.FLAG_SUPPORTS_COPY 53 | Document.FLAG_SUPPORTS_MOVE, "application/pdf"); 54 55 createJob(newArrayList(testFile)).run(); 56 57 waitForJobFinished(); 58 mDocs.assertChildCount(mDestRoot, 1); 59 mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf"); // Copy should convert file to PDF. 60 } 61 testCopyEmptyDir()62 public void testCopyEmptyDir() throws Exception { 63 runCopyEmptyDirTest(); 64 } 65 testCopyDirRecursively()66 public void testCopyDirRecursively() throws Exception { 67 runCopyDirRecursivelyTest(); 68 } 69 testCopyDirRecursively_loadingInFirstCursor()70 public void testCopyDirRecursively_loadingInFirstCursor() throws Exception { 71 mDocs.setLoadingDuration(500); 72 testCopyDirRecursively(); 73 } 74 testNoCopyDirToSelf()75 public void testNoCopyDirToSelf() throws Exception { 76 runNoCopyDirToSelfTest(); 77 } 78 testNoCopyDirToDescendent()79 public void testNoCopyDirToDescendent() throws Exception { 80 runNoCopyDirToDescendentTest(); 81 } 82 testCopyFileWithReadErrors()83 public void testCopyFileWithReadErrors() throws Exception { 84 runCopyFileWithReadErrorsTest(); 85 } 86 testCopyProgressWithFileCount()87 public void testCopyProgressWithFileCount() throws Exception { 88 runCopyProgressForFileCountTest(); 89 } 90 testCopyProgressWithByteCount()91 public void testCopyProgressWithByteCount() throws Exception { 92 runCopyProgressForByteCountTest(); 93 } 94 } 95