aboutsummaryrefslogtreecommitdiff
path: root/gradle/src
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-12-07 10:52:22 -0800
committerXavier Ducrohet <xav@android.com>2012-12-07 12:34:19 -0800
commit3348fe7cb5eadf38797cc39efae4ff08f04a76c9 (patch)
tree0b1298962533463bcfea9cc60291f05dc02bd80b /gradle/src
parentd2a32548edd18fbfe4eb3f0a0311a2c460678c79 (diff)
downloadbuild-3348fe7cb5eadf38797cc39efae4ff08f04a76c9.tar.gz
Two simple test projects to detect overlay issues.
Also add support to build them during the plugin integration tests and check the output. Change-Id: I882f47f4c79d1b44c3e95b2df0f044d91508a3eb
Diffstat (limited to 'gradle/src')
-rw-r--r--gradle/src/integration-test/groovy/com/android/build/gradle/ProjectTest.groovy36
-rw-r--r--gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy1
2 files changed, 35 insertions, 2 deletions
diff --git a/gradle/src/integration-test/groovy/com/android/build/gradle/ProjectTest.groovy b/gradle/src/integration-test/groovy/com/android/build/gradle/ProjectTest.groovy
index 59e09e4..51d585f 100644
--- a/gradle/src/integration-test/groovy/com/android/build/gradle/ProjectTest.groovy
+++ b/gradle/src/integration-test/groovy/com/android/build/gradle/ProjectTest.groovy
@@ -23,6 +23,9 @@ import com.google.common.collect.Sets
import org.gradle.tooling.GradleConnector
import org.gradle.tooling.ProjectConnection
+import javax.imageio.ImageIO
+import java.awt.image.BufferedImage
+
/**
*/
class ProjectTest extends BaseTest {
@@ -81,6 +84,24 @@ class ProjectTest extends BaseTest {
buildProject("multiproject")
}
+ void testOverlay1() {
+ File project = buildProject("overlay1")
+ File drawableOutput = new File(project, "build/res/debug/drawable" )
+
+ checkImageColor(drawableOutput, "no_overlay.png", (int) 0xFF00FF00)
+ checkImageColor(drawableOutput, "type_overlay.png", (int) 0xFF00FF00)
+ }
+
+ void testOverlay2() {
+ File project = buildProject("overlay2")
+ File drawableOutput = new File(project, "build/res/one/debug/drawable" )
+
+ checkImageColor(drawableOutput, "no_overlay.png", (int) 0xFF00FF00)
+ checkImageColor(drawableOutput, "type_overlay.png", (int) 0xFF00FF00)
+ checkImageColor(drawableOutput, "flavor_overlay.png", (int) 0xFF00FF00)
+ checkImageColor(drawableOutput, "type_flavor_overlay.png", (int) 0xFF00FF00)
+ }
+
void testRepo() {
// this is not an actual project, but we add it so that the catch-all below doesn't
// try to build it again
@@ -114,11 +135,13 @@ class ProjectTest extends BaseTest {
}
}
- private void buildProject(String name) {
+ private File buildProject(String name) {
File project = new File(testDir, name)
builtProjects.add(name)
buildProject(project, "clean", "assemble")
+
+ return project;
}
private void buildProject(File project, String... tasks) {
@@ -148,4 +171,15 @@ class ProjectTest extends BaseTest {
return (File) localProp.file
}
+
+ private void checkImageColor(File folder, String fileName, int expectedColor) {
+ File f = new File(folder, fileName)
+ assertTrue("File '" + f.getAbsolutePath() + "' does not exist.", f.isFile())
+
+ BufferedImage image = ImageIO.read(f)
+ int rgb = image.getRGB(0, 0)
+ assertEquals(String.format("Expected: 0x%08X, actual: 0x%08X for file %s",
+ expectedColor, rgb, f),
+ expectedColor, rgb);
+ }
}
diff --git a/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy b/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy
index c83fc08..c35e5ef 100644
--- a/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy
+++ b/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy
@@ -45,7 +45,6 @@ public abstract class BaseTest extends TestCase {
fail("Fail to get tests folder")
}
-
/**
* Returns the root folder for the tests projects.
*/