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