Search in sources :

Example 1 with AbiModel

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

the class SplitsModel method abi.

@NotNull
public AbiModel abi() {
    AbiDslElement abiDslElement = myDslElement.getPropertyElement(ABI_BLOCK_NAME, AbiDslElement.class);
    if (abiDslElement == null) {
        abiDslElement = new AbiDslElement(myDslElement);
        myDslElement.setNewElement(ABI_BLOCK_NAME, abiDslElement);
    }
    return new AbiModel(abiDslElement);
}
Also used : AbiDslElement(com.android.tools.idea.gradle.dsl.parser.android.splits.AbiDslElement) AbiModel(com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with AbiModel

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

the class SplitsModelTest method testRemoveOneOfElementsInTheList.

public void testRemoveOneOfElementsInTheList() throws Exception {
    String text = "android {\n" + "  splits {\n" + "    abi {\n" + "      exclude 'abi-exclude-1', 'abi-exclude-2'\n" + "      include 'abi-include-1', 'abi-include-2'\n" + "    }\n" + "    density {\n" + "      compatibleScreens 'screen1', 'screen2'\n" + "      exclude 'density-exclude-1', 'density-exclude-2'\n" + "      include 'density-include-1', 'density-include-2'\n" + "    }\n" + "    language {\n" + "      include 'language-include-1', 'language-include-2'\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    AbiModel abi = splits.abi();
    assertEquals("exclude", ImmutableList.of("abi-exclude-1", "abi-exclude-2"), abi.exclude());
    assertEquals("include", ImmutableList.of("abi-include-1", "abi-include-2"), abi.include());
    DensityModel density = splits.density();
    assertEquals("compatibleScreens", ImmutableList.of("screen1", "screen2"), density.compatibleScreens());
    assertEquals("exclude", ImmutableList.of("density-exclude-1", "density-exclude-2"), density.exclude());
    assertEquals("include", ImmutableList.of("density-include-1", "density-include-2"), density.include());
    LanguageModel language = splits.language();
    assertEquals("include", ImmutableList.of("language-include-1", "language-include-2"), language.include());
    abi.removeExclude("abi-exclude-1");
    abi.removeInclude("abi-include-2");
    density.removeCompatibleScreen("screen1");
    density.removeExclude("density-exclude-2");
    density.removeInclude("density-include-1");
    language.removeInclude("language-include-2");
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    splits = android.splits();
    abi = splits.abi();
    assertEquals("exclude", ImmutableList.of("abi-exclude-2"), abi.exclude());
    assertEquals("include", ImmutableList.of("abi-include-1"), abi.include());
    density = splits.density();
    assertEquals("compatibleScreens", ImmutableList.of("screen2"), density.compatibleScreens());
    assertEquals("exclude", ImmutableList.of("density-exclude-1"), density.exclude());
    assertEquals("include", ImmutableList.of("density-include-2"), density.include());
    language = splits.language();
    assertEquals("include", ImmutableList.of("language-include-1"), 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 3 with AbiModel

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

the class SplitsModelTest method verifySplitsValues.

private void verifySplitsValues() {
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    AbiModel abi = splits.abi();
    assertEquals("enable", Boolean.TRUE, abi.enable());
    assertEquals("exclude", ImmutableList.of("abi-exclude-1", "abi-exclude-2"), abi.exclude());
    assertEquals("include", ImmutableList.of("abi-include-1", "abi-include-2"), abi.include());
    assertEquals("universalApk", Boolean.FALSE, abi.universalApk());
    DensityModel density = splits.density();
    assertEquals("auto", Boolean.FALSE, density.auto());
    assertEquals("compatibleScreens", ImmutableList.of("screen1", "screen2"), density.compatibleScreens());
    assertEquals("enable", Boolean.TRUE, density.enable());
    assertEquals("exclude", ImmutableList.of("density-exclude-1", "density-exclude-2"), density.exclude());
    assertEquals("include", ImmutableList.of("density-include-1", "density-include-2"), density.include());
    LanguageModel language = splits.language();
    assertEquals("enable", Boolean.FALSE, language.enable());
    assertEquals("include", ImmutableList.of("language-include-1", "language-include-2"), language.include());
}
Also used : DensityModel(com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel) LanguageModel(com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel) AbiModel(com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel)

Example 4 with AbiModel

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

the class SplitsModelTest method verifyNullSplitsValues.

public void verifyNullSplitsValues() {
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    AbiModel abi = splits.abi();
    assertNull("enable", abi.enable());
    assertNull("exclude", abi.exclude());
    assertNull("include", abi.include());
    assertNull("universalApk", abi.universalApk());
    assertFalse(abi.hasValidPsiElement());
    DensityModel density = splits.density();
    assertNull("auto", density.auto());
    assertNull("compatibleScreens", density.compatibleScreens());
    assertNull("enable", density.enable());
    assertNull("exclude", density.exclude());
    assertNull("include", density.include());
    assertFalse(density.hasValidPsiElement());
    LanguageModel language = splits.language();
    assertNull("enable", language.enable());
    assertNull("include", language.include());
    assertFalse(language.hasValidPsiElement());
}
Also used : DensityModel(com.android.tools.idea.gradle.dsl.model.android.splits.DensityModel) LanguageModel(com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel) AbiModel(com.android.tools.idea.gradle.dsl.model.android.splits.AbiModel)

Example 5 with AbiModel

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

the class SplitsModelTest method testRemoveOnlyElementsInTheList.

public void testRemoveOnlyElementsInTheList() throws Exception {
    String text = "android {\n" + "  splits {\n" + "    abi {\n" + "      exclude 'abi-exclude'\n" + "      include 'abi-include'\n" + "    }\n" + "    density {\n" + "      compatibleScreens 'screen'\n" + "      exclude 'density-exclude'\n" + "      include 'density-include'\n" + "    }\n" + "    language {\n" + "      include 'language-include'\n" + "    }\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    SplitsModel splits = android.splits();
    assertTrue(splits.hasValidPsiElement());
    AbiModel abi = splits.abi();
    assertTrue(splits.hasValidPsiElement());
    assertEquals("exclude", ImmutableList.of("abi-exclude"), abi.exclude());
    assertEquals("include", ImmutableList.of("abi-include"), abi.include());
    DensityModel density = splits.density();
    assertTrue(density.hasValidPsiElement());
    assertEquals("compatibleScreens", ImmutableList.of("screen"), density.compatibleScreens());
    assertEquals("exclude", ImmutableList.of("density-exclude"), density.exclude());
    assertEquals("include", ImmutableList.of("density-include"), density.include());
    LanguageModel language = splits.language();
    assertTrue(language.hasValidPsiElement());
    assertEquals("include", ImmutableList.of("language-include"), language.include());
    abi.removeExclude("abi-exclude");
    abi.removeInclude("abi-include");
    density.removeCompatibleScreen("screen");
    density.removeExclude("density-exclude");
    density.removeInclude("density-include");
    language.removeInclude("language-include");
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    splits = android.splits();
    abi = splits.abi();
    assertNull("exclude", abi.exclude());
    assertNull("include", abi.include());
    assertFalse(abi.hasValidPsiElement());
    density = splits.density();
    assertNull("compatibleScreens", density.compatibleScreens());
    assertNull("exclude", density.exclude());
    assertNull("include", density.include());
    language = splits.language();
    assertNull("include", language.include());
    assertFalse(language.hasValidPsiElement());
    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