Steve McKay | bbeba52 | 2016-01-13 17:17:39 -0800 | [diff] [blame^] | 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 android.net.Uri; |
| 20 | import android.test.suitebuilder.annotation.MediumTest; |
| 21 | |
| 22 | import com.android.documentsui.model.DocumentInfo; |
| 23 | import com.android.documentsui.model.DocumentStack; |
| 24 | |
| 25 | import com.google.common.collect.Lists; |
| 26 | |
| 27 | import java.util.List; |
| 28 | |
| 29 | @MediumTest |
| 30 | public class CopyJobTest extends BaseCopyJobTest { |
| 31 | |
| 32 | public void testCopyFiles() throws Exception { |
| 33 | runCopyFilesTest(); |
| 34 | } |
| 35 | |
| 36 | public void testCopyVirtualTypedFile() throws Exception { |
| 37 | runCopyVirtualTypedFileTest(); |
| 38 | } |
| 39 | |
| 40 | public void testCopyVirtualNonTypedFile() throws Exception { |
| 41 | runCopyVirtualNonTypedFileTest(); |
| 42 | } |
| 43 | |
| 44 | public void testCopyEmptyDir() throws Exception { |
| 45 | runCopyEmptyDirTest(); |
| 46 | } |
| 47 | |
| 48 | public void testCopyDirRecursively() throws Exception { |
| 49 | runCopyDirRecursivelyTest(); |
| 50 | } |
| 51 | |
| 52 | public void testNoCopyDirToSelf() throws Exception { |
| 53 | runNoCopyDirToSelfTest(); |
| 54 | } |
| 55 | |
| 56 | public void testNoCopyDirToDescendent() throws Exception { |
| 57 | runNoCopyDirToDescendentTest(); |
| 58 | } |
| 59 | |
| 60 | public void testCopyFileWithReadErrors() throws Exception { |
| 61 | runCopyFileWithReadErrorsTest(); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | CopyJob createJob(List<Uri> srcs, Uri destination) throws Exception { |
| 66 | DocumentStack stack = new DocumentStack(); |
| 67 | stack.push(DocumentInfo.fromUri(mResolver, destination)); |
| 68 | |
| 69 | List<DocumentInfo> srcDocs = Lists.newArrayList(); |
| 70 | for (Uri src : srcs) { |
| 71 | srcDocs.add(DocumentInfo.fromUri(mResolver, src)); |
| 72 | } |
| 73 | |
| 74 | return new CopyJob( |
| 75 | mContext, mContext, mJobListener, FileOperations.createJobId(), stack, srcDocs); |
| 76 | } |
| 77 | } |