Search in sources :

Example 6 with DensityModel

use of com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel 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 7 with DensityModel

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

the class SplitsModel method density.

@NotNull
public DensityModel density() {
    DensityDslElement densityDslElement = myDslElement.getPropertyElement(DENSITY_BLOCK_NAME, DensityDslElement.class);
    if (densityDslElement == null) {
        densityDslElement = new DensityDslElement(myDslElement);
        myDslElement.setNewElement(DENSITY_BLOCK_NAME, densityDslElement);
    }
    return new DensityModel(densityDslElement);
}
Also used : DensityModel(com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel) DensityDslElement(com.android.tools.idea.gradle.dsl.parser.android.splits.DensityDslElement) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with DensityModel

use of com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel 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

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