use of com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField in project android by JetBrains.
the class BuildTypeModelTest method testAddAndApplyListElements.
public void testAddAndApplyListElements() throws Exception {
String text = "android {\n" + " buildTypes {\n" + " xyz {\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
BuildTypeModel buildType = getXyzBuildType(buildModel);
assertNull("buildConfigFields", buildType.buildConfigFields());
assertNull("consumerProguardFiles", buildType.consumerProguardFiles());
assertNull("proguardFiles", buildType.proguardFiles());
assertNull("resValues", buildType.resValues());
buildType.addBuildConfigField(new BuildConfigField("abcd", "efgh", "ijkl")).addConsumerProguardFile("proguard-android.txt").addProguardFile("proguard-android.txt").addResValue(new ResValue("mnop", "qrst", "uvwx"));
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
applyChanges(buildModel);
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
buildModel.reparse();
buildType = getXyzBuildType(buildModel);
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
}
use of com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField in project android by JetBrains.
the class BuildTypeModelTest method testAddToAndApplyListElements.
public void testAddToAndApplyListElements() throws Exception {
String text = "android {\n" + " buildTypes {\n" + " xyz {\n" + " buildConfigField \"abcd\", \"efgh\", \"ijkl\"\n" + " consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " resValue \"mnop\", \"qrst\", \"uvwx\"\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
BuildTypeModel buildType = getXyzBuildType(buildModel);
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
buildType.addBuildConfigField(new BuildConfigField("cdef", "ghij", "klmn")).addConsumerProguardFile("proguard-android-1.txt").addProguardFile("proguard-android-1.txt").addResValue(new ResValue("opqr", "stuv", "wxyz"));
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl"), new BuildConfigField("cdef", "ghij", "klmn")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx"), new ResValue("opqr", "stuv", "wxyz")), buildType.resValues());
applyChanges(buildModel);
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl"), new BuildConfigField("cdef", "ghij", "klmn")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx"), new ResValue("opqr", "stuv", "wxyz")), buildType.resValues());
buildModel.reparse();
buildType = getXyzBuildType(buildModel);
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl"), new BuildConfigField("cdef", "ghij", "klmn")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx"), new ResValue("opqr", "stuv", "wxyz")), buildType.resValues());
}
use of com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField in project android by JetBrains.
the class BuildTypeModelTest method testReplaceAndResetListElements.
public void testReplaceAndResetListElements() throws Exception {
String text = "android {\n" + " buildTypes {\n" + " xyz {\n" + " buildConfigField \"abcd\", \"efgh\", \"ijkl\"\n" + " consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " resValue \"mnop\", \"qrst\", \"uvwx\"\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
BuildTypeModel buildType = getXyzBuildType(buildModel);
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
buildType.replaceBuildConfigField(new BuildConfigField("abcd", "efgh", "ijkl"), new BuildConfigField("abcd", "mnop", "qrst")).replaceConsumerProguardFile("proguard-android.txt", "proguard-android-1.txt").replaceProguardFile("proguard-android.txt", "proguard-android-1.txt").replaceResValue(new ResValue("mnop", "qrst", "uvwx"), new ResValue("mnop", "efgh", "ijkl"));
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "mnop", "qrst")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android-1.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android-1.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "efgh", "ijkl")), buildType.resValues());
buildModel.resetState();
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
}
use of com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField in project android by JetBrains.
the class BuildTypeModelTest method testRemoveAndResetElements.
public void testRemoveAndResetElements() throws Exception {
String text = "android {\n" + " buildTypes {\n" + " xyz {\n" + " applicationIdSuffix \"mySuffix\"\n" + " buildConfigField \"abcd\", \"efgh\", \"ijkl\"\n" + " consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " debuggable true\n" + " embedMicroApp true\n" + " jniDebuggable true\n" + " manifestPlaceholders activityLabel1:\"defaultName1\", activityLabel2:\"defaultName2\"\n" + " minifyEnabled true\n" + " multiDexEnabled true\n" + " proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " pseudoLocalesEnabled true\n" + " renderscriptDebuggable true\n" + " renderscriptOptimLevel 1\n" + " resValue \"mnop\", \"qrst\", \"uvwx\"\n" + " shrinkResources true\n" + " testCoverageEnabled true\n" + " useJack true\n" + " versionNameSuffix \"abc\"\n" + " zipAlignEnabled true\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
BuildTypeModel buildType = getXyzBuildType(buildModel);
assertEquals("applicationIdSuffix", "mySuffix", buildType.applicationIdSuffix());
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("debuggable", Boolean.TRUE, buildType.debuggable());
assertEquals("embedMicroApp", Boolean.TRUE, buildType.embedMicroApp());
assertEquals("jniDebuggable", Boolean.TRUE, buildType.jniDebuggable());
assertEquals("manifestPlaceholders", ImmutableMap.of("activityLabel1", "defaultName1", "activityLabel2", "defaultName2"), buildType.manifestPlaceholders());
assertEquals("minifyEnabled", Boolean.TRUE, buildType.minifyEnabled());
assertEquals("multiDexEnabled", Boolean.TRUE, buildType.multiDexEnabled());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("pseudoLocalesEnabled", Boolean.TRUE, buildType.pseudoLocalesEnabled());
assertEquals("renderscriptDebuggable", Boolean.TRUE, buildType.renderscriptDebuggable());
assertEquals("renderscriptOptimLevel", Integer.valueOf(1), buildType.renderscriptOptimLevel());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
assertEquals("shrinkResources", Boolean.TRUE, buildType.shrinkResources());
assertEquals("testCoverageEnabled", Boolean.TRUE, buildType.testCoverageEnabled());
assertEquals("useJack", Boolean.TRUE, buildType.useJack());
assertEquals("versionNameSuffix", "abc", buildType.versionNameSuffix());
assertEquals("zipAlignEnabled", Boolean.TRUE, buildType.zipAlignEnabled());
buildType.removeApplicationIdSuffix().removeAllBuildConfigFields().removeAllConsumerProguardFiles().removeDebuggable().removeEmbedMicroApp().removeJniDebuggable().removeAllManifestPlaceholders().removeMinifyEnabled().removeMultiDexEnabled().removeAllProguardFiles().removePseudoLocalesEnabled().removeRenderscriptDebuggable().removeRenderscriptOptimLevel().removeAllResValues().removeShrinkResources().removeTestCoverageEnabled().removeUseJack().removeVersionNameSuffix().removeZipAlignEnabled();
assertNull("applicationIdSuffix", buildType.applicationIdSuffix());
assertNull("buildConfigFields", buildType.buildConfigFields());
assertNull("consumerProguardFiles", buildType.consumerProguardFiles());
assertNull("debuggable", buildType.debuggable());
assertNull("embedMicroApp", buildType.embedMicroApp());
assertNull("jniDebuggable", buildType.jniDebuggable());
assertNull("manifestPlaceholders", buildType.manifestPlaceholders());
assertNull("minifyEnabled", buildType.minifyEnabled());
assertNull("multiDexEnabled", buildType.multiDexEnabled());
assertNull("proguardFiles", buildType.proguardFiles());
assertNull("pseudoLocalesEnabled", buildType.pseudoLocalesEnabled());
assertNull("renderscriptDebuggable", buildType.renderscriptDebuggable());
assertNull("renderscriptOptimLevel", buildType.renderscriptOptimLevel());
assertNull("resValues", buildType.resValues());
assertNull("shrinkResources", buildType.shrinkResources());
assertNull("testCoverageEnabled", buildType.testCoverageEnabled());
assertNull("useJack", buildType.useJack());
assertNull("versionNameSuffix", buildType.versionNameSuffix());
assertNull("zipAlignEnabled", buildType.zipAlignEnabled());
buildModel.resetState();
assertEquals("applicationIdSuffix", "mySuffix", buildType.applicationIdSuffix());
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("debuggable", Boolean.TRUE, buildType.debuggable());
assertEquals("embedMicroApp", Boolean.TRUE, buildType.embedMicroApp());
assertEquals("jniDebuggable", Boolean.TRUE, buildType.jniDebuggable());
assertEquals("manifestPlaceholders", ImmutableMap.of("activityLabel1", "defaultName1", "activityLabel2", "defaultName2"), buildType.manifestPlaceholders());
assertEquals("minifyEnabled", Boolean.TRUE, buildType.minifyEnabled());
assertEquals("multiDexEnabled", Boolean.TRUE, buildType.multiDexEnabled());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("pseudoLocalesEnabled", Boolean.TRUE, buildType.pseudoLocalesEnabled());
assertEquals("renderscriptDebuggable", Boolean.TRUE, buildType.renderscriptDebuggable());
assertEquals("renderscriptOptimLevel", Integer.valueOf(1), buildType.renderscriptOptimLevel());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
assertEquals("shrinkResources", Boolean.TRUE, buildType.shrinkResources());
assertEquals("testCoverageEnabled", Boolean.TRUE, buildType.testCoverageEnabled());
assertEquals("useJack", Boolean.TRUE, buildType.useJack());
assertEquals("versionNameSuffix", "abc", buildType.versionNameSuffix());
assertEquals("zipAlignEnabled", Boolean.TRUE, buildType.zipAlignEnabled());
}
use of com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField in project android by JetBrains.
the class BuildTypeModelTest method testRemoveFromAndResetListElements.
public void testRemoveFromAndResetListElements() throws Exception {
String text = "android {\n" + " buildTypes {\n" + " xyz {\n" + " buildConfigField \"abcd\", \"efgh\", \"ijkl\"\n" + " buildConfigField \"cdef\", \"ghij\", \"klmn\"\n" + " consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + " resValue \"mnop\", \"qrst\", \"uvwx\"\n" + " resValue \"opqr\", \"stuv\", \"wxyz\"\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
BuildTypeModel buildType = getXyzBuildType(buildModel);
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl"), new BuildConfigField("cdef", "ghij", "klmn")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx"), new ResValue("opqr", "stuv", "wxyz")), buildType.resValues());
buildType.removeBuildConfigField(new BuildConfigField("abcd", "efgh", "ijkl")).removeConsumerProguardFile("proguard-rules.pro").removeProguardFile("proguard-rules.pro").removeResValue(new ResValue("opqr", "stuv", "wxyz"));
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("cdef", "ghij", "klmn")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx")), buildType.resValues());
buildModel.resetState();
assertEquals("buildConfigFields", ImmutableList.of(new BuildConfigField("abcd", "efgh", "ijkl"), new BuildConfigField("cdef", "ghij", "klmn")), buildType.buildConfigFields());
assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.consumerProguardFiles());
assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), buildType.proguardFiles());
assertEquals("resValues", ImmutableList.of(new ResValue("mnop", "qrst", "uvwx"), new ResValue("opqr", "stuv", "wxyz")), buildType.resValues());
}
Aggregations