Add tests to ensure empty, uncompressed files are put on the doNotCompress list.

Also, fix a bug where ext would retain its value from a previous
iteration of the loop, since we don't always overwrite it now.
This commit is contained in:
Peter Retzlaff 2020-04-21 10:37:54 +02:00 committed by Connor Tumbleson
parent 05f81f9dd0
commit 408050ffde
3 changed files with 14 additions and 2 deletions

View File

@ -163,10 +163,10 @@ public class Androlib {
try { try {
Directory unk = apkFile.getDirectory(); Directory unk = apkFile.getDirectory();
Set<String> files = unk.getFiles(true); Set<String> files = unk.getFiles(true);
String ext = "";
for (String file : files) { for (String file : files) {
if (isAPKFileNames(file) && unk.getCompressionLevel(file) == 0) { if (isAPKFileNames(file) && unk.getCompressionLevel(file) == 0) {
String ext = "";
if (unk.getSize(file) != 0) { if (unk.getSize(file) != 0) {
ext = FilenameUtils.getExtension(file); ext = FilenameUtils.getExtension(file);
} }

View File

@ -501,6 +501,12 @@ public class BuildAndDecodeTest extends BaseTest {
} }
} }
@Test
public void confirmZeroByteFileIsStored() throws BrutException {
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
assertTrue(metaInfo.doNotCompress.contains("assets/0byte_file.jpg"));
}
@Test @Test
public void drawableXxhdpiTest() throws BrutException, IOException { public void drawableXxhdpiTest() throws BrutException, IOException {
compareResFolder("drawable-xxhdpi"); compareResFolder("drawable-xxhdpi");

View File

@ -82,7 +82,13 @@ public class BuildAndDecodeTest extends BaseTest {
@Test @Test
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException { public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir); MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
assertNull(metaInfo.doNotCompress); assertFalse(metaInfo.doNotCompress.contains("jpg"));
}
@Test
public void confirmZeroByteFileIsStored() throws BrutException {
MetaInfo metaInfo = new Androlib().readMetaFile(sTestNewDir);
assertTrue(metaInfo.doNotCompress.contains("assets/0byte_file.jpg"));
} }
@Test @Test