• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import android.support.test.filters.MediumTest;
26 
27 @MediumTest
28 public class CopyJobTest extends AbstractCopyJobTest<CopyJob> {
29 
CopyJobTest()30     public CopyJobTest() {
31         super(OPERATION_COPY);
32     }
33 
testCopyFiles()34     public void testCopyFiles() throws Exception {
35         runCopyFilesTest();
36     }
37 
testCopyVirtualTypedFile()38     public void testCopyVirtualTypedFile() throws Exception {
39         runCopyVirtualTypedFileTest();
40     }
41 
testCopyVirtualNonTypedFile()42     public void testCopyVirtualNonTypedFile() throws Exception {
43         runCopyVirtualNonTypedFileTest();
44     }
45 
testCopy_BackendSideVirtualTypedFile_Fallback()46     public void testCopy_BackendSideVirtualTypedFile_Fallback() throws Exception {
47         mDocs.assertChildCount(mDestRoot, 0);
48 
49         Uri testFile = mDocs.createDocumentWithFlags(
50                 mSrcRoot.documentId, "virtual/mime-type", "tokyo.sth",
51                 Document.FLAG_VIRTUAL_DOCUMENT | Document.FLAG_SUPPORTS_COPY
52                         | Document.FLAG_SUPPORTS_MOVE, "application/pdf");
53 
54         createJob(newArrayList(testFile)).run();
55 
56         waitForJobFinished();
57         mDocs.assertChildCount(mDestRoot, 1);
58         mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf");  // Copy should convert file to PDF.
59     }
60 
testCopyEmptyDir()61     public void testCopyEmptyDir() throws Exception {
62         runCopyEmptyDirTest();
63     }
64 
testCopyDirRecursively()65     public void testCopyDirRecursively() throws Exception {
66         runCopyDirRecursivelyTest();
67     }
68 
testCopyDirRecursively_loadingInFirstCursor()69     public void testCopyDirRecursively_loadingInFirstCursor() throws Exception {
70         mDocs.setLoadingDuration(500);
71         testCopyDirRecursively();
72     }
73 
testNoCopyDirToSelf()74     public void testNoCopyDirToSelf() throws Exception {
75         runNoCopyDirToSelfTest();
76     }
77 
testNoCopyDirToDescendent()78     public void testNoCopyDirToDescendent() throws Exception {
79         runNoCopyDirToDescendentTest();
80     }
81 
testCopyFileWithReadErrors()82     public void testCopyFileWithReadErrors() throws Exception {
83         runCopyFileWithReadErrorsTest();
84     }
85 }
86