1 /* 2 * Copyright (C) 2020 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 static org.junit.Assert.assertNotNull; 20 import static org.junit.Assert.assertNull; 21 22 import android.platform.test.annotations.AppModeFull; 23 24 import com.android.tradefed.device.DeviceNotAvailableException; 25 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; 26 27 import org.junit.After; 28 import org.junit.Before; 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 32 import java.io.File; 33 34 @RunWith(DeviceJUnit4ClassRunner.class) 35 public class SessionReferrerUriTest extends BaseAppSecurityTest { 36 37 private static final String SESSION_INSPECTOR_A_APK = "CtsSessionInspectorAppA.apk"; 38 private static final String SESSION_INSPECTOR_B_APK = "CtsSessionInspectorAppB.apk"; 39 private static final String SESSION_INSPECTOR_PKG_A = "com.android.cts.sessioninspector.a"; 40 private static final String SESSION_INSPECTOR_PKG_B = "com.android.cts.sessioninspector.b"; 41 42 @Before setup()43 public void setup() throws Exception { 44 new InstallMultiple().addFile(SESSION_INSPECTOR_A_APK).run(); 45 new InstallMultiple().addFile(SESSION_INSPECTOR_B_APK).run(); 46 } 47 48 @After teardown()49 public void teardown() throws Exception { 50 getDevice().uninstallPackage(SESSION_INSPECTOR_PKG_A); 51 getDevice().uninstallPackage(SESSION_INSPECTOR_PKG_B); 52 } 53 54 @Test 55 @AppModeFull(reason = "Only full apps may install") testSessionReferrerUriVisibleToOwner()56 public void testSessionReferrerUriVisibleToOwner() throws DeviceNotAvailableException { 57 // Device test launches an Activity, so it should run under current user. 58 Utils.runDeviceTestsAsCurrentUser(getDevice(), SESSION_INSPECTOR_PKG_A, 59 "com.android.cts.sessioninspector.SessionInspectorTest", "testOnlyOwnerCanSee"); 60 Utils.runDeviceTestsAsCurrentUser(getDevice(), SESSION_INSPECTOR_PKG_B, 61 "com.android.cts.sessioninspector.SessionInspectorTest", "testOnlyOwnerCanSee"); 62 } 63 } 64