use of com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel 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());
}
use of com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel 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());
}
use of com.android.tools.idea.gradle.dsl.model.android.splits.LanguageModel 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());
}
Aggregations