Fix BuildTypeDsl.initWith.
Xavier Ducrohet [Wed, 6 Feb 2013 03:22:20 +0000 (19:22 -0800)]
It was missing the duplication of the renderscript value.

Changed the test to catch this.

Change-Id: I3fda4fef7e7f7bf4787a5f4c70be8ab5d29c9646

gradle/src/main/groovy/com/android/build/gradle/internal/dsl/BuildTypeDsl.groovy
gradle/src/test/groovy/com/android/build/gradle/internal/dsl/BuildTypeDslTest.groovy

index 1fc1b8f..c1e16dd 100644 (file)
@@ -34,20 +34,20 @@ public class BuildTypeDsl extends BuildType implements Serializable {
     public void init(SigningConfig debugSigningConfig) {
         if (BuilderConstants.DEBUG.equals(getName())) {
             setDebuggable(true)
-            setJniDebugBuild(true)
             setZipAlign(false)
 
             assert debugSigningConfig != null
             setSigningConfig(debugSigningConfig)
         } else if (BuilderConstants.RELEASE.equals(getName())) {
-            setDebuggable(false)
-            setJniDebugBuild(false)
+            // no config needed for now.
         }
     }
 
     public BuildTypeDsl initWith(BuildType that) {
         setDebuggable(that.isDebuggable())
         setJniDebugBuild(that.isJniDebugBuild())
+        setRenderscriptDebugBuild(that.isRenderscriptDebugBuild())
+        setRenderscriptOptimLevel(that.getRenderscriptOptimLevel())
         setPackageNameSuffix(that.getPackageNameSuffix())
         setVersionNameSuffix(that.getVersionNameSuffix())
         setRunProguard(that.isRunProguard())
index 64a9e14..b7c5602 100644 (file)
@@ -43,9 +43,11 @@ public class BuildTypeDslTest extends BaseTest {
         BuildType type = plugin.buildTypes.get(BuilderConstants.DEBUG).buildType
 
         assertTrue(type.isDebuggable());
-        assertTrue(type.isJniDebugBuild());
+        assertFalse(type.isJniDebugBuild());
+        assertFalse(type.isRenderscriptDebugBuild());
         assertNotNull(type.getSigningConfig());
         assertTrue(type.getSigningConfig().isSigningReady());
+        assertFalse(type.isZipAlign());
     }
 
     public void testRelease() {
@@ -64,40 +66,27 @@ public class BuildTypeDslTest extends BaseTest {
 
         assertFalse(type.isDebuggable());
         assertFalse(type.isJniDebugBuild());
+        assertFalse(type.isRenderscriptDebugBuild());
+        assertTrue(type.isZipAlign());
     }
 
     public void testInitWith() {
-        Project project = ProjectBuilder.builder().withProjectDir(
-                new File(testDir, "basic")).build();
-
-        project.apply plugin: 'android'
-
-        project.android {
-            target "android-15"
-
-            buildTypes {
-                debug {
-                    packageNameSuffix = ".debug"
-                    versionNameSuffix = "-DEBUG"
-                }
-
-                foo.initWith(owner.buildTypes.debug)
-                foo {
-                    packageNameSuffix = ".foo"
-                }
-            }
-        }
-
-        AppPlugin plugin = AppPlugin.pluginHolder.plugin
-
-        BuildType debugType = plugin.buildTypes.get(BuilderConstants.DEBUG).buildType
-        BuildType fooType = plugin.buildTypes.get("foo").buildType
-
-        assertEquals(debugType.isDebuggable(),         fooType.isDebuggable())
-        assertEquals(debugType.isJniDebugBuild(),      fooType.isJniDebugBuild())
-        assertEquals(debugType.isZipAlign(),           fooType.isZipAlign())
-        assertEquals(debugType.getVersionNameSuffix(), fooType.getVersionNameSuffix())
-        assertEquals(debugType.getSigningConfig(),     fooType.getSigningConfig())
-        assertNotSame(debugType.getPackageNameSuffix(), fooType.getPackageNameSuffix())
+        BuildTypeDsl object1 = new BuildTypeDsl("foo");
+
+        // change every value from their default.
+        object1.setDebuggable(true)
+        object1.setJniDebugBuild(true)
+        object1.setRenderscriptDebugBuild(true)
+        object1.setRenderscriptOptimLevel(0)
+        object1.setPackageNameSuffix("foo")
+        object1.setVersionNameSuffix("foo")
+        object1.setRunProguard(true)
+        object1.setSigningConfig(new SigningConfigDsl("blah"))
+        object1.setZipAlign(false)
+
+        BuildTypeDsl object2 = new BuildTypeDsl(object1.name)
+        object2.initWith(object1)
+
+        assertEquals(object1, object2)
     }
 }