• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.cts.appsecurity;
18 
19 import com.android.cts.tradefed.build.CtsBuildHelper;
20 import com.android.tradefed.build.IBuildInfo;
21 import com.android.tradefed.device.DeviceNotAvailableException;
22 import com.android.tradefed.testtype.DeviceTestCase;
23 import com.android.tradefed.testtype.IAbi;
24 import com.android.tradefed.testtype.IAbiReceiver;
25 import com.android.tradefed.testtype.IBuildReceiver;
26 
27 public class DocumentsTest extends DeviceTestCase implements IAbiReceiver, IBuildReceiver {
28     private static final String PROVIDER_PKG = "com.android.cts.documentprovider";
29     private static final String PROVIDER_APK = "CtsDocumentProvider.apk";
30 
31     private static final String CLIENT_PKG = "com.android.cts.documentclient";
32     private static final String CLIENT_APK = "CtsDocumentClient.apk";
33 
34     private IAbi mAbi;
35     private CtsBuildHelper mCtsBuild;
36 
37     @Override
setAbi(IAbi abi)38     public void setAbi(IAbi abi) {
39         mAbi = abi;
40     }
41 
42     @Override
setBuild(IBuildInfo buildInfo)43     public void setBuild(IBuildInfo buildInfo) {
44         mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
45     }
46 
47     @Override
setUp()48     protected void setUp() throws Exception {
49         super.setUp();
50 
51         assertNotNull(mAbi);
52         assertNotNull(mCtsBuild);
53 
54         getDevice().uninstallPackage(PROVIDER_PKG);
55         getDevice().uninstallPackage(CLIENT_PKG);
56 
57         assertNull(getDevice().installPackage(mCtsBuild.getTestApp(PROVIDER_APK), false));
58         assertNull(getDevice().installPackage(mCtsBuild.getTestApp(CLIENT_APK), false));
59     }
60 
61     @Override
tearDown()62     protected void tearDown() throws Exception {
63         super.tearDown();
64 
65         getDevice().uninstallPackage(PROVIDER_PKG);
66         getDevice().uninstallPackage(CLIENT_PKG);
67     }
68 
testOpenSimple()69     public void testOpenSimple() throws Exception {
70         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testOpenSimple");
71     }
72 
testCreateNew()73     public void testCreateNew() throws Exception {
74         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testCreateNew");
75     }
76 
testCreateExisting()77     public void testCreateExisting() throws Exception {
78         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testCreateExisting");
79     }
80 
testTree()81     public void testTree() throws Exception {
82         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testTree");
83     }
84 
testGetContent()85     public void testGetContent() throws Exception {
86         runDeviceTests(CLIENT_PKG, ".DocumentsClientTest", "testGetContent");
87     }
88 
runDeviceTests(String packageName, String testClassName, String testMethodName)89     public void runDeviceTests(String packageName, String testClassName, String testMethodName)
90             throws DeviceNotAvailableException {
91         Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
92     }
93 }
94