1 /* 2 * Copyright (C) 2019 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 android.platform.test.annotations.AppModeFull; 20 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; 21 22 import org.junit.After; 23 import org.junit.Before; 24 import org.junit.Test; 25 import org.junit.runner.RunWith; 26 27 @RunWith(DeviceJUnit4ClassRunner.class) 28 @AppModeFull 29 public final class UseEmbeddedDexTest extends BaseAppSecurityTest { 30 31 private static final String PACKAGE_NAME = "com.android.cts.useembeddeddex"; 32 private static final String APK_CANONICAL = "CtsUseEmbeddedDexApp_Canonical.apk"; 33 private static final String APK_DEX_COMPRESSED = "CtsUseEmbeddedDexApp_DexCompressed.apk"; 34 private static final String APK_SPLIT_CANONICAL = 35 "CtsUseEmbeddedDexAppSplit_Canonical.apk"; 36 private static final String APK_SPLIT_COMPRESSED_DEX = 37 "CtsUseEmbeddedDexAppSplit_CompressedDex.apk"; 38 39 @After tearDown()40 public void tearDown() throws Exception { 41 getDevice().uninstallPackage(PACKAGE_NAME); 42 } 43 44 @Test testCanonicalInstall()45 public void testCanonicalInstall() throws Exception { 46 new InstallMultiple().addApk(APK_CANONICAL).run(); 47 } 48 49 @Test testBadInstallWithCompressedDex()50 public void testBadInstallWithCompressedDex() throws Exception { 51 new InstallMultiple().addApk(APK_DEX_COMPRESSED).runExpectingFailure(); 52 } 53 54 @Test testCanonicalInstallWithSplit()55 public void testCanonicalInstallWithSplit() throws Exception { 56 new InstallMultiple().addApk(APK_CANONICAL).addApk(APK_SPLIT_CANONICAL).run(); 57 } 58 59 @Test testBadInstallWithDexCompressedSplit()60 public void testBadInstallWithDexCompressedSplit() throws Exception { 61 new InstallMultiple().addApk(APK_CANONICAL).addApk(APK_SPLIT_COMPRESSED_DEX) 62 .runExpectingFailure(); 63 } 64 65 @Test testCanonicalInstallWithBaseThenSplit()66 public void testCanonicalInstallWithBaseThenSplit() throws Exception { 67 new InstallMultiple().addApk(APK_CANONICAL).run(); 68 new InstallMultiple().inheritFrom(PACKAGE_NAME).addApk(APK_SPLIT_CANONICAL).run(); 69 } 70 71 @Test testBadInstallWithBaseThenDexCompressedSplit()72 public void testBadInstallWithBaseThenDexCompressedSplit() throws Exception { 73 new InstallMultiple().addApk(APK_CANONICAL).run(); 74 new InstallMultiple().inheritFrom(PACKAGE_NAME).addApk(APK_SPLIT_COMPRESSED_DEX) 75 .runExpectingFailure(); 76 } 77 } 78