1 /*
2  * Copyright (C) 2014 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 android.appsecurity.cts;
18 
19 import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
20 
21 /**
22  * Set of tests that verify behavior of
23  * {@link android.provider.DocumentsContract} and related intents.
24  */
25 public class DocumentsTest extends DocumentsTestCase {
26     private static final String PROVIDER_PKG = "com.android.cts.documentprovider";
27     private static final String STUBIME_PKG = "com.android.cts.stubime";
28     private static final String PROVIDER_APK = "CtsDocumentProvider.apk";
29     private static final String STUBIME_APK = "CtsStubIme.apk";
30 
31     @Override
setUp()32     protected void setUp() throws Exception {
33         super.setUp();
34 
35         getDevice().uninstallPackage(PROVIDER_PKG);
36         CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(mCtsBuild);
37         assertNull(getDevice().installPackage(buildHelper.getTestFile(PROVIDER_APK), false));
38         assertNull(getDevice().installPackage(buildHelper.getTestFile(STUBIME_APK), false));
39     }
40 
41     @Override
tearDown()42     protected void tearDown() throws Exception {
43         super.tearDown();
44 
45         getDevice().uninstallPackage(PROVIDER_PKG);
46         getDevice().uninstallPackage(STUBIME_PKG);
47     }
48 
testOpenSimple()49     public void testOpenSimple() throws Exception {
50         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testOpenSimple");
51     }
52 
testOpenVirtual()53     public void testOpenVirtual() throws Exception {
54         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testOpenVirtual");
55     }
56 
testCreateNew()57     public void testCreateNew() throws Exception {
58         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testCreateNew");
59     }
60 
testCreateExisting()61     public void testCreateExisting() throws Exception {
62         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testCreateExisting");
63     }
64 
testTree()65     public void testTree() throws Exception {
66         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testTree");
67     }
68 
testGetContent_rootsShowing()69     public void testGetContent_rootsShowing() throws Exception {
70         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testGetContent_rootsShowing");
71     }
72 
testGetContentWithQuery_matchingFileShowing()73     public void testGetContentWithQuery_matchingFileShowing() throws Exception {
74         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest",
75                 "testGetContentWithQuery_matchingFileShowing");
76     }
77 
testGetContent_returnsResultToCallingActivity()78     public void testGetContent_returnsResultToCallingActivity() throws Exception {
79         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest",
80                 "testGetContent_returnsResultToCallingActivity");
81     }
82 
testTransferDocument()83     public void testTransferDocument() throws Exception {
84         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testTransferDocument");
85     }
86 
testFindDocumentPathInScopedAccess()87     public void testFindDocumentPathInScopedAccess() throws Exception {
88         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testFindDocumentPathInScopedAccess");
89     }
90 
testOpenDocumentAtInitialLocation()91     public void testOpenDocumentAtInitialLocation() throws Exception {
92         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testOpenDocumentAtInitialLocation");
93     }
94 
testOpenDocumentTreeAtInitialLocation()95     public void testOpenDocumentTreeAtInitialLocation() throws Exception {
96         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testOpenDocumentTreeAtInitialLocation");
97     }
98 
testOpenRootWithoutRootIdAtInitialLocation()99     public void testOpenRootWithoutRootIdAtInitialLocation() throws Exception {
100         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest",
101                 "testOpenRootWithoutRootIdAtInitialLocation");
102     }
103 
testCreateDocumentAtInitialLocation()104     public void testCreateDocumentAtInitialLocation() throws Exception {
105         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testCreateDocumentAtInitialLocation");
106     }
107 
testCreateWebLink()108     public void testCreateWebLink() throws Exception {
109         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testCreateWebLink");
110     }
111 
testEject()112     public void testEject() throws Exception {
113         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testEject");
114     }
115 }
116