1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 package android.appsecurity.cts; 17 18 import android.platform.test.annotations.AppModeFull; 19 import android.platform.test.annotations.AppModeInstant; 20 import android.platform.test.annotations.Presubmit; 21 22 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; 23 24 import org.junit.After; 25 import org.junit.Before; 26 import org.junit.Test; 27 import org.junit.runner.RunWith; 28 29 import java.io.FileNotFoundException; 30 31 @Presubmit 32 @RunWith(DeviceJUnit4ClassRunner.class) 33 public class IsolatedSplitsTests extends BaseAppSecurityTest { 34 private static final String PKG = "com.android.cts.isolatedsplitapp"; 35 private static final String TEST_CLASS = PKG + ".SplitAppTest"; 36 37 /* The feature hierarchy looks like this: 38 39 APK_BASE <- APK_FEATURE_A <- APK_FEATURE_B 40 ^------ APK_FEATURE_C 41 42 */ 43 private static final String APK_BASE = "CtsIsolatedSplitApp.apk"; 44 private static final String APK_BASE_pl = "CtsIsolatedSplitApp_pl.apk"; 45 private static final String APK_FEATURE_A = "CtsIsolatedSplitAppFeatureA.apk"; 46 private static final String APK_FEATURE_A_pl = "CtsIsolatedSplitAppFeatureA_pl.apk"; 47 private static final String APK_FEATURE_B = "CtsIsolatedSplitAppFeatureB.apk"; 48 private static final String APK_FEATURE_B_pl = "CtsIsolatedSplitAppFeatureB_pl.apk"; 49 private static final String APK_FEATURE_C = "CtsIsolatedSplitAppFeatureC.apk"; 50 private static final String APK_FEATURE_C_pl = "CtsIsolatedSplitAppFeatureC_pl.apk"; 51 private static final String APK_FEATURE_A_DiffRev = "CtsIsolatedSplitAppFeatureADiffRev.apk"; 52 53 private static final String APK_BASE_WITHOUT_EXTRACTING = APK_BASE; 54 private static final String APK_FEATURE_JNI_WITHOUT_EXTRACTING = 55 "CtsIsolatedSplitAppExtractNativeLibsFalseJni.apk"; 56 private static final String APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING = 57 "CtsIsolatedSplitAppExtractNativeLibsFalseNumberProviderA.apk"; 58 private static final String APK_FEATURE_PROVIDER_B_WITHOUT_EXTRACTING = 59 "CtsIsolatedSplitAppExtractNativeLibsFalseNumberProviderB.apk"; 60 private static final String APK_FEATURE_PROXY_WITHOUT_EXTRACTING = 61 "CtsIsolatedSplitAppExtractNativeLibsFalseNumberProxy.apk"; 62 63 private static final String APK_BASE_WITH_EXTRACTING = 64 "CtsIsolatedSplitAppExtractNativeLibsTrue.apk"; 65 private static final String APK_FEATURE_JNI_WITH_EXTRACTING = 66 "CtsIsolatedSplitAppExtractNativeLibsTrueJni.apk"; 67 private static final String APK_FEATURE_PROVIDER_A_WITH_EXTRACTING = 68 "CtsIsolatedSplitAppExtractNativeLibsTrueNumberProviderA.apk"; 69 private static final String APK_FEATURE_PROVIDER_B_WITH_EXTRACTING = 70 "CtsIsolatedSplitAppExtractNativeLibsTrueNumberProviderB.apk"; 71 private static final String APK_FEATURE_PROXY_WITH_EXTRACTING = 72 "CtsIsolatedSplitAppExtractNativeLibsTrueNumberProxy.apk"; 73 74 @Before setUp()75 public void setUp() throws Exception { 76 Utils.prepareSingleUser(getDevice()); 77 getDevice().uninstallPackage(PKG); 78 } 79 80 @After tearDown()81 public void tearDown() throws Exception { 82 getDevice().uninstallPackage(PKG); 83 } 84 85 @Test 86 @AppModeFull(reason = "'full' portion of the hostside test") testInstallBase_full()87 public void testInstallBase_full() throws Exception { 88 testInstallBase(false); 89 } 90 91 @Test 92 @AppModeInstant(reason = "'instant' portion of the hostside test") testInstallBase_instant()93 public void testInstallBase_instant() throws Exception { 94 testInstallBase(true); 95 } 96 testInstallBase(boolean instant)97 private void testInstallBase(boolean instant) throws Exception { 98 new InstallMultiple(instant).addFile(APK_BASE).run(); 99 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault"); 100 } 101 102 @Test 103 @AppModeFull(reason = "'full' portion of the hostside test") testInstallBaseAndConfigSplit_full()104 public void testInstallBaseAndConfigSplit_full() throws Exception { 105 testInstallBaseAndConfigSplit(false); 106 } 107 108 @Test 109 @AppModeInstant(reason = "'instant' portion of the hostside test") testInstallBaseAndConfigSplit_instant()110 public void testInstallBaseAndConfigSplit_instant() throws Exception { 111 testInstallBaseAndConfigSplit(true); 112 } 113 testInstallBaseAndConfigSplit(boolean instant)114 private void testInstallBaseAndConfigSplit(boolean instant) throws Exception { 115 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_BASE_pl).run(); 116 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadPolishLocale"); 117 } 118 119 @Test 120 @AppModeFull(reason = "'full' portion of the hostside test") testInstallMissingDependency_usesSplit_full()121 public void testInstallMissingDependency_usesSplit_full() throws Exception { 122 testInstallMissingDependency_usesSplit(false); 123 } 124 125 @Test 126 @AppModeInstant(reason = "'instant' portion of the hostside test") testInstallMissingDependency_usesSplit_instant()127 public void testInstallMissingDependency_usesSplit_instant() throws Exception { 128 testInstallMissingDependency_usesSplit(true); 129 } 130 testInstallMissingDependency_usesSplit(boolean instant)131 private void testInstallMissingDependency_usesSplit(boolean instant) throws Exception { 132 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_B).runExpectingFailure(); 133 } 134 135 @Test 136 @AppModeFull(reason = "'full' portion of the hostside test") testInstallMissingDependency_configForSplit_full()137 public void testInstallMissingDependency_configForSplit_full() throws Exception { 138 testInstallMissingDependency_configForSplit(false); 139 } 140 141 @Test 142 @AppModeInstant(reason = "'instant' portion of the hostside test") testInstallMissingDependency_configForSplit_instant()143 public void testInstallMissingDependency_configForSplit_instant() throws Exception { 144 testInstallMissingDependency_configForSplit(true); 145 } 146 testInstallMissingDependency_configForSplit(boolean instant)147 private void testInstallMissingDependency_configForSplit(boolean instant) throws Exception { 148 new InstallMultiple(instant).addFile(APK_BASE).addFile( 149 APK_FEATURE_A_pl).runExpectingFailure(); 150 } 151 152 @Test 153 @AppModeFull(reason = "b/109878606; instant applications can't send broadcasts to manifest " 154 + "receivers") testInstallOneFeatureSplit_full()155 public void testInstallOneFeatureSplit_full() throws Exception { 156 testInstallOneFeatureSplit(false); 157 } 158 testInstallOneFeatureSplit(boolean instant)159 private void testInstallOneFeatureSplit(boolean instant) throws Exception { 160 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_A).run(); 161 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault"); 162 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 163 "shouldLoadFeatureADefault"); 164 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 165 "shouldLoadFeatureAReceivers"); 166 } 167 168 @Test 169 @AppModeFull(reason = "'full' portion of the hostside test") testInstallOneFeatureSplitAndConfigSplits_full()170 public void testInstallOneFeatureSplitAndConfigSplits_full() throws Exception { 171 testInstallOneFeatureSplitAndConfigSplits(false); 172 } 173 174 @Test 175 @AppModeInstant(reason = "'instant' portion of the hostside test") testInstallOneFeatureSplitAndConfigSplits_instant()176 public void testInstallOneFeatureSplitAndConfigSplits_instant() throws Exception { 177 testInstallOneFeatureSplitAndConfigSplits(true); 178 } 179 testInstallOneFeatureSplitAndConfigSplits(boolean instant)180 private void testInstallOneFeatureSplitAndConfigSplits(boolean instant) throws Exception { 181 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_A).addFile(APK_BASE_pl) 182 .addFile(APK_FEATURE_A_pl).run(); 183 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadPolishLocale"); 184 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 185 "shouldLoadFeatureAPolishLocale"); 186 } 187 188 @Test 189 @AppModeFull(reason = "b/109878606; instant applications can't send broadcasts to manifest " 190 + "receivers") testInstallDependentFeatureSplits_full()191 public void testInstallDependentFeatureSplits_full() throws Exception { 192 testInstallDependentFeatureSplits(false); 193 } 194 testInstallDependentFeatureSplits(boolean instant)195 private void testInstallDependentFeatureSplits(boolean instant) throws Exception { 196 new InstallMultiple(instant) 197 .addFile(APK_BASE).addFile(APK_FEATURE_A).addFile(APK_FEATURE_B).run(); 198 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault"); 199 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 200 "shouldLoadFeatureADefault"); 201 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 202 "shouldLoadFeatureBDefault"); 203 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 204 "shouldLoadFeatureAAndBReceivers"); 205 } 206 207 @Test 208 @AppModeFull(reason = "'full' portion of the hostside test") testInstallDependentFeatureSplitsAndConfigSplits_full()209 public void testInstallDependentFeatureSplitsAndConfigSplits_full() throws Exception { 210 testInstallDependentFeatureSplitsAndConfigSplits(false); 211 } 212 213 @Test 214 @AppModeInstant(reason = "'instant' portion of the hostside test") testInstallDependentFeatureSplitsAndConfigSplits_instant()215 public void testInstallDependentFeatureSplitsAndConfigSplits_instant() throws Exception { 216 testInstallDependentFeatureSplitsAndConfigSplits(true); 217 } 218 testInstallDependentFeatureSplitsAndConfigSplits(boolean instant)219 private void testInstallDependentFeatureSplitsAndConfigSplits(boolean instant) 220 throws Exception { 221 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_A).addFile(APK_FEATURE_B) 222 .addFile(APK_BASE_pl).addFile(APK_FEATURE_A_pl).addFile(APK_FEATURE_B_pl).run(); 223 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadPolishLocale"); 224 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 225 "shouldLoadFeatureAPolishLocale"); 226 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 227 "shouldLoadFeatureBPolishLocale"); 228 } 229 230 @Test 231 @AppModeFull(reason = "b/109878606; instant applications can't send broadcasts to manifest " 232 + "receivers") testInstallAllFeatureSplits_full()233 public void testInstallAllFeatureSplits_full() throws Exception { 234 testInstallAllFeatureSplits(false); 235 } 236 testInstallAllFeatureSplits(boolean instant)237 private void testInstallAllFeatureSplits(boolean instant) throws Exception { 238 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_A).addFile(APK_FEATURE_B) 239 .addFile(APK_FEATURE_C).run(); 240 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault"); 241 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 242 "shouldLoadFeatureADefault"); 243 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 244 "shouldLoadFeatureBDefault"); 245 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 246 "shouldLoadFeatureCDefault"); 247 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 248 "shouldLoadFeatureAAndBAndCReceivers"); 249 } 250 251 @Test 252 @AppModeFull(reason = "'full' portion of the hostside test") testInstallAllFeatureSplitsAndConfigSplits_full()253 public void testInstallAllFeatureSplitsAndConfigSplits_full() throws Exception { 254 testInstallAllFeatureSplitsAndConfigSplits(false); 255 } 256 257 @Test 258 @AppModeInstant(reason = "'instant' portion of the hostside test") testInstallAllFeatureSplitsAndConfigSplits_instant()259 public void testInstallAllFeatureSplitsAndConfigSplits_instant() throws Exception { 260 testInstallAllFeatureSplitsAndConfigSplits(true); 261 } 262 testInstallAllFeatureSplitsAndConfigSplits(boolean instant)263 private void testInstallAllFeatureSplitsAndConfigSplits(boolean instant) throws Exception { 264 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_A).addFile(APK_FEATURE_B) 265 .addFile(APK_FEATURE_C).addFile(APK_BASE_pl).addFile(APK_FEATURE_A_pl) 266 .addFile(APK_FEATURE_C_pl).run(); 267 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault"); 268 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 269 "shouldLoadFeatureADefault"); 270 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 271 "shouldLoadFeatureBDefault"); 272 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 273 "shouldLoadFeatureCDefault"); 274 } 275 276 @Test 277 @AppModeFull(reason = "'full' portion of the hostside test") testSplitsInheritInstall_full()278 public void testSplitsInheritInstall_full() throws Exception { 279 testSplitsInheritInstall(false); 280 } 281 282 @Test 283 @AppModeInstant(reason = "'instant' portion of the hostside test") testSplitsInheritInstall_instant()284 public void testSplitsInheritInstall_instant() throws Exception { 285 testSplitsInheritInstall(true); 286 } 287 testSplitsInheritInstall(boolean instant)288 private void testSplitsInheritInstall(boolean instant) throws Exception { 289 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_A).addFile(APK_FEATURE_B) 290 .addFile(APK_FEATURE_C).run(); 291 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 292 "shouldLoadFeatureADefault"); 293 294 new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_FEATURE_A_DiffRev).run(); 295 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 296 "shouldLoadFeatureADiffRevision"); 297 } 298 299 @Test 300 @AppModeFull(reason = "'full' portion of the hostside test") testSplitsRemoved_full()301 public void testSplitsRemoved_full() throws Exception { 302 testSplitsRemoved(false); 303 } 304 305 @Test 306 @AppModeInstant(reason = "'instant' portion of the hostside test") testSplitsRemoved_instant()307 public void testSplitsRemoved_instant() throws Exception { 308 testSplitsRemoved(true); 309 } 310 testSplitsRemoved(boolean instant)311 private void testSplitsRemoved(boolean instant) throws Exception { 312 new InstallMultiple(instant).addFile(APK_BASE).addFile(APK_FEATURE_A).addFile(APK_FEATURE_B) 313 .addFile(APK_FEATURE_C).run(); 314 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 315 "shouldLoadFeatureCDefault"); 316 317 new InstallMultiple(instant).inheritFrom(PKG).removeSplit("feature_c").run(); 318 Utils.runDeviceTestsAsCurrentUser(getDevice(), PKG, TEST_CLASS, 319 "shouldNotFoundFeatureC"); 320 } 321 configureInstallMultiple(boolean instant, String...apks)322 private InstallMultiple configureInstallMultiple(boolean instant, String...apks) 323 throws FileNotFoundException { 324 InstallMultiple installMultiple = new InstallMultiple(instant); 325 for (String apk : apks) { 326 installMultiple.addFile(apk); 327 } 328 return installMultiple; 329 } 330 331 @Test 332 @AppModeFull(reason = "'full' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseFalse_splitTrue_full()333 public void testNativeInstallable_extractNativeLibs_baseFalse_splitTrue_full() 334 throws Exception { 335 configureInstallMultiple(false, APK_BASE_WITHOUT_EXTRACTING, 336 APK_FEATURE_JNI_WITH_EXTRACTING, APK_FEATURE_PROXY_WITH_EXTRACTING, 337 APK_FEATURE_PROVIDER_A_WITH_EXTRACTING).runExpectingFailure( 338 "INSTALL_FAILED_INVALID_APK"); 339 } 340 341 @Test 342 @AppModeInstant(reason = "'instant' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseFalse_splitTrue_instant()343 public void testNativeInstallable_extractNativeLibs_baseFalse_splitTrue_instant() 344 throws Exception { 345 configureInstallMultiple(true, APK_BASE_WITHOUT_EXTRACTING, APK_FEATURE_JNI_WITH_EXTRACTING, 346 APK_FEATURE_PROXY_WITH_EXTRACTING, 347 APK_FEATURE_PROVIDER_A_WITH_EXTRACTING).runExpectingFailure( 348 "INSTALL_FAILED_INVALID_APK"); 349 } 350 351 @Test 352 @AppModeFull(reason = "'full' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseFalse_splitFalse_full()353 public void testNativeInstallable_extractNativeLibs_baseFalse_splitFalse_full() 354 throws Exception { 355 configureInstallMultiple(false, APK_BASE_WITHOUT_EXTRACTING, 356 APK_FEATURE_JNI_WITHOUT_EXTRACTING, APK_FEATURE_PROXY_WITHOUT_EXTRACTING, 357 APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING).run(); 358 } 359 360 @Test 361 @AppModeInstant(reason = "'instant' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseFalse_splitFalse_instant()362 public void testNativeInstallable_extractNativeLibs_baseFalse_splitFalse_instant() 363 throws Exception { 364 configureInstallMultiple(true, APK_BASE_WITHOUT_EXTRACTING, 365 APK_FEATURE_JNI_WITHOUT_EXTRACTING, APK_FEATURE_PROXY_WITHOUT_EXTRACTING, 366 APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING).run(); 367 } 368 369 @Test 370 @AppModeFull(reason = "'full' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseTrue_splitTrue_full()371 public void testNativeInstallable_extractNativeLibs_baseTrue_splitTrue_full() 372 throws Exception { 373 configureInstallMultiple(false, APK_BASE_WITH_EXTRACTING, 374 APK_FEATURE_JNI_WITH_EXTRACTING, 375 APK_FEATURE_PROXY_WITH_EXTRACTING, APK_FEATURE_PROVIDER_A_WITH_EXTRACTING).run(); 376 } 377 378 @Test 379 @AppModeInstant(reason = "'instant' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseTrue_splitTrue_instant()380 public void testNativeInstallable_extractNativeLibs_baseTrue_splitTrue_instant() 381 throws Exception { 382 configureInstallMultiple(true, APK_BASE_WITH_EXTRACTING, APK_FEATURE_JNI_WITH_EXTRACTING, 383 APK_FEATURE_PROXY_WITH_EXTRACTING, APK_FEATURE_PROVIDER_A_WITH_EXTRACTING).run(); 384 } 385 386 @Test 387 @AppModeFull(reason = "'full' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseTrue_splitFalse_full()388 public void testNativeInstallable_extractNativeLibs_baseTrue_splitFalse_full() 389 throws Exception { 390 configureInstallMultiple(false, APK_BASE_WITH_EXTRACTING, 391 APK_FEATURE_JNI_WITHOUT_EXTRACTING, APK_FEATURE_PROXY_WITHOUT_EXTRACTING, 392 APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING).run(); 393 } 394 395 @Test 396 @AppModeInstant(reason = "'instant' portion of the hostside test") testNativeInstallable_extractNativeLibs_baseTrue_splitFalse_instant()397 public void testNativeInstallable_extractNativeLibs_baseTrue_splitFalse_instant() 398 throws Exception { 399 configureInstallMultiple(true, APK_BASE_WITH_EXTRACTING, APK_FEATURE_JNI_WITHOUT_EXTRACTING, 400 APK_FEATURE_PROXY_WITHOUT_EXTRACTING, 401 APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING).run(); 402 } 403 404 @Test 405 @AppModeFull(reason = "'full' portion of the hostside test") testAccessNativeSymbol_bothBaseAndSplitExtracting_full()406 public void testAccessNativeSymbol_bothBaseAndSplitExtracting_full() throws Exception { 407 testAccessNativeSymbol(false, true, APK_BASE_WITH_EXTRACTING, 408 APK_FEATURE_JNI_WITH_EXTRACTING, APK_FEATURE_PROVIDER_A_WITH_EXTRACTING, 409 APK_FEATURE_PROVIDER_B_WITH_EXTRACTING, APK_FEATURE_PROXY_WITH_EXTRACTING); 410 } 411 412 @Test 413 @AppModeInstant(reason = "'instant' portion of the hostside test") testAccessNativeSymbol_bothBaseAndSplitExtracting_instant()414 public void testAccessNativeSymbol_bothBaseAndSplitExtracting_instant() throws Exception { 415 testAccessNativeSymbol(true, true, APK_BASE_WITH_EXTRACTING, 416 APK_FEATURE_JNI_WITH_EXTRACTING, APK_FEATURE_PROVIDER_A_WITH_EXTRACTING, 417 APK_FEATURE_PROVIDER_B_WITH_EXTRACTING, APK_FEATURE_PROXY_WITH_EXTRACTING); 418 } 419 420 @Test 421 @AppModeFull(reason = "'full' portion of the hostside test") testAccessNativeSymbol_onlyBaseExtracting_full()422 public void testAccessNativeSymbol_onlyBaseExtracting_full() throws Exception { 423 testAccessNativeSymbol(false, true, APK_BASE_WITH_EXTRACTING, 424 APK_FEATURE_JNI_WITHOUT_EXTRACTING, APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING, 425 APK_FEATURE_PROVIDER_B_WITHOUT_EXTRACTING, APK_FEATURE_PROXY_WITHOUT_EXTRACTING); 426 } 427 428 @Test 429 @AppModeInstant(reason = "'instant' portion of the hostside test") testAccessNativeSymbol_onlyBaseExtracting_instant()430 public void testAccessNativeSymbol_onlyBaseExtracting_instant() throws Exception { 431 testAccessNativeSymbol(true, true, APK_BASE_WITH_EXTRACTING, 432 APK_FEATURE_JNI_WITHOUT_EXTRACTING, APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING, 433 APK_FEATURE_PROVIDER_B_WITHOUT_EXTRACTING, APK_FEATURE_PROXY_WITHOUT_EXTRACTING); 434 } 435 436 @Test 437 @AppModeFull(reason = "'full' portion of the hostside test") testAccessNativeSymbol_neitherBaseNorSplitExtracting_full()438 public void testAccessNativeSymbol_neitherBaseNorSplitExtracting_full() throws Exception { 439 testAccessNativeSymbol(false, false, APK_BASE_WITHOUT_EXTRACTING, 440 APK_FEATURE_JNI_WITHOUT_EXTRACTING, APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING, 441 APK_FEATURE_PROVIDER_B_WITHOUT_EXTRACTING, APK_FEATURE_PROXY_WITHOUT_EXTRACTING); 442 } 443 444 @Test 445 @AppModeInstant(reason = "'instant' portion of the hostside test") testAccessNativeSymbol_neitherBaseNorSplitExtracting_instant()446 public void testAccessNativeSymbol_neitherBaseNorSplitExtracting_instant() throws Exception { 447 testAccessNativeSymbol(true, false, APK_BASE_WITHOUT_EXTRACTING, 448 APK_FEATURE_JNI_WITHOUT_EXTRACTING, APK_FEATURE_PROVIDER_A_WITHOUT_EXTRACTING, 449 APK_FEATURE_PROVIDER_B_WITHOUT_EXTRACTING, APK_FEATURE_PROXY_WITHOUT_EXTRACTING); 450 } 451 testAccessNativeSymbol(boolean instant, boolean expectedLoadedLibrary, String baseApk, String jniApk, String providerAApk, String providerBApk, String providerProxyApk)452 private void testAccessNativeSymbol(boolean instant, boolean expectedLoadedLibrary, 453 String baseApk, String jniApk, String providerAApk, String providerBApk, 454 String providerProxyApk) throws Exception { 455 configureInstallMultiple(instant, baseApk, jniApk, providerAApk, providerBApk, 456 providerProxyApk).run(); 457 if (expectedLoadedLibrary) { 458 runDeviceTests(PKG, TEST_CLASS, "testNative_getNumberAViaProxy_shouldBeSeven"); 459 runDeviceTests(PKG, TEST_CLASS, "testNative_getNumberBDirectly_shouldBeEleven"); 460 runDeviceTests(PKG, TEST_CLASS, "testNative_getNumberADirectly_shouldBeSeven"); 461 runDeviceTests(PKG, TEST_CLASS, "testNative_getNumberBViaProxy_shouldBeEleven"); 462 } else { 463 runDeviceTests(PKG, TEST_CLASS, "testNative_cannotLoadSharedLibrary"); 464 runDeviceTests( 465 PKG, 466 TEST_CLASS, 467 "testNativeSplit_withoutExtractLibs_nativeLibraryCannotBeLoaded"); 468 } 469 } 470 } 471