Search in sources :

Example 16 with ResValue

use of com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue 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());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ResValue(com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue) BuildConfigField(com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField)

Example 17 with ResValue

use of com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue in project android by JetBrains.

the class ProductFlavorModelTest method testRemoveAndResetElements.

public void testRemoveAndResetElements() throws Exception {
    String text = "android {\n" + "  defaultConfig {\n" + "    applicationId \"com.example.myapplication\"\n" + "    consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    dimension \"abcd\"\n" + "    manifestPlaceholders activityLabel1:\"defaultName1\", activityLabel2:\"defaultName2\"\n" + "    maxSdkVersion 23\n" + "    minSdkVersion 15\n" + "    multiDexEnabled true\n" + "    proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    resConfigs \"abcd\", \"efgh\"\n" + "    resValue \"abcd\", \"efgh\", \"ijkl\"\n" + "    targetSdkVersion 22 \n" + "    testApplicationId \"com.example.myapplication.test\"\n" + "    testFunctionalTest false\n" + "    testHandleProfiling true\n" + "    testInstrumentationRunner \"abcd\"\n" + "    testInstrumentationRunnerArguments size:\"medium\", foo:\"bar\"\n" + "    useJack false\n" + "    versionCode 1\n" + "    versionName \"1.0\"\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    ProductFlavorModel defaultConfig = android.defaultConfig();
    assertEquals("applicationId", "com.example.myapplication", defaultConfig.applicationId());
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("dimension", "abcd", defaultConfig.dimension());
    assertEquals("manifestPlaceholders", ImmutableMap.of("activityLabel1", "defaultName1", "activityLabel2", "defaultName2"), defaultConfig.manifestPlaceholders());
    assertEquals("maxSdkVersion", Integer.valueOf(23), defaultConfig.maxSdkVersion());
    assertEquals("minSdkVersion", "15", defaultConfig.minSdkVersion());
    assertEquals("multiDexEnabled", Boolean.TRUE, defaultConfig.multiDexEnabled());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl")), defaultConfig.resValues());
    assertEquals("targetSdkVersion", "22", defaultConfig.targetSdkVersion());
    assertEquals("testApplicationId", "com.example.myapplication.test", defaultConfig.testApplicationId());
    assertEquals("testFunctionalTest", Boolean.FALSE, defaultConfig.testFunctionalTest());
    assertEquals("testHandleProfiling", Boolean.TRUE, defaultConfig.testHandleProfiling());
    assertEquals("testInstrumentationRunner", "abcd", defaultConfig.testInstrumentationRunner());
    assertEquals("testInstrumentationRunnerArguments", ImmutableMap.of("size", "medium", "foo", "bar"), defaultConfig.testInstrumentationRunnerArguments());
    assertEquals("useJack", Boolean.FALSE, defaultConfig.useJack());
    assertEquals("versionCode", "1", defaultConfig.versionCode());
    assertEquals("versionName", "1.0", defaultConfig.versionName());
    defaultConfig.removeApplicationId();
    defaultConfig.removeAllConsumerProguardFiles();
    defaultConfig.removeDimension();
    defaultConfig.removeAllManifestPlaceholders();
    defaultConfig.removeMaxSdkVersion();
    defaultConfig.removeMinSdkVersion();
    defaultConfig.removeMultiDexEnabled();
    defaultConfig.removeAllProguardFiles();
    defaultConfig.removeAllResConfigs();
    defaultConfig.removeAllResValues();
    defaultConfig.removeTargetSdkVersion();
    defaultConfig.removeTestApplicationId();
    defaultConfig.removeTestFunctionalTest();
    defaultConfig.removeTestHandleProfiling();
    defaultConfig.removeTestInstrumentationRunner();
    defaultConfig.removeAllTestInstrumentationRunnerArguments();
    defaultConfig.removeUseJack();
    defaultConfig.removeVersionCode();
    defaultConfig.removeVersionName();
    assertNull("applicationId", defaultConfig.applicationId());
    assertNull("consumerProguardFiles", defaultConfig.consumerProguardFiles());
    assertNull("dimension", defaultConfig.dimension());
    assertNull("manifestPlaceholders", defaultConfig.manifestPlaceholders());
    assertNull("maxSdkVersion", defaultConfig.maxSdkVersion());
    assertNull("minSdkVersion", defaultConfig.minSdkVersion());
    assertNull("multiDexEnabled", defaultConfig.multiDexEnabled());
    assertNull("proguardFiles", defaultConfig.proguardFiles());
    assertNull("resConfigs", defaultConfig.resConfigs());
    assertNull("resValues", defaultConfig.resValues());
    assertNull("targetSdkVersion", defaultConfig.targetSdkVersion());
    assertNull("testApplicationId", defaultConfig.testApplicationId());
    assertNull("testFunctionalTest", defaultConfig.testFunctionalTest());
    assertNull("testHandleProfiling", defaultConfig.testHandleProfiling());
    assertNull("testInstrumentationRunner", defaultConfig.testInstrumentationRunner());
    assertNull("testInstrumentationRunnerArguments", defaultConfig.testInstrumentationRunnerArguments());
    assertNull("useJack", defaultConfig.useJack());
    assertNull("versionCode", defaultConfig.versionCode());
    assertNull("versionName", defaultConfig.versionName());
    buildModel.resetState();
    assertEquals("applicationId", "com.example.myapplication", defaultConfig.applicationId());
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("dimension", "abcd", defaultConfig.dimension());
    assertEquals("manifestPlaceholders", ImmutableMap.of("activityLabel1", "defaultName1", "activityLabel2", "defaultName2"), defaultConfig.manifestPlaceholders());
    assertEquals("maxSdkVersion", Integer.valueOf(23), defaultConfig.maxSdkVersion());
    assertEquals("minSdkVersion", "15", defaultConfig.minSdkVersion());
    assertEquals("multiDexEnabled", Boolean.TRUE, defaultConfig.multiDexEnabled());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl")), defaultConfig.resValues());
    assertEquals("targetSdkVersion", "22", defaultConfig.targetSdkVersion());
    assertEquals("testApplicationId", "com.example.myapplication.test", defaultConfig.testApplicationId());
    assertEquals("testFunctionalTest", Boolean.FALSE, defaultConfig.testFunctionalTest());
    assertEquals("testHandleProfiling", Boolean.TRUE, defaultConfig.testHandleProfiling());
    assertEquals("testInstrumentationRunner", "abcd", defaultConfig.testInstrumentationRunner());
    assertEquals("testInstrumentationRunnerArguments", ImmutableMap.of("size", "medium", "foo", "bar"), defaultConfig.testInstrumentationRunnerArguments());
    assertEquals("useJack", Boolean.FALSE, defaultConfig.useJack());
    assertEquals("versionCode", "1", defaultConfig.versionCode());
    assertEquals("versionName", "1.0", defaultConfig.versionName());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ResValue(com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue)

Example 18 with ResValue

use of com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue in project android by JetBrains.

the class ProductFlavorModelTest method testRemoveAndApplyElements.

public void testRemoveAndApplyElements() throws Exception {
    String text = "android {\n" + "  defaultConfig {\n" + "    applicationId \"com.example.myapplication\"\n" + "    consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    dimension \"abcd\"\n" + "    manifestPlaceholders activityLabel1:\"defaultName1\", activityLabel2:\"defaultName2\"\n" + "    maxSdkVersion 23\n" + "    minSdkVersion 15\n" + "    multiDexEnabled true\n" + "    proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    resConfigs \"abcd\", \"efgh\"\n" + "    resValue \"abcd\", \"efgh\", \"ijkl\"\n" + "    targetSdkVersion 22 \n" + "    testApplicationId \"com.example.myapplication.test\"\n" + "    testFunctionalTest false\n" + "    testHandleProfiling true\n" + "    testInstrumentationRunner \"abcd\"\n" + "    testInstrumentationRunnerArguments size:\"medium\", foo:\"bar\"\n" + "    useJack false\n" + "    versionCode 1\n" + "    versionName \"1.0\"\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    assertTrue(android.hasValidPsiElement());
    ProductFlavorModel defaultConfig = android.defaultConfig();
    assertTrue(defaultConfig.hasValidPsiElement());
    assertEquals("applicationId", "com.example.myapplication", defaultConfig.applicationId());
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("dimension", "abcd", defaultConfig.dimension());
    assertEquals("manifestPlaceholders", ImmutableMap.of("activityLabel1", "defaultName1", "activityLabel2", "defaultName2"), defaultConfig.manifestPlaceholders());
    assertEquals("maxSdkVersion", Integer.valueOf(23), defaultConfig.maxSdkVersion());
    assertEquals("minSdkVersion", "15", defaultConfig.minSdkVersion());
    assertEquals("multiDexEnabled", Boolean.TRUE, defaultConfig.multiDexEnabled());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl")), defaultConfig.resValues());
    assertEquals("targetSdkVersion", "22", defaultConfig.targetSdkVersion());
    assertEquals("testApplicationId", "com.example.myapplication.test", defaultConfig.testApplicationId());
    assertEquals("testFunctionalTest", Boolean.FALSE, defaultConfig.testFunctionalTest());
    assertEquals("testHandleProfiling", Boolean.TRUE, defaultConfig.testHandleProfiling());
    assertEquals("testInstrumentationRunner", "abcd", defaultConfig.testInstrumentationRunner());
    assertEquals("testInstrumentationRunnerArguments", ImmutableMap.of("size", "medium", "foo", "bar"), defaultConfig.testInstrumentationRunnerArguments());
    assertEquals("useJack", Boolean.FALSE, defaultConfig.useJack());
    assertEquals("versionCode", "1", defaultConfig.versionCode());
    assertEquals("versionName", "1.0", defaultConfig.versionName());
    defaultConfig.removeApplicationId();
    defaultConfig.removeAllConsumerProguardFiles();
    defaultConfig.removeDimension();
    defaultConfig.removeAllManifestPlaceholders();
    defaultConfig.removeMaxSdkVersion();
    defaultConfig.removeMinSdkVersion();
    defaultConfig.removeMultiDexEnabled();
    defaultConfig.removeAllProguardFiles();
    defaultConfig.removeAllResConfigs();
    defaultConfig.removeAllResValues();
    defaultConfig.removeTargetSdkVersion();
    defaultConfig.removeTestApplicationId();
    defaultConfig.removeTestFunctionalTest();
    defaultConfig.removeTestHandleProfiling();
    defaultConfig.removeTestInstrumentationRunner();
    defaultConfig.removeAllTestInstrumentationRunnerArguments();
    defaultConfig.removeUseJack();
    defaultConfig.removeVersionCode();
    defaultConfig.removeVersionName();
    assertTrue(android.hasValidPsiElement());
    assertTrue(defaultConfig.hasValidPsiElement());
    assertNull("applicationId", defaultConfig.applicationId());
    assertNull("consumerProguardFiles", defaultConfig.consumerProguardFiles());
    assertNull("dimension", defaultConfig.dimension());
    assertNull("manifestPlaceholders", defaultConfig.manifestPlaceholders());
    assertNull("maxSdkVersion", defaultConfig.maxSdkVersion());
    assertNull("minSdkVersion", defaultConfig.minSdkVersion());
    assertNull("multiDexEnabled", defaultConfig.multiDexEnabled());
    assertNull("proguardFiles", defaultConfig.proguardFiles());
    assertNull("resConfigs", defaultConfig.resConfigs());
    assertNull("resValues", defaultConfig.resValues());
    assertNull("targetSdkVersion", defaultConfig.targetSdkVersion());
    assertNull("testApplicationId", defaultConfig.testApplicationId());
    assertNull("testFunctionalTest", defaultConfig.testFunctionalTest());
    assertNull("testHandleProfiling", defaultConfig.testHandleProfiling());
    assertNull("testInstrumentationRunner", defaultConfig.testInstrumentationRunner());
    assertNull("testInstrumentationRunnerArguments", defaultConfig.testInstrumentationRunnerArguments());
    assertNull("useJack", defaultConfig.useJack());
    assertNull("versionCode", defaultConfig.versionCode());
    assertNull("versionName", defaultConfig.versionName());
    applyChanges(buildModel);
    assertFalse(android.hasValidPsiElement());
    assertFalse(android.defaultConfig().hasValidPsiElement());
    assertNull("applicationId", defaultConfig.applicationId());
    assertNull("consumerProguardFiles", defaultConfig.consumerProguardFiles());
    assertNull("dimension", defaultConfig.dimension());
    assertNull("manifestPlaceholders", defaultConfig.manifestPlaceholders());
    assertNull("maxSdkVersion", defaultConfig.maxSdkVersion());
    assertNull("minSdkVersion", defaultConfig.minSdkVersion());
    assertNull("multiDexEnabled", defaultConfig.multiDexEnabled());
    assertNull("proguardFiles", defaultConfig.proguardFiles());
    assertNull("resConfigs", defaultConfig.resConfigs());
    assertNull("resValues", defaultConfig.resValues());
    assertNull("targetSdkVersion", defaultConfig.targetSdkVersion());
    assertNull("testApplicationId", defaultConfig.testApplicationId());
    assertNull("testFunctionalTest", defaultConfig.testFunctionalTest());
    assertNull("testHandleProfiling", defaultConfig.testHandleProfiling());
    assertNull("testInstrumentationRunner", defaultConfig.testInstrumentationRunner());
    assertNull("testInstrumentationRunnerArguments", defaultConfig.testInstrumentationRunnerArguments());
    assertNull("useJack", defaultConfig.useJack());
    assertNull("versionCode", defaultConfig.versionCode());
    assertNull("versionName", defaultConfig.versionName());
    buildModel.reparse();
    android = buildModel.android();
    assertNotNull(android);
    assertFalse(android.hasValidPsiElement());
    assertFalse(android.defaultConfig().hasValidPsiElement());
    assertNull("applicationId", defaultConfig.applicationId());
    assertNull("consumerProguardFiles", defaultConfig.consumerProguardFiles());
    assertNull("dimension", defaultConfig.dimension());
    assertNull("manifestPlaceholders", defaultConfig.manifestPlaceholders());
    assertNull("maxSdkVersion", defaultConfig.maxSdkVersion());
    assertNull("minSdkVersion", defaultConfig.minSdkVersion());
    assertNull("multiDexEnabled", defaultConfig.multiDexEnabled());
    assertNull("proguardFiles", defaultConfig.proguardFiles());
    assertNull("resConfigs", defaultConfig.resConfigs());
    assertNull("resValues", defaultConfig.resValues());
    assertNull("targetSdkVersion", defaultConfig.targetSdkVersion());
    assertNull("testApplicationId", defaultConfig.testApplicationId());
    assertNull("testFunctionalTest", defaultConfig.testFunctionalTest());
    assertNull("testHandleProfiling", defaultConfig.testHandleProfiling());
    assertNull("testInstrumentationRunner", defaultConfig.testInstrumentationRunner());
    assertNull("testInstrumentationRunnerArguments", defaultConfig.testInstrumentationRunnerArguments());
    assertNull("useJack", defaultConfig.useJack());
    assertNull("versionCode", defaultConfig.versionCode());
    assertNull("versionName", defaultConfig.versionName());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ResValue(com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue)

Example 19 with ResValue

use of com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue in project android by JetBrains.

the class ProductFlavorModelTest method testAddToAndResetListElements.

public void testAddToAndResetListElements() throws Exception {
    String text = "android {\n" + "  defaultConfig {\n" + "    consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    resConfigs \"abcd\", \"efgh\"\n" + "    resValue \"abcd\", \"efgh\", \"ijkl\"\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    ProductFlavorModel defaultConfig = android.defaultConfig();
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl")), defaultConfig.resValues());
    defaultConfig.addConsumerProguardFile("proguard-android-1.txt").addProguardFile("proguard-android-1.txt").addResConfig("xyz").addResValue(new ResValue("mnop", "qrst", "uvwx"));
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), defaultConfig.consumerProguardFiles());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro", "proguard-android-1.txt"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh", "xyz"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl"), new ResValue("mnop", "qrst", "uvwx")), defaultConfig.resValues());
    buildModel.resetState();
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl")), defaultConfig.resValues());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ResValue(com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue)

Example 20 with ResValue

use of com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue in project android by JetBrains.

the class ProductFlavorModelTest method testReplaceAndResetListElements.

public void testReplaceAndResetListElements() throws Exception {
    String text = "android {\n" + "  defaultConfig {\n" + "    consumerProguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    proguardFiles 'proguard-android.txt', 'proguard-rules.pro'\n" + "    resConfigs \"abcd\", \"efgh\"\n" + "    resValue \"abcd\", \"efgh\", \"ijkl\"\n" + "  }\n" + "}";
    writeToBuildFile(text);
    GradleBuildModel buildModel = getGradleBuildModel();
    AndroidModel android = buildModel.android();
    assertNotNull(android);
    ProductFlavorModel defaultConfig = android.defaultConfig();
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl")), defaultConfig.resValues());
    defaultConfig.replaceConsumerProguardFile("proguard-android.txt", "proguard-android-1.txt").replaceProguardFile("proguard-android.txt", "proguard-android-1.txt").replaceResConfig("abcd", "xyz").replaceResValue(new ResValue("abcd", "efgh", "ijkl"), new ResValue("abcd", "mnop", "qrst"));
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android-1.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android-1.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("xyz", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "mnop", "qrst")), defaultConfig.resValues());
    buildModel.resetState();
    assertEquals("consumerProguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.consumerProguardFiles());
    assertEquals("proguardFiles", ImmutableList.of("proguard-android.txt", "proguard-rules.pro"), defaultConfig.proguardFiles());
    assertEquals("resConfigs", ImmutableList.of("abcd", "efgh"), defaultConfig.resConfigs());
    assertEquals("resValues", ImmutableList.of(new ResValue("abcd", "efgh", "ijkl")), defaultConfig.resValues());
}
Also used : GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ResValue(com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue)

Aggregations

GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)20 ResValue (com.android.tools.idea.gradle.dsl.model.android.AbstractFlavorTypeModel.ResValue)20 BuildConfigField (com.android.tools.idea.gradle.dsl.model.android.BuildTypeModel.BuildConfigField)10