From fc43ec2470075c1652e4e66b72a13526acbfd5e2 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Thu, 24 Mar 2016 08:14:20 -0400 Subject: [PATCH] unit test to check image color of 9patch --- .../brut/androlib/BuildAndDecodeTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index b2144c81..07917fdc 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -20,6 +20,8 @@ import brut.androlib.res.util.ExtFile; import brut.common.BrutException; import brut.directory.FileDirectory; import brut.util.OS; + +import java.awt.image.BufferedImage; import java.io.*; import java.util.Map; import java.util.Set; @@ -30,6 +32,8 @@ import org.junit.*; import static org.junit.Assert.*; import org.xml.sax.SAXException; +import javax.imageio.ImageIO; + /** * @author Ryszard Wiśniewski */ @@ -309,6 +313,27 @@ public class BuildAndDecodeTest { compareResFolder("drawable-xhdpi"); } + @Test + public void ninePatchImageColorTest() throws BrutException, IOException { + char slash = File.separatorChar; + String location = slash + "res" + slash + "drawable-xhdpi" + slash; + + File control = new File((sTestOrigDir + location), "9patch.9.png"); + File test = new File((sTestNewDir + location), "9patch.9.png"); + + BufferedImage controlImage = ImageIO.read(control); + BufferedImage testImage = ImageIO.read(test); + + // lets start with 0,0 - empty + assertEquals(controlImage.getRGB(0, 0), testImage.getRGB(0, 0)); + + // then with 30, 0 - black + assertEquals(controlImage.getRGB(30, 0), testImage.getRGB(30, 0)); + + // then 30, 30 - blue + assertEquals(controlImage.getRGB(30, 30), testImage.getRGB(30, 30)); + } + @Test public void drawableXxhdpiTest() throws BrutException, IOException { compareResFolder("drawable-xxhdpi");