Search in sources :

Example 1 with DensityModel

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

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

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

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

Example 5 with DensityModel

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

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