use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class AndroidModelTest method testRemoveAndApplySigningConfigBlock.
public void testRemoveAndApplySigningConfigBlock() throws Exception {
String text = "android { \n" + " signingConfigs { \n" + " config1 { \n" + " } \n" + " config2 {" + " } \n" + " } \n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
List<SigningConfigModel> signingConfigs = android.signingConfigs();
assertThat(signingConfigs).hasSize(2);
assertEquals("signingConfigs", "config1", signingConfigs.get(0).name());
assertEquals("signingConfigs", "config2", signingConfigs.get(1).name());
android.removeSigningConfig("config2");
signingConfigs = android.signingConfigs();
assertThat(signingConfigs).hasSize(1);
assertEquals("signingConfigs", "config1", signingConfigs.get(0).name());
applyChanges(buildModel);
signingConfigs = android.signingConfigs();
assertThat(signingConfigs).hasSize(1);
assertEquals("signingConfigs", "config1", signingConfigs.get(0).name());
buildModel.reparse();
android = buildModel.android();
assertNotNull(android);
signingConfigs = android.signingConfigs();
assertThat(signingConfigs).hasSize(1);
assertEquals("signingConfigs", "config1", signingConfigs.get(0).name());
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class AndroidModelTest method testRemoveAndApplySourceSetBlock.
public void testRemoveAndApplySourceSetBlock() throws Exception {
String text = "android { \n" + " sourceSets { \n" + " set1 { \n" + " } \n" + " set2 {" + " } \n" + " } \n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
List<SourceSetModel> sourceSets = android.sourceSets();
assertThat(sourceSets).hasSize(2);
assertEquals("sourceSets", "set1", sourceSets.get(0).name());
assertEquals("sourceSets", "set2", sourceSets.get(1).name());
android.removeSourceSet("set2");
sourceSets = android.sourceSets();
assertThat(sourceSets).hasSize(1);
assertEquals("sourceSets", "set1", sourceSets.get(0).name());
applyChanges(buildModel);
sourceSets = android.sourceSets();
assertThat(sourceSets).hasSize(1);
assertEquals("sourceSets", "set1", sourceSets.get(0).name());
buildModel.reparse();
android = buildModel.android();
assertNotNull(android);
sourceSets = android.sourceSets();
assertThat(sourceSets).hasSize(1);
assertEquals("sourceSets", "set1", sourceSets.get(0).name());
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class AndroidModelTest method testRemoveAndApplyBuildTypeBlock.
public void testRemoveAndApplyBuildTypeBlock() throws Exception {
String text = "android { \n" + " buildTypes { \n" + " type1 { \n" + " } \n" + " type2 { \n" + " } \n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
List<BuildTypeModel> buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(2);
assertEquals("buildTypes", "type1", buildTypes.get(0).name());
assertEquals("buildTypes", "type2", buildTypes.get(1).name());
android.removeBuildType("type1");
buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(1);
assertEquals("buildTypes", "type2", buildTypes.get(0).name());
applyChanges(buildModel);
buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(1);
assertEquals("buildTypes", "type2", buildTypes.get(0).name());
buildModel.reparse();
android = buildModel.android();
assertNotNull(android);
buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(1);
assertEquals("buildTypes", "type2", buildTypes.get(0).name());
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class AndroidModelTest method testAddAndResetProductFlavorBlock.
public void testAddAndResetProductFlavorBlock() throws Exception {
String text = "android { \n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
assertThat(android.productFlavors()).isEmpty();
android.addProductFlavor("flavor");
List<ProductFlavorModel> productFlavors = android.productFlavors();
assertThat(productFlavors).hasSize(1);
assertEquals("productFlavors", "flavor", productFlavors.get(0).name());
buildModel.resetState();
assertThat(android.productFlavors()).isEmpty();
}
use of com.android.tools.idea.gradle.dsl.model.GradleBuildModel in project android by JetBrains.
the class AndroidModelTest method testAddAndApplyBuildTypeBlock.
public void testAddAndApplyBuildTypeBlock() throws Exception {
String text = "android { \n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
android.addBuildType("type");
List<BuildTypeModel> buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(1);
BuildTypeModel buildType = buildTypes.get(0);
buildType.setApplicationIdSuffix("mySuffix");
buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(1);
buildType = buildTypes.get(0);
assertEquals("buildTypes", "type", buildType.name());
assertEquals("buildTypes", "mySuffix", buildType.applicationIdSuffix());
applyChanges(buildModel);
buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(1);
buildType = buildTypes.get(0);
assertEquals("buildTypes", "type", buildType.name());
assertEquals("buildTypes", "mySuffix", buildType.applicationIdSuffix());
buildModel.reparse();
android = buildModel.android();
assertNotNull(android);
buildTypes = android.buildTypes();
assertThat(buildTypes).hasSize(1);
buildType = buildTypes.get(0);
assertEquals("buildTypes", "type", buildType.name());
assertEquals("buildTypes", "mySuffix", buildType.applicationIdSuffix());
}
Aggregations