use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class SplitsModelTest method testAddResetStatement.
public void testAddResetStatement() throws Exception {
String text = "android {\n" + " splits {\n" + " abi {\n" + " include 'abi-include-1', 'abi-include-2'\n" + " }\n" + " density {\n" + " include 'density-include-1', 'density-include-2'\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
SplitsModel splits = android.splits();
assertEquals("abi-include", ImmutableList.of("abi-include-1", "abi-include-2"), splits.abi().include());
assertEquals("density-include", ImmutableList.of("density-include-1", "density-include-2"), splits.density().include());
splits.abi().addReset();
splits.density().addReset();
applyChangesAndReparse(buildModel);
android = buildModel.android();
assertNotNull(android);
splits = android.splits();
assertNull("abi-include", splits.abi().include());
assertNull("density-include", splits.density().include());
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class TestOptionsModelTest method testRemoveElements.
public void testRemoveElements() throws Exception {
writeToBuildFile(TEST_OPTIONS_TEXT);
verifyTestOptionsValues();
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
TestOptionsModel testOptions = android.testOptions();
assertTrue(testOptions.hasValidPsiElement());
testOptions.removeReportDir();
testOptions.removeResultsDir();
testOptions.unitTests().removeReturnDefaultValues();
applyChangesAndReparse(buildModel);
android = buildModel.android();
assertNotNull(android);
testOptions = android.testOptions();
verifyNullTestOptionsValues();
assertFalse(testOptions.hasValidPsiElement());
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class SourceFileModelTest method testSourceFileRemoveAndApply.
public void testSourceFileRemoveAndApply() throws Exception {
String text = "android {\n" + " sourceSets {\n" + " main {\n" + " manifest {\n" + " srcFile \"mainSource.xml\"\n" + " }\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
verifySourceFile(buildModel, "mainSource.xml");
AndroidModel android = buildModel.android();
assertNotNull(android);
android.sourceSets().get(0).manifest().removeSrcFile();
verifySourceFile(buildModel, null);
applyChangesAndReparse(buildModel);
android = buildModel.android();
assertNotNull(android);
// Whole android block gets removed as it would become empty.
assertFalse(android.hasValidPsiElement());
assertThat(android.sourceSets()).isEmpty();
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class SourceFileModelTest method testSourceFileAddAndApply.
public void testSourceFileAddAndApply() throws Exception {
String text = "android {\n" + " sourceSets {\n" + " main {\n" + " manifest {\n" + " }\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
verifySourceFile(buildModel, null);
AndroidModel android = buildModel.android();
assertNotNull(android);
android.sourceSets().get(0).manifest().setSrcFile("mainSource.xml");
verifySourceFile(buildModel, "mainSource.xml");
applyChangesAndReparse(buildModel);
verifySourceFile(buildModel, "mainSource.xml");
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class SourceFileModelTest method testSourceFileEditAndApply.
public void testSourceFileEditAndApply() throws Exception {
String text = "android {\n" + " sourceSets {\n" + " main {\n" + " manifest {\n" + " srcFile \"mainSource.xml\"\n" + " }\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
verifySourceFile(buildModel, "mainSource.xml");
AndroidModel android = buildModel.android();
assertNotNull(android);
android.sourceSets().get(0).manifest().setSrcFile("otherSource.xml");
verifySourceFile(buildModel, "otherSource.xml");
applyChangesAndReparse(buildModel);
verifySourceFile(buildModel, "otherSource.xml");
}
Aggregations