Search in sources :

Example 71 with AndroidVersion

use of com.android.sdklib.AndroidVersion in project android by JetBrains.

the class InstantRunBuilderTest method alternativeUiForHotswap.

@Test
public void alternativeUiForHotswap() throws Exception {
    myDumpsysPackageOutput = DUMPSYS_PACKAGE_EXISTS;
    myDeviceBuildTimetamp = "100";
    myAppInForeground = true;
    myRunConfigContext.setSameExecutorAsPreviousSession(true);
    when(myDevice.getVersion()).thenReturn(new AndroidVersion(23, null));
    setUpDeviceForHotSwap();
    // normally we'd do a hotswap
    myBuilder.build(myTaskRunner, Collections.emptyList());
    assertEquals("gradlew -Pandroid.optional.compilation=INSTANT_DEV -Pandroid.injected.coldswap.mode=MULTIAPK :app:assemble", myTaskRunner.getBuilds());
    // but a full apk is forced if this was launched from the new UI
    boolean[] couldHaveInvokedHotswapValues = new boolean[] { true, false };
    for (boolean couldHaveHotswaped : couldHaveInvokedHotswapValues) {
        myRunConfigContext.setForceColdSwap(true, couldHaveHotswaped);
        myTaskRunner = new RecordingTaskRunner();
        myBuilder.build(myTaskRunner, Collections.emptyList());
        assertEquals("gradlew -Pandroid.optional.compilation=INSTANT_DEV,RESTART_ONLY -Pandroid.injected.coldswap.mode=MULTIAPK :app:assemble", myTaskRunner.getBuilds());
    }
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) Test(org.junit.Test)

Example 72 with AndroidVersion

use of com.android.sdklib.AndroidVersion in project android by JetBrains.

the class InstantRunBuilderTest method hotSwapBuild.

@Test
public void hotSwapBuild() throws Exception {
    myDumpsysPackageOutput = DUMPSYS_PACKAGE_EXISTS;
    myDeviceBuildTimetamp = "100";
    myAppInForeground = true;
    myRunConfigContext.setSameExecutorAsPreviousSession(true);
    when(myDevice.getVersion()).thenReturn(new AndroidVersion(23, null));
    setUpDeviceForHotSwap();
    myBuilder.build(myTaskRunner, Collections.emptyList());
    assertEquals("gradlew -Pandroid.optional.compilation=INSTANT_DEV -Pandroid.injected.coldswap.mode=MULTIAPK :app:assemble", myTaskRunner.getBuilds());
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) Test(org.junit.Test)

Example 73 with AndroidVersion

use of com.android.sdklib.AndroidVersion in project android by JetBrains.

the class InstantRunBuilderTest method coldSwapBuildIfUsingMultipleProcesses.

@Test
public void coldSwapBuildIfUsingMultipleProcesses() throws Exception {
    myDumpsysPackageOutput = DUMPSYS_PACKAGE_EXISTS;
    myDeviceBuildTimetamp = "100";
    myAppInForeground = true;
    myRunConfigContext.setSameExecutorAsPreviousSession(true);
    when(myDevice.getVersion()).thenReturn(new AndroidVersion(23, null));
    setUpDeviceForHotSwap();
    when(myInstantRunContext.usesMultipleProcesses()).thenReturn(true);
    myBuilder.build(myTaskRunner, Collections.emptyList());
    assertEquals("gradlew -Pandroid.optional.compilation=INSTANT_DEV,RESTART_ONLY -Pandroid.injected.coldswap.mode=MULTIAPK :app:assemble", myTaskRunner.getBuilds());
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) Test(org.junit.Test)

Example 74 with AndroidVersion

use of com.android.sdklib.AndroidVersion in project android by JetBrains.

the class InstantRunBuilderTest method fullBuildIfNoLocalTimestamp.

@Test
public void fullBuildIfNoLocalTimestamp() throws Exception {
    myDumpsysPackageOutput = DUMPSYS_NO_SUCH_PACKAGE;
    when(myInstantRunContext.getInstantRunBuildInfo()).thenReturn(null);
    when(myDevice.getVersion()).thenReturn(new AndroidVersion(23, null));
    myBuilder.build(myTaskRunner, Collections.emptyList());
    assertEquals("gradlew -Pandroid.optional.compilation=INSTANT_DEV,FULL_APK -Pandroid.injected.coldswap.mode=MULTIAPK :app:assemble", myTaskRunner.getBuilds());
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) Test(org.junit.Test)

Example 75 with AndroidVersion

use of com.android.sdklib.AndroidVersion in project android by JetBrains.

the class InstantRunBuilderTest method fullBuildWhenPackageNotInstalledForDefaultUser.

@Test
public void fullBuildWhenPackageNotInstalledForDefaultUser() throws Exception {
    myDumpsysPackageOutput = "Packages:\n" + "  Package [instant.run] (a1df9a8):\n" + "    User 0:  installed=false hidden=false stopped=true notLaunched=true enabled=0\n" + "      runtime permissions:\n" + "    User 10:  installed=true hidden=false stopped=true notLaunched=false enabled=0\n" + "      runtime permissions:\n";
    myDeviceBuildTimetamp = "100";
    when(myDevice.getVersion()).thenReturn(new AndroidVersion(23, null));
    myBuilder.build(myTaskRunner, Collections.emptyList());
    assertEquals("gradlew -Pandroid.optional.compilation=INSTANT_DEV,FULL_APK -Pandroid.injected.coldswap.mode=MULTIAPK :app:assemble", myTaskRunner.getBuilds());
}
Also used : AndroidVersion(com.android.sdklib.AndroidVersion) Test(org.junit.Test)

Aggregations

AndroidVersion (com.android.sdklib.AndroidVersion)89 Test (org.junit.Test)21 NotNull (org.jetbrains.annotations.NotNull)14 IAndroidTarget (com.android.sdklib.IAndroidTarget)12 IDevice (com.android.ddmlib.IDevice)11 Nullable (org.jetbrains.annotations.Nullable)9 MockPlatformTarget (com.android.sdklib.internal.androidTarget.MockPlatformTarget)8 Module (com.intellij.openapi.module.Module)8 File (java.io.File)8 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)8 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)8 DetailsTypes (com.android.sdklib.repository.meta.DetailsTypes)6 Project (com.intellij.openapi.project.Project)5 Abi (com.android.sdklib.devices.Abi)4 InstantRunGradleSupport (com.android.tools.idea.fd.gradle.InstantRunGradleSupport)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)4 OutputFile (com.android.build.OutputFile)3 TypeDetails (com.android.repository.impl.meta.TypeDetails)3 AvdInfo (com.android.sdklib.internal.avd.AvdInfo)3 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)3