fixed problem with nodpi, added drawable unit testing

This commit is contained in:
Connor Tumbleson 2013-05-09 21:54:03 -05:00
parent f93a312308
commit 3a6d548756
12 changed files with 74 additions and 1 deletions

View File

@ -416,7 +416,7 @@ public class ResConfigFlags {
public final static int DENSITY_HIGH = 240;
public final static int DENSITY_XHIGH = 320;
public final static int DENSITY_XXHIGH = 480;
public final static int DENSITY_NONE = -1;
public final static int DENSITY_NONE = 0xFFFF;
public final static short MASK_LAYOUTDIR = 0xc0;
public final static short SCREENLAYOUT_LAYOUTDIR_ANY = 0x00;

View File

@ -19,6 +19,8 @@ import brut.androlib.res.util.ExtFile;
import brut.common.BrutException;
import brut.util.OS;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashMap;
import java.util.logging.Logger;
import org.custommonkey.xmlunit.*;
@ -130,6 +132,41 @@ public class BuildAndDecodeTest {
+ "-navhidden-dpad/strings.xml");
}
@Test
public void drawableNoDpiTest() throws BrutException, IOException {
compareDrawablesFolder("drawable-nodpi");
}
@Test
public void drawableNumberedDpiTest() throws BrutException, IOException {
compareDrawablesFolder("drawable-534dpi");
}
@Test
public void drawableLdpiTest() throws BrutException, IOException {
compareDrawablesFolder("drawable-ldpi");
}
@Test
public void drawableMdpiTest() throws BrutException, IOException {
compareDrawablesFolder("drawable-mdpi");
}
@Test
public void drawableTvdpiTest() throws BrutException, IOException {
compareDrawablesFolder("drawable-tvdpi");
}
@Test
public void drawableXhdpiTest() throws BrutException, IOException {
compareDrawablesFolder("drawable-xhdpi");
}
@Test
public void drawableXxhdpiTest() throws BrutException, IOException {
compareDrawablesFolder("drawable-xxhdpi");
}
private static boolean isAaptPresent() throws Exception {
boolean result = true;
try {
@ -145,6 +182,40 @@ public class BuildAndDecodeTest {
return result;
}
private void compareDrawable(String path) throws BrutException, IOException {
String tmp = File.separatorChar + "res" + File.separatorChar;
Files.walkFileTree(Paths.get(sTestOrigDir.toPath() + tmp + path), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// hacky fix - load test by changing name of control
File control = file.toFile();
File test = new File(file.toString().replace("testapp-orig", "testapp-new"));
if (test.isFile()) {
if (control.hashCode() != test.hashCode()) {
sResult = false;
return FileVisitResult.TERMINATE;
}
} else {
sResult = false;
return FileVisitResult.TERMINATE;
}
return FileVisitResult.CONTINUE;
}
});
}
private boolean compareDrawablesFolder(String path) throws BrutException, IOException {
sResult = true;
compareDrawable(path);
return sResult;
}
private void compareValuesFiles(String path) throws BrutException {
compareXmlFiles("res/" + path, new ElementNameAndAttributeQualifier(
"name"));
@ -192,6 +263,8 @@ public class BuildAndDecodeTest {
private static ExtFile sTestOrigDir;
private static ExtFile sTestNewDir;
private static boolean sResult;
private final static Logger LOGGER = Logger
.getLogger(BuildAndDecodeTest.class.getName());
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB