Search in sources :

Example 6 with AbiModel

use of com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel in project android by JetBrains.

the class SplitsModelTest method testAddElements.

public void testAddElements() throws Exception {
    String text = "android {\n" + "  splits {\n" + "  }\n" + "}";
    writeToBuildFile(text);
    verifyNullSplitsValues();
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    AbiModel abi = splits.abi();
    abi.setEnable(true);
    abi.addExclude("abi-exclude");
    abi.addInclude("abi-include");
    abi.setUniversalApk(false);
    DensityModel density = splits.density();
    density.setAuto(false);
    density.addCompatibleScreen("screen");
    density.setEnable(true);
    density.addExclude("density-exclude");
    density.addInclude("density-include");
    LanguageModel language = splits.language();
    language.setEnable(false);
    language.addInclude("language-include");
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    splits = android.splits();
    abi = splits.abi();
    assertEquals("enable", Boolean.TRUE, abi.enable());
    assertEquals("exclude", ImmutableList.of("abi-exclude"), abi.exclude());
    assertEquals("include", ImmutableList.of("abi-include"), abi.include());
    assertEquals("universalApk", Boolean.FALSE, abi.universalApk());
    density = splits.density();
    assertEquals("auto", Boolean.FALSE, density.auto());
    assertEquals("compatibleScreens", ImmutableList.of("screen"), density.compatibleScreens());
    assertEquals("enable", Boolean.TRUE, density.enable());
    assertEquals("exclude", ImmutableList.of("density-exclude"), density.exclude());
    assertEquals("include", ImmutableList.of("density-include"), density.include());
    language = splits.language();
    assertEquals("enable", Boolean.FALSE, language.enable());
    assertEquals("include", ImmutableList.of("language-include"), language.include());
}
Also used : DensityModel(com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) LanguageModel(com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel) AbiModel(com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel)

Example 7 with AbiModel

use of com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel in project android by JetBrains.

the class SplitsModelTest method testEditElements.

public void testEditElements() throws Exception {
    writeToBuildFile(SPLITS_TEXT);
    verifySplitsValues();
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    AbiModel abi = splits.abi();
    abi.setEnable(false);
    abi.replaceExclude("abi-exclude-2", "abi-exclude-3");
    abi.replaceInclude("abi-include-2", "abi-include-3");
    abi.setUniversalApk(true);
    DensityModel density = splits.density();
    density.setAuto(true);
    density.replaceCompatibleScreen("screen2", "screen3");
    density.setEnable(false);
    density.replaceExclude("density-exclude-2", "density-exclude-3");
    density.replaceInclude("density-include-2", "density-include-3");
    LanguageModel language = splits.language();
    language.setEnable(true);
    language.replaceInclude("language-include-2", "language-include-3");
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    splits = android.splits();
    abi = splits.abi();
    assertEquals("enable", Boolean.FALSE, abi.enable());
    assertEquals("exclude", ImmutableList.of("abi-exclude-1", "abi-exclude-3"), abi.exclude());
    assertEquals("include", ImmutableList.of("abi-include-1", "abi-include-3"), abi.include());
    assertEquals("universalApk", Boolean.TRUE, abi.universalApk());
    density = splits.density();
    assertEquals("auto", Boolean.TRUE, density.auto());
    assertEquals("compatibleScreens", ImmutableList.of("screen1", "screen3"), density.compatibleScreens());
    assertEquals("enable", Boolean.FALSE, density.enable());
    assertEquals("exclude", ImmutableList.of("density-exclude-1", "density-exclude-3"), density.exclude());
    assertEquals("include", ImmutableList.of("density-include-1", "density-include-3"), density.include());
    language = splits.language();
    assertEquals("enable", Boolean.TRUE, language.enable());
    assertEquals("include", ImmutableList.of("language-include-1", "language-include-3"), language.include());
}
Also used : DensityModel(com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) LanguageModel(com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel) AbiModel(com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel)

Example 8 with AbiModel

use of com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel in project android by JetBrains.

the class SplitsModelTest method testRemoveElements.

public void testRemoveElements() throws Exception {
    writeToBuildFile(SPLITS_TEXT);
    verifySplitsValues();
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    assertTrue(splits.hasValidPsiElement());
    AbiModel abi = splits.abi();
    assertTrue(abi.hasValidPsiElement());
    abi.removeEnable();
    abi.removeAllExclude();
    abi.removeAllInclude();
    abi.removeUniversalApk();
    DensityModel density = splits.density();
    assertTrue(density.hasValidPsiElement());
    density.removeAuto();
    density.removeAllCompatibleScreens();
    density.removeEnable();
    density.removeAllExclude();
    density.removeAllInclude();
    LanguageModel language = splits.language();
    assertTrue(language.hasValidPsiElement());
    language.removeEnable();
    language.removeAllInclude();
    applyChangesAndReparse(buildModel);
    verifyNullSplitsValues();
    android = buildModel.android();
    assertNotNull(android);
    splits = android.splits();
    assertFalse(splits.hasValidPsiElement());
}
Also used : DensityModel(com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) LanguageModel(com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel) AbiModel(com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel)

Aggregations

AbiModel (com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel)8 DensityModel (com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel)7 LanguageModel (com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel)7 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)5 AbiDslElement (com.android.tools.idea.gradle.dsl.parser.android.splits.AbiDslElement)1 NotNull (org.jetbrains.annotations.NotNull)1