mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-06 10:05:54 +01:00
Adding a few random AOSP 9 patch images to more test suite more robust.
This commit is contained in:
parent
4a3e24666e
commit
dab59a2aec
@ -176,16 +176,16 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
|
||||
}
|
||||
|
||||
public static NinePatch decode(ExtDataInput di) throws IOException {
|
||||
di.skipBytes(1);
|
||||
di.skipBytes(1); // wasDeserialized
|
||||
byte numXDivs = di.readByte();
|
||||
byte numYDivs = di.readByte();
|
||||
di.skipBytes(1);
|
||||
di.skipBytes(8);
|
||||
di.skipBytes(1); // numColors
|
||||
di.skipBytes(8); // xDivs/yDivs offset
|
||||
int padLeft = di.readInt();
|
||||
int padRight = di.readInt();
|
||||
int padTop = di.readInt();
|
||||
int padBottom = di.readInt();
|
||||
di.skipBytes(4);
|
||||
di.skipBytes(4); // colorsOffset
|
||||
int[] xDivs = di.readIntArray(numXDivs);
|
||||
int[] yDivs = di.readIntArray(numYDivs);
|
||||
|
||||
|
@ -389,12 +389,50 @@ public class BuildAndDecodeTest {
|
||||
final int[] controlImageGrid = controlImage.getRGB(0, 0, w, h, null, 0, w);
|
||||
final int[] testImageGrid = testImage.getRGB(0, 0, w, h, null, 0, w);
|
||||
|
||||
|
||||
for (int i = 0; i < controlImageGrid.length; i++) {
|
||||
assertEquals("Image lost Optical Bounds at i = " + i, controlImageGrid[i], testImageGrid[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void robust9patchTest() throws BrutException, IOException {
|
||||
String[] ninePatches = {"ic_notification_overlay.9.png", "status_background.9.png",
|
||||
"search_bg_transparent.9.png", "screenshot_panel.9.png", "recents_lower_gradient.9.png"};
|
||||
|
||||
char slash = File.separatorChar;
|
||||
String location = slash + "res" + slash + "drawable-xxhdpi" + slash;
|
||||
|
||||
for (String ninePatch : ninePatches) {
|
||||
File control = new File((sTestOrigDir + location), ninePatch);
|
||||
File test = new File((sTestNewDir + location), ninePatch);
|
||||
|
||||
BufferedImage controlImage = ImageIO.read(control);
|
||||
BufferedImage testImage = ImageIO.read(test);
|
||||
|
||||
int w = controlImage.getWidth(), h = controlImage.getHeight();
|
||||
|
||||
// Check the entire horizontal line
|
||||
for (int i = 1; i < w; i++) {
|
||||
if (isTransparent(controlImage.getRGB(i, 0))) {
|
||||
assertTrue(isTransparent(testImage.getRGB(i, 0)));
|
||||
} else {
|
||||
assertEquals("Image lost npTc chunk on image " + ninePatch + " at (x, y) (" + i + "," + 0 + ")",
|
||||
controlImage.getRGB(i, 0), testImage.getRGB(i, 0));
|
||||
}
|
||||
}
|
||||
|
||||
// Check the entire vertical line
|
||||
for (int i = 1; i < h; i++) {
|
||||
if (isTransparent(controlImage.getRGB(0, i))) {
|
||||
assertTrue(isTransparent(testImage.getRGB(0, i)));
|
||||
} else {
|
||||
assertEquals("Image lost npTc chunk on image " + ninePatch + " at (x, y) (" + 0 + "," + i + ")",
|
||||
controlImage.getRGB(0, i), testImage.getRGB(0, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawableXxhdpiTest() throws BrutException, IOException {
|
||||
compareResFolder("drawable-xxhdpi");
|
||||
@ -515,6 +553,10 @@ public class BuildAndDecodeTest {
|
||||
assertTrue(f.isDirectory());
|
||||
}
|
||||
|
||||
private boolean isTransparent(int pixel) {
|
||||
return pixel >> 24 == 0x00;
|
||||
}
|
||||
|
||||
private void compareXmlFiles(String path, ElementQualifier qualifier) throws BrutException {
|
||||
DetailedDiff diff;
|
||||
try {
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 265 B |
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 179 B |
Loading…
Reference in New Issue
Block a user