mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-02 15:04:24 +02:00
Multiple Dex Support - part 4
- add unit tests - minor cs fixes
This commit is contained in:
parent
7ef993cc75
commit
18b94d5974
@ -165,7 +165,6 @@ public class ApkDecoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mAndrolib.decodeRawFiles(mApkFile, outDir);
|
mAndrolib.decodeRawFiles(mApkFile, outDir);
|
||||||
|
@ -40,13 +40,11 @@ public class BuildAndDecodeTest {
|
|||||||
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
|
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
|
||||||
sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
|
sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
|
||||||
LOGGER.info("Unpacking testapp...");
|
LOGGER.info("Unpacking testapp...");
|
||||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class,
|
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "brut/apktool/testapp/", sTestOrigDir);
|
||||||
"brut/apktool/testapp/", sTestOrigDir);
|
|
||||||
|
|
||||||
LOGGER.info("Building testapp.apk...");
|
LOGGER.info("Building testapp.apk...");
|
||||||
File testApk = new File(sTmpDir, "testapp.apk");
|
File testApk = new File(sTmpDir, "testapp.apk");
|
||||||
new Androlib().build(sTestOrigDir, testApk,
|
new Androlib().build(sTestOrigDir, testApk, TestUtils.returnStockHashMap(),"");
|
||||||
TestUtils.returnStockHashMap(),"");
|
|
||||||
|
|
||||||
LOGGER.info("Decoding testapp.apk...");
|
LOGGER.info("Decoding testapp.apk...");
|
||||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||||
@ -219,8 +217,19 @@ public class BuildAndDecodeTest {
|
|||||||
compareUnknownFiles();
|
compareUnknownFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void multipleDexTest() throws BrutException, IOException {
|
||||||
|
compareBinaryFolder("/smali_classes2", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void singleDexTest() throws BrutException, IOException {
|
||||||
|
compareBinaryFolder("/smali", false);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void compareUnknownFiles() throws BrutException, IOException {
|
private void compareUnknownFiles()
|
||||||
|
throws BrutException, IOException {
|
||||||
Map<String, Object> control = new Androlib().readMetaFile(sTestOrigDir);
|
Map<String, Object> control = new Androlib().readMetaFile(sTestOrigDir);
|
||||||
Map<String, Object> test = new Androlib().readMetaFile(sTestNewDir);
|
Map<String, Object> test = new Androlib().readMetaFile(sTestNewDir);
|
||||||
assertTrue(control.containsKey("unknownFiles"));
|
assertTrue(control.containsKey("unknownFiles"));
|
||||||
@ -231,8 +240,8 @@ public class BuildAndDecodeTest {
|
|||||||
assertTrue(control_files.size() == test_files.size());
|
assertTrue(control_files.size() == test_files.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean compareBinaryFolder(String path, boolean res) throws BrutException, IOException {
|
private boolean compareBinaryFolder(String path, boolean res)
|
||||||
|
throws BrutException, IOException {
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
if (res) {
|
if (res) {
|
||||||
tmp = File.separatorChar + "res" + File.separatorChar;
|
tmp = File.separatorChar + "res" + File.separatorChar;
|
||||||
@ -265,8 +274,7 @@ public class BuildAndDecodeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void compareValuesFiles(String path) throws BrutException {
|
private void compareValuesFiles(String path) throws BrutException {
|
||||||
compareXmlFiles("res/" + path, new ElementNameAndAttributeQualifier(
|
compareXmlFiles("res/" + path, new ElementNameAndAttributeQualifier("name"));
|
||||||
"name"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compareXmlFiles(String path) throws BrutException {
|
private void compareXmlFiles(String path) throws BrutException {
|
||||||
@ -291,14 +299,12 @@ public class BuildAndDecodeTest {
|
|||||||
diff.overrideElementQualifier(qualifier);
|
diff.overrideElementQualifier(qualifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(path + ": " + diff.getAllDifferences().toString(),
|
assertTrue(path + ": " + diff.getAllDifferences().toString(), diff.similar());
|
||||||
diff.similar());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ExtFile sTmpDir;
|
private static ExtFile sTmpDir;
|
||||||
private static ExtFile sTestOrigDir;
|
private static ExtFile sTestOrigDir;
|
||||||
private static ExtFile sTestNewDir;
|
private static ExtFile sTestNewDir;
|
||||||
|
|
||||||
private final static Logger LOGGER = Logger
|
private final static Logger LOGGER = Logger.getLogger(BuildAndDecodeTest.class.getName());
|
||||||
.getLogger(BuildAndDecodeTest.class.getName());
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user