• 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 android.appsecurity.cts;
18 
19 import static org.junit.Assert.assertNotNull;
20 
21 import android.platform.test.annotations.AppModeFull;
22 import android.platform.test.annotations.AppModeInstant;
23 import android.platform.test.annotations.PlatinumTest;
24 import android.platform.test.annotations.Presubmit;
25 
26 import com.android.compatibility.common.util.CpuFeatures;
27 import com.android.tradefed.device.DeviceNotAvailableException;
28 import com.android.tradefed.testtype.Abi;
29 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
30 import com.android.tradefed.testtype.IAbi;
31 import com.android.tradefed.util.AbiUtils;
32 
33 import org.junit.After;
34 import org.junit.Assume;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 
39 import java.io.FileNotFoundException;
40 import java.util.HashMap;
41 import java.util.Set;
42 
43 /**
44  * Tests that verify installing of various split APKs from host side.
45  */
46 @Presubmit
47 @PlatinumTest(focusArea = "pm")
48 @RunWith(DeviceJUnit4ClassRunner.class)
49 public class SplitTests extends BaseAppSecurityTest {
50     static final String PKG_NO_RESTART = "com.android.cts.norestart";
51     static final String APK_NO_RESTART_BASE = "CtsNoRestartBase.apk";
52     static final String APK_NO_RESTART_FEATURE = "CtsNoRestartFeature.apk";
53 
54     static final String APK_NEED_SPLIT_BASE = "CtsNeedSplitApp.apk";
55     static final String APK_NEED_SPLIT_FEATURE_WARM = "CtsNeedSplitFeatureWarm.apk";
56     static final String APK_NEED_SPLIT_CONFIG = "CtsNeedSplitApp_xxhdpi-v4.apk";
57 
58     static final String APK_REQUIRED_SPLIT_TYPE_BASE = "CtsRequiredSplitTypeSplitApp.apk";
59     static final String APK_REQUIRED_SPLIT_TYPE_BASE_UPDATED =
60             "CtsRequiredSplitTypeSplitAppUpdated.apk";
61     static final String APK_REQUIRED_SPLIT_TYPE_DENSITY = "CtsSplitAppTypeDensity.apk";
62     static final String APK_REQUIRED_SPLIT_TYPE_LOCALE = "CtsSplitAppTypeLocale.apk";
63     static final String APK_REQUIRED_SPLIT_TYPE_FOO = "CtsSplitAppTypeFoo.apk";
64     static final String APK_REQUIRED_SPLIT_TYPE_MULTIPLE = "CtsSplitAppTypeMultiple.apk";
65     static final String APK_REQUIRED_SPLIT_TYPE_FEATURE = "CtsSplitAppTypeFeature.apk";
66     static final String APK_REQUIRED_SPLIT_TYPE_FEATURE_DATA = "CtsSplitAppTypeFeatureData.apk";
67     static final String APK_REQUIRED_SPLIT_TYPE_FEATURE_FOO = "CtsSplitAppTypeFeatureFoo.apk";
68     static final String APK_INVALID_REQUIRED_SPLIT_TYPE_BASE =
69             "CtsInvalidRequiredSplitTypeSplitApp.apk";
70 
71     static final String PKG = "com.android.cts.splitapp";
72     static final String CLASS = PKG + ".SplitAppTest";
73 
74     static final String APK = "CtsSplitApp.apk";
75 
76     static final String APK_mdpi = "CtsSplitApp_mdpi-v4.apk";
77     static final String APK_hdpi = "CtsSplitApp_hdpi-v4.apk";
78     static final String APK_xhdpi = "CtsSplitApp_xhdpi-v4.apk";
79     static final String APK_xxhdpi = "CtsSplitApp_xxhdpi-v4.apk";
80 
81     private static final String APK_v7 = "CtsSplitApp_v7.apk";
82     private static final String APK_v23 = "CtsSplitApp_v23.apk";
83     private static final String APK_fr = "CtsSplitApp_fr.apk";
84     private static final String APK_de = "CtsSplitApp_de.apk";
85 
86     private static final String APK_x86 = "CtsSplitApp_x86.apk";
87     private static final String APK_x86_64 = "CtsSplitApp_x86_64.apk";
88     private static final String APK_armeabi_v7a = "CtsSplitApp_armeabi-v7a.apk";
89     private static final String APK_armeabi = "CtsSplitApp_armeabi.apk";
90     private static final String APK_arm64_v8a = "CtsSplitApp_arm64-v8a.apk";
91     private static final String APK_mips64 = "CtsSplitApp_mips64.apk";
92     private static final String APK_mips = "CtsSplitApp_mips.apk";
93 
94     private static final String APK_NUMBER_PROVIDER_A = "CtsSplitApp_number_provider_a.apk";
95     private static final String APK_NUMBER_PROVIDER_B = "CtsSplitApp_number_provider_b.apk";
96     private static final String APK_NUMBER_PROXY = "CtsSplitApp_number_proxy.apk";
97 
98     private static final String APK_DIFF_REVISION = "CtsSplitAppDiffRevision.apk";
99     private static final String APK_DIFF_REVISION_v7 = "CtsSplitAppDiffRevision_v7.apk";
100 
101     private static final String APK_DIFF_VERSION = "CtsSplitAppDiffVersion.apk";
102     private static final String APK_DIFF_VERSION_v7 = "CtsSplitAppDiffVersion_v7.apk";
103 
104     private static final String APK_DIFF_CERT = "CtsSplitAppDiffCert.apk";
105     private static final String APK_DIFF_CERT_v7 = "CtsSplitAppDiffCert_v7.apk";
106 
107     private static final String APK_FEATURE_WARM = "CtsSplitAppFeatureWarm.apk";
108     private static final String APK_FEATURE_WARM_v7 = "CtsSplitAppFeatureWarm_v7.apk";
109     private static final String APK_FEATURE_WARM_v23 = "CtsSplitAppFeatureWarm_v23.apk";
110 
111     private static final String APK_FEATURE_ROSE = "CtsSplitAppFeatureRose.apk";
112     private static final String APK_FEATURE_ROSE_v23 = "CtsSplitAppFeatureRose_v23.apk";
113 
114     private static final String APK_REVISION_A = "CtsSplitAppRevisionA.apk";
115     private static final String APK_FEATURE_WARM_REVISION_A = "CtsSplitAppFeatureWarmRevisionA.apk";
116 
117     // Apk includes a provider and service declared in other split apk. And only could be tested in
118     // instant app mode.
119     static final String APK_INSTANT = "CtsSplitInstantApp.apk";
120 
121     static final HashMap<String, String> ABI_TO_APK = new HashMap<>();
122     static final HashMap<String, String> ABI_TO_REVISION_APK = new HashMap<>();
123 
124     static {
125         ABI_TO_APK.put("x86", APK_x86);
126         ABI_TO_APK.put("x86_64", APK_x86_64);
127         ABI_TO_APK.put("armeabi-v7a", APK_armeabi_v7a);
128         ABI_TO_APK.put("armeabi", APK_armeabi);
129         ABI_TO_APK.put("arm64-v8a", APK_arm64_v8a);
130         ABI_TO_APK.put("mips64", APK_mips64);
131         ABI_TO_APK.put("mips", APK_mips);
132 
133         ABI_TO_REVISION_APK.put("x86", "CtsSplitApp_revision12_x86.apk");
134         ABI_TO_REVISION_APK.put("x86_64", "CtsSplitApp_revision12_x86_64.apk");
135         ABI_TO_REVISION_APK.put("armeabi-v7a", "CtsSplitApp_revision12_armeabi-v7a.apk");
136         ABI_TO_REVISION_APK.put("armeabi", "CtsSplitApp_revision12_armeabi.apk");
137         ABI_TO_REVISION_APK.put("arm64-v8a", "CtsSplitApp_revision12_arm64-v8a.apk");
138         ABI_TO_REVISION_APK.put("mips64", "CtsSplitApp_revision12_mips64.apk");
139         ABI_TO_REVISION_APK.put("mips", "CtsSplitApp_revision12_mips.apk");
140     }
141 
142     @Before
setUp()143     public void setUp() throws Exception {
144         Utils.prepareSingleUser(getDevice());
145         getDevice().uninstallPackage(PKG);
146         getDevice().uninstallPackage(PKG_NO_RESTART);
147     }
148 
149     @After
tearDown()150     public void tearDown() throws Exception {
151         getDevice().uninstallPackage(PKG);
152         getDevice().uninstallPackage(PKG_NO_RESTART);
153     }
154 
155     @Test
156     @AppModeFull(reason = "'full' portion of the hostside test")
testSingleBase_full()157     public void testSingleBase_full() throws Exception {
158         testSingleBase(false);
159     }
160     @Test
161     @AppModeInstant(reason = "'instant' portion of the hostside test")
testSingleBase_instant()162     public void testSingleBase_instant() throws Exception {
163         testSingleBase(true);
164     }
testSingleBase(boolean instant)165     private void testSingleBase(boolean instant) throws Exception {
166         new InstallMultiple(instant).addFile(APK).run();
167         runDeviceTests(PKG, CLASS, "testSingleBase");
168     }
169 
170     @Test
171     @AppModeFull(reason = "'full' portion of the hostside test")
testDensitySingle_full()172     public void testDensitySingle_full() throws Exception {
173         testDensitySingle(false);
174     }
175     @Test
176     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDensitySingle_instant()177     public void testDensitySingle_instant() throws Exception {
178         testDensitySingle(true);
179     }
testDensitySingle(boolean instant)180     private void testDensitySingle(boolean instant) throws Exception {
181         new InstallMultiple(instant).addFile(APK).addFile(APK_mdpi).run();
182         runDeviceTests(PKG, CLASS, "testDensitySingle");
183     }
184 
185     @Test
186     @AppModeFull(reason = "'full' portion of the hostside test")
testDensityAll_full()187     public void testDensityAll_full() throws Exception {
188         testDensityAll(false);
189     }
190     @Test
191     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDensityAll_instant()192     public void testDensityAll_instant() throws Exception {
193         testDensityAll(true);
194     }
testDensityAll(boolean instant)195     private void testDensityAll(boolean instant) throws Exception {
196         new InstallMultiple(instant).addFile(APK).addFile(APK_mdpi).addFile(APK_hdpi).addFile(APK_xhdpi)
197                 .addFile(APK_xxhdpi).run();
198         runDeviceTests(PKG, CLASS, "testDensityAll");
199     }
200 
201     /**
202      * Install first with low-resolution resources, then add a split that offers
203      * higher-resolution resources.
204      */
205     @Test
206     @AppModeFull(reason = "'full' portion of the hostside test")
testDensityBest_full()207     public void testDensityBest_full() throws Exception {
208         testDensityBest(false);
209     }
210     @Test
211     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDensityBest_instant()212     public void testDensityBest_instant() throws Exception {
213         testDensityBest(true);
214     }
testDensityBest(boolean instant)215     private void testDensityBest(boolean instant) throws Exception {
216         new InstallMultiple(instant).addFile(APK).addFile(APK_mdpi).run();
217         runDeviceTests(PKG, CLASS, "testDensityBest1");
218 
219         // Now splice in an additional split which offers better resources
220         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_xxhdpi).run();
221         runDeviceTests(PKG, CLASS, "testDensityBest2");
222     }
223 
224     /**
225      * Verify that an API-based split can change enabled/disabled state of
226      * manifest elements.
227      */
228     @Test
229     @AppModeFull(reason = "'full' portion of the hostside test")
testApi_full()230     public void testApi_full() throws Exception {
231         testApi(false);
232     }
233     @Test
234     @AppModeInstant(reason = "'instant' portion of the hostside test")
testApi_instant()235     public void testApi_instant() throws Exception {
236         testApi(true);
237     }
testApi(boolean instant)238     private void testApi(boolean instant) throws Exception {
239         new InstallMultiple(instant).addFile(APK).addFile(APK_v7).run();
240         runDeviceTests(PKG, CLASS, "testApi");
241     }
242 
243     @Test
244     @AppModeFull(reason = "'full' portion of the hostside test")
testLocale_full()245     public void testLocale_full() throws Exception {
246         testLocale(false);
247     }
248     @Test
249     @AppModeInstant(reason = "'instant' portion of the hostside test")
testLocale_instant()250     public void testLocale_instant() throws Exception {
251         testLocale(true);
252     }
testLocale(boolean instant)253     private void testLocale(boolean instant) throws Exception {
254         new InstallMultiple(instant).addFile(APK).addFile(APK_de).addFile(APK_fr).run();
255         runDeviceTests(PKG, CLASS, "testLocale");
256     }
257 
258     /**
259      * Install test app with <em>single</em> split that exactly matches the
260      * currently active ABI. This also explicitly forces ABI when installing.
261      */
262     @Test
263     @AppModeFull(reason = "'full' portion of the hostside test")
testNativeSingle_full()264     public void testNativeSingle_full() throws Exception {
265         testNativeSingle(false, false);
266     }
267     @Test
268     @AppModeInstant(reason = "'instant' portion of the hostside test")
testNativeSingle_instant()269     public void testNativeSingle_instant() throws Exception {
270         testNativeSingle(true, false);
271     }
272 
getInstallMultiple(boolean instant, boolean useNaturalAbi)273     private InstallMultiple getInstallMultiple(boolean instant, boolean useNaturalAbi) {
274         final InstallMultiple installMultiple = new InstallMultiple(instant);
275         if (useNaturalAbi) {
276             return installMultiple.useNaturalAbi();
277         }
278         return installMultiple;
279     }
280 
testNativeSingle(boolean instant, boolean useNaturalAbi)281     private void testNativeSingle(boolean instant, boolean useNaturalAbi) throws Exception {
282         final String abi = getAbi().getName();
283         final String apk = ABI_TO_APK.get(abi);
284         final String revisionApk = ABI_TO_REVISION_APK.get(abi);
285         assertNotNull("Failed to find APK for ABI " + abi, apk);
286 
287         getInstallMultiple(instant, useNaturalAbi).addFile(APK).addFile(apk).run();
288         runDeviceTests(PKG, CLASS, "testNative");
289         runDeviceTests(PKG, CLASS, "testNativeRevision_sub_shouldImplementBadly");
290         getInstallMultiple(instant, useNaturalAbi).inheritFrom(PKG).addFile(revisionApk).run();
291         runDeviceTests(PKG, CLASS, "testNativeRevision_sub_shouldImplementWell");
292 
293         getInstallMultiple(instant, useNaturalAbi).inheritFrom(PKG)
294                 .addFile(APK_NUMBER_PROVIDER_A)
295                 .addFile(APK_NUMBER_PROVIDER_B)
296                 .addFile(APK_NUMBER_PROXY).run();
297         runDeviceTests(PKG, CLASS, "testNative_getNumberADirectly_shouldBeSeven");
298         runDeviceTests(PKG, CLASS, "testNative_getNumberAViaProxy_shouldBeSeven");
299         runDeviceTests(PKG, CLASS, "testNative_getNumberBDirectly_shouldBeEleven");
300         runDeviceTests(PKG, CLASS, "testNative_getNumberBViaProxy_shouldBeEleven");
301     }
302 
303     @Test
304     @AppModeFull(reason = "'full' portion of the hostside test")
testNativeSplitForEachSupportedAbi_full()305     public void testNativeSplitForEachSupportedAbi_full() throws Exception {
306         testNativeForEachSupportedAbi(false);
307     }
308 
309     @Test
310     @AppModeInstant(reason = "'instant' portion of the hostside test")
testNativeSplitForEachSupportedAbi_instant()311     public void testNativeSplitForEachSupportedAbi_instant() throws Exception {
312         testNativeForEachSupportedAbi(true);
313     }
314 
315 
specifyAbiToTest(boolean instant, String abiListProperty, String testMethodName)316     private void specifyAbiToTest(boolean instant, String abiListProperty, String testMethodName)
317             throws FileNotFoundException, DeviceNotAvailableException {
318         final String propertyAbiListValue = getDevice().getProperty(abiListProperty);
319         final Set<String> supportedAbiSet =
320                 AbiUtils.parseAbiListFromProperty(propertyAbiListValue);
321         for (String abi : supportedAbiSet) {
322             String apk = ABI_TO_APK.get(abi);
323             new InstallMultiple(instant, true).inheritFrom(PKG).addFile(apk).run();
324 
325             // Without specifying abi for executing "adb shell am",
326             // a UnsatisfiedLinkError will happen.
327             IAbi iAbi = new Abi(abi, AbiUtils.getBitness(abi));
328             setAbi(iAbi);
329             runDeviceTests(PKG, CLASS, testMethodName);
330         }
331     }
332 
testNativeForEachSupportedAbi(boolean instant)333     private void testNativeForEachSupportedAbi(boolean instant)
334             throws DeviceNotAvailableException, FileNotFoundException {
335         new InstallMultiple(instant, true).addFile(APK).run();
336 
337         // make sure this device can run both 32 bit and 64 bit
338         specifyAbiToTest(instant, "ro.product.cpu.abilist64", "testNative64Bit");
339         specifyAbiToTest(instant, "ro.product.cpu.abilist32", "testNative32Bit");
340     }
341 
342     /**
343      * Install test app with <em>single</em> split that exactly matches the
344      * currently active ABI. This variant <em>does not</em> force the ABI when
345      * installing, instead exercising the system's ability to choose the ABI
346      * through inspection of the installed app.
347      */
348     @Test
349     @AppModeFull(reason = "'full' portion of the hostside test")
testNativeSingleNatural_full()350     public void testNativeSingleNatural_full() throws Exception {
351         testNativeSingle(false, true);
352     }
353     @Test
354     @AppModeInstant(reason = "'instant' portion of the hostside test")
testNativeSingleNatural_instant()355     public void testNativeSingleNatural_instant() throws Exception {
356         testNativeSingle(true, true);
357     }
358 
assumeNativeAbi()359     private void assumeNativeAbi() throws Exception {
360         // Skip this test if not running on the device's native abi.
361         Assume.assumeTrue(CpuFeatures.isNativeAbi(getDevice(), getAbi().getName()));
362     }
363     /**
364      * Install test app with <em>all</em> possible ABI splits. This also
365      * explicitly forces ABI when installing.
366      */
367     @Test
368     @AppModeFull(reason = "'full' portion of the hostside test")
testNativeAll_full()369     public void testNativeAll_full() throws Exception {
370         assumeNativeAbi();
371         testNativeAll(false, false);
372     }
373     @Test
374     @AppModeInstant(reason = "'instant' portion of the hostside test")
testNativeAll_instant()375     public void testNativeAll_instant() throws Exception {
376         testNativeAll(true, false);
377     }
testNativeAll(boolean instant, boolean useNaturalAbi)378     private void testNativeAll(boolean instant, boolean useNaturalAbi) throws Exception {
379         final InstallMultiple inst = getInstallMultiple(instant, useNaturalAbi).addFile(APK);
380         for (String apk : ABI_TO_APK.values()) {
381             inst.addFile(apk);
382         }
383         inst.run();
384         runDeviceTests(PKG, CLASS, "testNative");
385         runDeviceTests(PKG, CLASS, "testNativeRevision_sub_shouldImplementBadly");
386 
387         final InstallMultiple instInheritFrom =
388                 getInstallMultiple(instant, useNaturalAbi).inheritFrom(PKG);
389         for (String apk : ABI_TO_REVISION_APK.values()) {
390             instInheritFrom.addFile(apk);
391         }
392         instInheritFrom.addFile(APK_NUMBER_PROVIDER_A);
393         instInheritFrom.addFile(APK_NUMBER_PROVIDER_B);
394         instInheritFrom.addFile(APK_NUMBER_PROXY);
395         instInheritFrom.run();
396         runDeviceTests(PKG, CLASS, "testNativeRevision_sub_shouldImplementWell");
397 
398         runDeviceTests(PKG, CLASS, "testNative_getNumberADirectly_shouldBeSeven");
399         runDeviceTests(PKG, CLASS, "testNative_getNumberAViaProxy_shouldBeSeven");
400         runDeviceTests(PKG, CLASS, "testNative_getNumberBDirectly_shouldBeEleven");
401         runDeviceTests(PKG, CLASS, "testNative_getNumberBViaProxy_shouldBeEleven");
402     }
403 
404     /**
405      * Install test app with <em>all</em> possible ABI splits. This variant
406      * <em>does not</em> force the ABI when installing, instead exercising the
407      * system's ability to choose the ABI through inspection of the installed
408      * app.
409      */
410     @Test
411     @AppModeFull(reason = "'full' portion of the hostside test")
testNativeAllNatural_full()412     public void testNativeAllNatural_full() throws Exception {
413         assumeNativeAbi();
414         testNativeAll(false, true);
415     }
416     @Test
417     @AppModeInstant(reason = "'instant' portion of the hostside test")
testNativeAllNatural_instant()418     public void testNativeAllNatural_instant() throws Exception {
419         testNativeAll(true, true);
420     }
421 
422     @Test
423     @AppModeFull(reason = "'full' portion of the hostside test")
testDuplicateBase_full()424     public void testDuplicateBase_full() throws Exception {
425         testDuplicateBase(false);
426     }
427     @Test
428     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDuplicateBase_instant()429     public void testDuplicateBase_instant() throws Exception {
430         testDuplicateBase(true);
431     }
testDuplicateBase(boolean instant)432     private void testDuplicateBase(boolean instant) throws Exception {
433         new InstallMultiple(instant).addFile(APK).addFile(APK).runExpectingFailure();
434     }
435 
436     @Test
437     @AppModeFull(reason = "'full' portion of the hostside test")
testDuplicateSplit_full()438     public void testDuplicateSplit_full() throws Exception {
439         testDuplicateSplit(false);
440     }
441     @Test
442     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDuplicateSplit_instant()443     public void testDuplicateSplit_instant() throws Exception {
444         testDuplicateSplit(true);
445     }
testDuplicateSplit(boolean instant)446     private void testDuplicateSplit(boolean instant) throws Exception {
447         new InstallMultiple(instant).addFile(APK).addFile(APK_v7).addFile(APK_v7).runExpectingFailure();
448     }
449 
450     @Test
451     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffCert_full()452     public void testDiffCert_full() throws Exception {
453         testDiffCert(false);
454     }
455     @Test
456     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffCert_instant()457     public void testDiffCert_instant() throws Exception {
458         testDiffCert(true);
459     }
testDiffCert(boolean instant)460     private void testDiffCert(boolean instant) throws Exception {
461         new InstallMultiple(instant).addFile(APK).addFile(APK_DIFF_CERT_v7).runExpectingFailure();
462     }
463 
464     @Test
465     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffCertInherit_full()466     public void testDiffCertInherit_full() throws Exception {
467         testDiffCertInherit(false);
468     }
469     @Test
470     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffCertInherit_instant()471     public void testDiffCertInherit_instant() throws Exception {
472         testDiffCertInherit(true);
473     }
testDiffCertInherit(boolean instant)474     private void testDiffCertInherit(boolean instant) throws Exception {
475         new InstallMultiple(instant).addFile(APK).run();
476         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_DIFF_CERT_v7).runExpectingFailure();
477     }
478 
479     @Test
480     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffVersion_full()481     public void testDiffVersion_full() throws Exception {
482         testDiffVersion(false);
483     }
484     @Test
485     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffVersion_instant()486     public void testDiffVersion_instant() throws Exception {
487         testDiffVersion(true);
488     }
testDiffVersion(boolean instant)489     private void testDiffVersion(boolean instant) throws Exception {
490         new InstallMultiple(instant).addFile(APK).addFile(APK_DIFF_VERSION_v7).runExpectingFailure();
491     }
492 
493     @Test
494     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffVersionInherit_full()495     public void testDiffVersionInherit_full() throws Exception {
496         testDiffVersionInherit(false);
497     }
498     @Test
499     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffVersionInherit_instant()500     public void testDiffVersionInherit_instant() throws Exception {
501         testDiffVersionInherit(true);
502     }
testDiffVersionInherit(boolean instant)503     private void testDiffVersionInherit(boolean instant) throws Exception {
504         new InstallMultiple(instant).addFile(APK).run();
505         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_DIFF_VERSION_v7).runExpectingFailure();
506     }
507 
508     @Test
509     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffRevision_full()510     public void testDiffRevision_full() throws Exception {
511         testDiffRevision(false);
512     }
513     @Test
514     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffRevision_instant()515     public void testDiffRevision_instant() throws Exception {
516         testDiffRevision(true);
517     }
testDiffRevision(boolean instant)518     private void testDiffRevision(boolean instant) throws Exception {
519         new InstallMultiple(instant).addFile(APK).addFile(APK_DIFF_REVISION_v7).run();
520         runDeviceTests(PKG, CLASS, "testRevision0_12");
521     }
522 
523     @Test
524     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffRevisionInheritBase_full()525     public void testDiffRevisionInheritBase_full() throws Exception {
526         testDiffRevisionInheritBase(false);
527     }
528     @Test
529     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffRevisionInheritBase_instant()530     public void testDiffRevisionInheritBase_instant() throws Exception {
531         testDiffRevisionInheritBase(true);
532     }
testDiffRevisionInheritBase(boolean instant)533     private void testDiffRevisionInheritBase(boolean instant) throws Exception {
534         new InstallMultiple(instant).addFile(APK).addFile(APK_v7).run();
535         runDeviceTests(PKG, CLASS, "testRevision0_0");
536         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_DIFF_REVISION_v7).run();
537         runDeviceTests(PKG, CLASS, "testRevision0_12");
538     }
539 
540     @Test
541     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffRevisionInheritSplit_full()542     public void testDiffRevisionInheritSplit_full() throws Exception {
543         testDiffRevisionInheritSplit(false);
544     }
545     @Test
546     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffRevisionInheritSplit_instant()547     public void testDiffRevisionInheritSplit_instant() throws Exception {
548         testDiffRevisionInheritSplit(true);
549     }
testDiffRevisionInheritSplit(boolean instant)550     private void testDiffRevisionInheritSplit(boolean instant) throws Exception {
551         new InstallMultiple(instant).addFile(APK).addFile(APK_v7).run();
552         runDeviceTests(PKG, CLASS, "testRevision0_0");
553         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_DIFF_REVISION).run();
554         runDeviceTests(PKG, CLASS, "testRevision12_0");
555     }
556 
557     @Test
558     @AppModeFull(reason = "'full' portion of the hostside test")
testDiffRevisionDowngrade_full()559     public void testDiffRevisionDowngrade_full() throws Exception {
560         testDiffRevisionDowngrade(false);
561     }
562     @Test
563     @AppModeInstant(reason = "'instant' portion of the hostside test")
testDiffRevisionDowngrade_instant()564     public void testDiffRevisionDowngrade_instant() throws Exception {
565         testDiffRevisionDowngrade(true);
566     }
testDiffRevisionDowngrade(boolean instant)567     private void testDiffRevisionDowngrade(boolean instant) throws Exception {
568         new InstallMultiple(instant).addFile(APK).addFile(APK_DIFF_REVISION_v7).run();
569         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_v7).runExpectingFailure();
570     }
571 
572     @Test
573     @AppModeFull(reason = "'full' portion of the hostside test")
testFeatureWarmBase_full()574     public void testFeatureWarmBase_full() throws Exception {
575         testFeatureWarmBase(false);
576     }
577     @Test
578     @AppModeInstant(reason = "'instant' portion of the hostside test")
testFeatureWarmBase_instant()579     public void testFeatureWarmBase_instant() throws Exception {
580         testFeatureWarmBase(true);
581     }
testFeatureWarmBase(boolean instant)582     private void testFeatureWarmBase(boolean instant) throws Exception {
583         new InstallMultiple(instant).addFile(APK).addFile(APK_FEATURE_WARM).run();
584         runDeviceTests(PKG, CLASS, "testFeatureWarmBase");
585     }
586 
587     @Test
588     @AppModeFull(reason = "'full' portion of the hostside test")
testFeatureWarmApi_full()589     public void testFeatureWarmApi_full() throws Exception {
590         testFeatureWarmApi(false);
591     }
592     @Test
593     @AppModeInstant(reason = "'instant' portion of the hostside test")
testFeatureWarmApi_instant()594     public void testFeatureWarmApi_instant() throws Exception {
595         testFeatureWarmApi(true);
596     }
testFeatureWarmApi(boolean instant)597     private void testFeatureWarmApi(boolean instant) throws Exception {
598         new InstallMultiple(instant).addFile(APK).addFile(APK_FEATURE_WARM)
599                 .addFile(APK_FEATURE_WARM_v7).run();
600         runDeviceTests(PKG, CLASS, "testFeatureWarmApi");
601     }
602 
603     @Test
604     @AppModeFull(reason = "'full' portion of the hostside test")
testInheritUpdatedBase_full()605     public void testInheritUpdatedBase_full() throws Exception {
606         testInheritUpdatedBase(false);
607     }
608     @Test
609     @AppModeInstant(reason = "'instant' portion of the hostside test")
testInheritUpdatedBase_instant()610     public void testInheritUpdatedBase_instant() throws Exception {
611         testInheritUpdatedBase(true);
612     }
testInheritUpdatedBase(boolean instant)613     public void testInheritUpdatedBase(boolean instant) throws Exception {
614         new InstallMultiple(instant).addFile(APK).addFile(APK_FEATURE_WARM).run();
615         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_REVISION_A).run();
616         runDeviceTests(PKG, CLASS, "testInheritUpdatedBase_withRevisionA", instant);
617     }
618 
619     @Test
620     @AppModeFull(reason = "'full' portion of the hostside test")
testInheritUpdatedSplit_full()621     public void testInheritUpdatedSplit_full() throws Exception {
622         testInheritUpdatedSplit(false);
623     }
624     @Test
625     @AppModeInstant(reason = "'instant' portion of the hostside test")
testInheritUpdatedSplit_instant()626     public void testInheritUpdatedSplit_instant() throws Exception {
627         testInheritUpdatedSplit(true);
628     }
testInheritUpdatedSplit(boolean instant)629     private void testInheritUpdatedSplit(boolean instant) throws Exception {
630         new InstallMultiple(instant).addFile(APK).addFile(APK_FEATURE_WARM).run();
631         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_FEATURE_WARM_REVISION_A).run();
632         runDeviceTests(PKG, CLASS, "testInheritUpdatedSplit_withRevisionA", instant);
633     }
634 
635     @Test
636     @AppModeFull(reason = "'full' portion of the hostside test")
testFeatureWithoutRestart_full()637     public void testFeatureWithoutRestart_full() throws Exception {
638         testFeatureWithoutRestart(false);
639     }
640     @Test
641     @AppModeInstant(reason = "'instant' portion of the hostside test")
testFeatureWithoutRestart_instant()642     public void testFeatureWithoutRestart_instant() throws Exception {
643         testFeatureWithoutRestart(true);
644     }
testFeatureWithoutRestart(boolean instant)645     private void testFeatureWithoutRestart(boolean instant) throws Exception {
646         // always install as a full app; we're testing that the instant app can be
647         // updated without restarting and need a broadcast receiver to ensure the
648         // correct behaviour. So, this component must be visible to instant apps.
649         new InstallMultiple().addFile(APK).run();
650 
651         new InstallMultiple(instant).addFile(APK_NO_RESTART_BASE).run();
652         runDeviceTests(PKG, CLASS, "testBaseInstalled", instant);
653         new InstallMultiple(instant)
654                 .addArg("--dont-kill")
655                 .inheritFrom(PKG_NO_RESTART)
656                 .addFile(APK_NO_RESTART_FEATURE)
657                 .run();
658         runDeviceTests(PKG, CLASS, "testFeatureInstalled", instant);
659     }
660 
661     @Test
662     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitMissing_full()663     public void testRequiredSplitMissing_full() throws Exception {
664         testRequiredSplitMissing(false);
665     }
666     @Test
667     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitMissing_instant()668     public void testRequiredSplitMissing_instant() throws Exception {
669         testRequiredSplitMissing(true);
670     }
testRequiredSplitMissing(boolean instant)671     private void testRequiredSplitMissing(boolean instant) throws Exception {
672         new InstallMultiple(instant).addFile(APK_NEED_SPLIT_BASE)
673                 .runExpectingFailure("INSTALL_FAILED_MISSING_SPLIT");
674     }
675 
676     @Test
677     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitInstalledFeatureWarm_full()678     public void testRequiredSplitInstalledFeatureWarm_full() throws Exception {
679         testRequiredSplitInstalledFeatureWarm(false);
680     }
681     @Test
682     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitInstalledFeatureWarm_instant()683     public void testRequiredSplitInstalledFeatureWarm_instant() throws Exception {
684         testRequiredSplitInstalledFeatureWarm(true);
685     }
testRequiredSplitInstalledFeatureWarm(boolean instant)686     private void testRequiredSplitInstalledFeatureWarm(boolean instant) throws Exception {
687         new InstallMultiple(instant).addFile(APK_NEED_SPLIT_BASE)
688                 .addFile(APK_NEED_SPLIT_FEATURE_WARM).run();
689     }
690 
691     @Test
692     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitInstalledConfig_full()693     public void testRequiredSplitInstalledConfig_full() throws Exception {
694         testRequiredSplitInstalledConfig(false);
695     }
696     @Test
697     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitInstalledConfig_instant()698     public void testRequiredSplitInstalledConfig_instant() throws Exception {
699         testRequiredSplitInstalledConfig(true);
700     }
testRequiredSplitInstalledConfig(boolean instant)701     private void testRequiredSplitInstalledConfig(boolean instant) throws Exception {
702         new InstallMultiple(instant).addFile(APK_NEED_SPLIT_BASE).addFile(APK_NEED_SPLIT_CONFIG)
703                 .run();
704     }
705 
706     @Test
707     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitRemoved_full()708     public void testRequiredSplitRemoved_full() throws Exception {
709         testRequiredSplitRemoved(false);
710     }
711     @Test
712     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitRemoved_instant()713     public void testRequiredSplitRemoved_instant() throws Exception {
714         testRequiredSplitRemoved(true);
715     }
testRequiredSplitRemoved(boolean instant)716     private void testRequiredSplitRemoved(boolean instant) throws Exception {
717         // start with a base and two splits
718         new InstallMultiple(instant)
719                 .addFile(APK_NEED_SPLIT_BASE)
720                 .addFile(APK_NEED_SPLIT_FEATURE_WARM)
721                 .addFile(APK_NEED_SPLIT_CONFIG)
722                 .run();
723         // it's okay to remove one of the splits
724         new InstallMultiple(instant).inheritFrom(PKG).removeSplit("feature_warm").run();
725         // but, not to remove all of them
726         new InstallMultiple(instant).inheritFrom(PKG).removeSplit("config.xxhdpi")
727                 .runExpectingFailure("INSTALL_FAILED_MISSING_SPLIT");
728     }
729 
730     @Test
731     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitTypesInstalledIncomplete_full()732     public void testRequiredSplitTypesInstalledIncomplete_full() throws Exception {
733         testRequiredSplitTypesInstalledIncomplete(false);
734     }
735     @Test
736     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitTypesInstalledIncomplete_instant()737     public void testRequiredSplitTypesInstalledIncomplete_instant() throws Exception {
738         testRequiredSplitTypesInstalledIncomplete(true);
739     }
testRequiredSplitTypesInstalledIncomplete(boolean instant)740     private void testRequiredSplitTypesInstalledIncomplete(boolean instant) throws Exception {
741         new InstallMultiple(instant).addFile(APK_REQUIRED_SPLIT_TYPE_BASE)
742                 .addFile(APK_REQUIRED_SPLIT_TYPE_LOCALE)
743                 .runExpectingFailure("INSTALL_FAILED_MISSING_SPLIT");
744     }
745 
746     @Test
747     @AppModeFull(reason = "'full' portion of the hostside test")
testInvalidRequiredSplitTypes_full()748     public void testInvalidRequiredSplitTypes_full() throws Exception {
749         testInvalidRequiredSplitTypes(false);
750     }
751     @Test
752     @AppModeInstant(reason = "'instant' portion of the hostside test")
testInvalidRequiredSplitTypes_instant()753     public void testInvalidRequiredSplitTypes_instant() throws Exception {
754         testInvalidRequiredSplitTypes(true);
755     }
testInvalidRequiredSplitTypes(boolean instant)756     private void testInvalidRequiredSplitTypes(boolean instant) throws Exception {
757         new InstallMultiple(instant).addFile(APK_INVALID_REQUIRED_SPLIT_TYPE_BASE)
758                 .runExpectingFailure("INSTALL_PARSE_FAILED_MANIFEST_MALFORMED");
759     }
760 
761     @Test
762     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitTypesInstalledAll_full()763     public void testRequiredSplitTypesInstalledAll_full() throws Exception {
764         testRequiredSplitTypesInstalledAll(false);
765     }
766     @Test
767     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitTypesInstalledAll_instant()768     public void testRequiredSplitTypesInstalledAll_instant() throws Exception {
769         testRequiredSplitTypesInstalledAll(true);
770     }
testRequiredSplitTypesInstalledAll(boolean instant)771     private void testRequiredSplitTypesInstalledAll(boolean instant) throws Exception {
772         new InstallMultiple(instant).addFile(APK_REQUIRED_SPLIT_TYPE_BASE)
773                 .addFile(APK_REQUIRED_SPLIT_TYPE_DENSITY)
774                 .addFile(APK_REQUIRED_SPLIT_TYPE_LOCALE)
775                 .run();
776     }
777 
778     @Test
779     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitTypesInstalledMultipleOne_full()780     public void testRequiredSplitTypesInstalledMultipleOne_full() throws Exception {
781         testRequiredSplitTypesInstalledMultipleOne(false);
782     }
783     @Test
784     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitTypesInstalledMultipleOne_instant()785     public void testRequiredSplitTypesInstalledMultipleOne_instant() throws Exception {
786         testRequiredSplitTypesInstalledMultipleOne(true);
787     }
testRequiredSplitTypesInstalledMultipleOne(boolean instant)788     private void testRequiredSplitTypesInstalledMultipleOne(boolean instant) throws Exception {
789         new InstallMultiple(instant).addFile(APK_REQUIRED_SPLIT_TYPE_BASE)
790                 .addFile(APK_REQUIRED_SPLIT_TYPE_MULTIPLE)
791                 .run();
792     }
793 
794     @Test
795     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitTypesRemoved_full()796     public void testRequiredSplitTypesRemoved_full() throws Exception {
797         testRequiredSplitTypesRemoved(false);
798     }
799     @Test
800     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitTypesRemoved_instant()801     public void testRequiredSplitTypesRemoved_instant() throws Exception {
802         testRequiredSplitTypesRemoved(true);
803     }
testRequiredSplitTypesRemoved(boolean instant)804     private void testRequiredSplitTypesRemoved(boolean instant) throws Exception {
805         // start with a base and three splits
806         new InstallMultiple(instant)
807                 .addFile(APK_REQUIRED_SPLIT_TYPE_BASE)
808                 .addFile(APK_REQUIRED_SPLIT_TYPE_DENSITY)
809                 .addFile(APK_REQUIRED_SPLIT_TYPE_LOCALE)
810                 .addFile(APK_REQUIRED_SPLIT_TYPE_FOO)
811                 .run();
812         // it's okay to remove non-required split type
813         new InstallMultiple(instant).inheritFrom(PKG).removeSplit("config.foo").run();
814         // but, not to remove a required one
815         new InstallMultiple(instant).inheritFrom(PKG).removeSplit("config.de")
816                 .runExpectingFailure("INSTALL_FAILED_MISSING_SPLIT");
817     }
818 
819     @Test
820     @AppModeFull(reason = "'full' portion of the hostside test")
testInheritUpdatedBase_requiredSplitTypesMissing_full()821     public void testInheritUpdatedBase_requiredSplitTypesMissing_full() throws Exception {
822         testInheritUpdatedBase_requiredSplitTypesMissing(false);
823     }
824     @Test
825     @AppModeInstant(reason = "'instant' portion of the hostside test")
testInheritUpdatedBase_requiredSplitTypesMissing_instant()826     public void testInheritUpdatedBase_requiredSplitTypesMissing_instant() throws Exception {
827         testInheritUpdatedBase_requiredSplitTypesMissing(true);
828     }
testInheritUpdatedBase_requiredSplitTypesMissing(boolean instant)829     private void testInheritUpdatedBase_requiredSplitTypesMissing(boolean instant)
830             throws Exception {
831         // start with a base and the required splits
832         new InstallMultiple(instant)
833                 .addFile(APK_REQUIRED_SPLIT_TYPE_BASE)
834                 .addFile(APK_REQUIRED_SPLIT_TYPE_DENSITY)
835                 .addFile(APK_REQUIRED_SPLIT_TYPE_LOCALE)
836                 .run();
837         // the updated base requires a new split type, but it's missing
838         new InstallMultiple(instant).inheritFrom(PKG).addFile(APK_REQUIRED_SPLIT_TYPE_BASE_UPDATED)
839                 .runExpectingFailure("INSTALL_FAILED_MISSING_SPLIT");
840     }
841 
842     @Test
843     @AppModeFull(reason = "'full' portion of the hostside test")
testInheritUpdatedBase_requiredSplitTypesInstalled_full()844     public void testInheritUpdatedBase_requiredSplitTypesInstalled_full() throws Exception {
845         testInheritUpdatedBase_requiredSplitTypesInstalled(false);
846     }
847     @Test
848     @AppModeInstant(reason = "'instant' portion of the hostside test")
testInheritUpdatedBase_requiredSplitTypesInstalled_instant()849     public void testInheritUpdatedBase_requiredSplitTypesInstalled_instant() throws Exception {
850         testInheritUpdatedBase_requiredSplitTypesInstalled(true);
851     }
testInheritUpdatedBase_requiredSplitTypesInstalled(boolean instant)852     private void testInheritUpdatedBase_requiredSplitTypesInstalled(boolean instant)
853             throws Exception {
854         // start with a base and the required splits
855         new InstallMultiple(instant)
856                 .addFile(APK_REQUIRED_SPLIT_TYPE_BASE)
857                 .addFile(APK_REQUIRED_SPLIT_TYPE_DENSITY)
858                 .addFile(APK_REQUIRED_SPLIT_TYPE_LOCALE)
859                 .run();
860         // the updated base requires a split type, and this split also requires another.
861         new InstallMultiple(instant).inheritFrom(PKG)
862                 .addFile(APK_REQUIRED_SPLIT_TYPE_BASE_UPDATED)
863                 .addFile(APK_REQUIRED_SPLIT_TYPE_FEATURE)
864                 .addFile(APK_REQUIRED_SPLIT_TYPE_FEATURE_DATA)
865                 .run();
866     }
867 
868     @Test
869     @AppModeFull(reason = "'full' portion of the hostside test")
testRequiredSplitTypesFromSplit_full()870     public void testRequiredSplitTypesFromSplit_full() throws Exception {
871         testRequiredSplitTypesFromSplit(false);
872     }
873     @Test
874     @AppModeInstant(reason = "'instant' portion of the hostside test")
testRequiredSplitTypesFromSplit_instant()875     public void testRequiredSplitTypesFromSplit_instant() throws Exception {
876         testRequiredSplitTypesFromSplit(true);
877     }
testRequiredSplitTypesFromSplit(boolean instant)878     private void testRequiredSplitTypesFromSplit(boolean instant) throws Exception {
879         new InstallMultiple(instant)
880                 .addFile(APK_REQUIRED_SPLIT_TYPE_BASE)
881                 .addFile(APK_REQUIRED_SPLIT_TYPE_DENSITY)
882                 .addFile(APK_REQUIRED_SPLIT_TYPE_LOCALE)
883                 .addFile(APK_REQUIRED_SPLIT_TYPE_FEATURE)
884                 .addFile(APK_REQUIRED_SPLIT_TYPE_FEATURE_DATA)
885                 .addFile(APK_REQUIRED_SPLIT_TYPE_FEATURE_FOO)
886                 .run();
887         // it's okay to remove non-required split type for the split
888         new InstallMultiple(instant).inheritFrom(PKG).removeSplit("feature_foo.foo").run();
889         // but, not to remove a required one for the split
890         new InstallMultiple(instant).inheritFrom(PKG).removeSplit("feature_foo.data")
891                 .runExpectingFailure("INSTALL_FAILED_MISSING_SPLIT");
892     }
893 
894     /**
895      * Verify that installing a new version of app wipes code cache.
896      */
897     @Test
898     @AppModeFull(reason = "'full' portion of the hostside test")
testClearCodeCache_full()899     public void testClearCodeCache_full() throws Exception {
900         testClearCodeCache(false);
901     }
902     @Test
903     @AppModeInstant(reason = "'instant' portion of the hostside test")
testClearCodeCache_instant()904     public void testClearCodeCache_instant() throws Exception {
905         testClearCodeCache(true);
906     }
testClearCodeCache(boolean instant)907     private void testClearCodeCache(boolean instant) throws Exception {
908         new InstallMultiple(instant).addFile(APK).run();
909         runDeviceTests(PKG, CLASS, "testCodeCacheWrite");
910         new InstallMultiple(instant).addArg("-r").addFile(APK_DIFF_VERSION).run();
911         runDeviceTests(PKG, CLASS, "testCodeCacheRead");
912     }
913 
914     @Test
915     @AppModeInstant(reason = "'instant' portion of the hostside test")
testComponentWithSplitName_instant()916     public void testComponentWithSplitName_instant() throws Exception {
917         new InstallMultiple(true).addFile(APK_INSTANT).run();
918         runDeviceTests(PKG, CLASS, "testComponentWithSplitName_singleBase");
919         new InstallMultiple(true).inheritFrom(PKG).addFile(APK_FEATURE_WARM).run();
920         runDeviceTests(PKG, CLASS, "testComponentWithSplitName_featureWarmInstalled");
921     }
922 
923     @Test
924     @AppModeFull(reason = "'full' portion of the hostside test")
testTheme_installBase_full()925     public void testTheme_installBase_full() throws Exception {
926         testTheme_installBase(false);
927     }
928     @Test
929     @AppModeInstant(reason = "'instant' portion of the hostside test")
testTheme_installBase_instant()930     public void testTheme_installBase_instant() throws Exception {
931         testTheme_installBase(true);
932     }
testTheme_installBase(boolean instant)933     private void testTheme_installBase(boolean instant) throws Exception {
934         new InstallMultiple(instant).addFile(APK).run();
935         runDeviceTests(PKG, CLASS, "launchBaseActivity_withThemeBase_baseApplied");
936     }
937 
938     @Test
939     @AppModeFull(reason = "'full' portion of the hostside test")
testTheme_installBaseV23_full()940     public void testTheme_installBaseV23_full() throws Exception {
941         testTheme_installBaseV23(false);
942     }
943     @Test
944     @AppModeInstant(reason = "'instant' portion of the hostside test")
testTheme_installBaseV23_instant()945     public void testTheme_installBaseV23_instant() throws Exception {
946         testTheme_installBaseV23(true);
947     }
testTheme_installBaseV23(boolean instant)948     private void testTheme_installBaseV23(boolean instant) throws Exception {
949         new InstallMultiple(instant).addFile(APK).addFile(APK_v23).run();
950         runDeviceTests(PKG, CLASS, "launchBaseActivity_withThemeBaseLt_baseLtApplied");
951     }
952 
953     @Test
954     @AppModeFull(reason = "'full' portion of the hostside test")
testTheme_installFeatureWarm_full()955     public void testTheme_installFeatureWarm_full() throws Exception {
956         testTheme_installFeatureWarm(false);
957     }
958     @Test
959     @AppModeInstant(reason = "'instant' portion of the hostside test")
testTheme_installFeatureWarm_instant()960     public void testTheme_installFeatureWarm_instant() throws Exception {
961         testTheme_installFeatureWarm(true);
962     }
testTheme_installFeatureWarm(boolean instant)963     private void testTheme_installFeatureWarm(boolean instant) throws Exception {
964         new InstallMultiple(instant).addFile(APK).addFile(APK_FEATURE_WARM).run();
965         runDeviceTests(PKG, CLASS, "launchBaseActivity_withThemeWarm_warmApplied");
966         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeBase_baseApplied");
967         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeWarm_warmApplied");
968     }
969 
970     @Test
971     @AppModeFull(reason = "'full' portion of the hostside test")
testTheme_installFeatureWarmV23_full()972     public void testTheme_installFeatureWarmV23_full() throws Exception {
973         testTheme_installFeatureWarmV23(false);
974     }
975     @Test
976     @AppModeInstant(reason = "'instant' portion of the hostside test")
testTheme_installFeatureWarmV23_instant()977     public void testTheme_installFeatureWarmV23_instant() throws Exception {
978         testTheme_installFeatureWarmV23(true);
979     }
testTheme_installFeatureWarmV23(boolean instant)980     private void testTheme_installFeatureWarmV23(boolean instant) throws Exception {
981         new InstallMultiple(instant).addFile(APK).addFile(APK_v23).addFile(APK_FEATURE_WARM)
982                 .addFile(APK_FEATURE_WARM_v23).run();
983         runDeviceTests(PKG, CLASS, "launchBaseActivity_withThemeWarmLt_warmLtApplied");
984         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeBaseLt_baseLtApplied");
985         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeWarmLt_warmLtApplied");
986     }
987 
988     @Test
989     @AppModeFull(reason = "'full' portion of the hostside test")
testTheme_installFeatureWarmV23_removeV23_full()990     public void testTheme_installFeatureWarmV23_removeV23_full() throws Exception {
991         testTheme_installFeatureWarmV23_removeV23(false);
992     }
993     @Test
994     @AppModeInstant(reason = "'instant' portion of the hostside test")
testTheme_installFeatureWarmV23_removeV23_instant()995     public void testTheme_installFeatureWarmV23_removeV23_instant() throws Exception {
996         testTheme_installFeatureWarmV23_removeV23(true);
997     }
testTheme_installFeatureWarmV23_removeV23(boolean instant)998     private void testTheme_installFeatureWarmV23_removeV23(boolean instant) throws Exception {
999         new InstallMultiple(instant).addFile(APK).addFile(APK_v23).addFile(APK_FEATURE_WARM)
1000                 .addFile(APK_FEATURE_WARM_v23).run();
1001         new InstallMultiple(instant).inheritFrom(PKG).removeSplit("config.v23")
1002                 .removeSplit("feature_warm.config.v23").run();
1003         runDeviceTests(PKG, CLASS, "launchBaseActivity_withThemeWarm_warmApplied");
1004         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeBase_baseApplied");
1005         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeWarm_warmApplied");
1006     }
1007 
1008     @Test
1009     @AppModeFull(reason = "'full' portion of the hostside test")
testTheme_installFeatureWarmAndRose_full()1010     public void testTheme_installFeatureWarmAndRose_full() throws Exception {
1011         testTheme_installFeatureWarmAndRose(false);
1012     }
1013     @Test
1014     @AppModeInstant(reason = "'instant' portion of the hostside test")
testTheme_installFeatureWarmAndRose_instant()1015     public void testTheme_installFeatureWarmAndRose_instant() throws Exception {
1016         testTheme_installFeatureWarmAndRose(true);
1017     }
testTheme_installFeatureWarmAndRose(boolean instant)1018     private void testTheme_installFeatureWarmAndRose(boolean instant) throws Exception {
1019         new InstallMultiple(instant).addFile(APK).addFile(APK_FEATURE_WARM)
1020                 .addFile(APK_FEATURE_ROSE).run();
1021         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeWarm_warmApplied");
1022         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeRose_roseApplied");
1023         runDeviceTests(PKG, CLASS, "launchRoseActivity_withThemeWarm_warmApplied");
1024         runDeviceTests(PKG, CLASS, "launchRoseActivity_withThemeRose_roseApplied");
1025     }
1026 
1027     @Test
1028     @AppModeFull(reason = "'full' portion of the hostside test")
testTheme_installFeatureWarmAndRoseV23_full()1029     public void testTheme_installFeatureWarmAndRoseV23_full() throws Exception {
1030         testTheme_installFeatureWarmAndRoseV23(false);
1031     }
1032     @Test
1033     @AppModeInstant(reason = "'instant' portion of the hostside test")
testTheme_installFeatureWarmAndRoseV23_instant()1034     public void testTheme_installFeatureWarmAndRoseV23_instant() throws Exception {
1035         testTheme_installFeatureWarmAndRoseV23(true);
1036     }
testTheme_installFeatureWarmAndRoseV23(boolean instant)1037     private void testTheme_installFeatureWarmAndRoseV23(boolean instant) throws Exception {
1038         new InstallMultiple(instant).addFile(APK).addFile(APK_v23)
1039                 .addFile(APK_FEATURE_WARM).addFile(APK_FEATURE_WARM_v23)
1040                 .addFile(APK_FEATURE_ROSE).addFile(APK_FEATURE_ROSE_v23).run();
1041         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeWarmLt_warmLtApplied");
1042         runDeviceTests(PKG, CLASS, "launchWarmActivity_withThemeRoseLt_roseLtApplied");
1043         runDeviceTests(PKG, CLASS, "launchRoseActivity_withThemeWarmLt_warmLtApplied");
1044         runDeviceTests(PKG, CLASS, "launchRoseActivity_withThemeRoseLt_roseLtApplied");
1045     }
1046 }
1047