mirror of
https://github.com/revanced/Apktool.git
synced 2025-02-13 12:26:47 +01:00
fixed BuildAndDecodeTest, Thanks aspack
This commit is contained in:
parent
0673c1e2dc
commit
5a4ffe6ca0
@ -33,17 +33,31 @@ import org.xml.sax.SAXException;
|
|||||||
public class BuildAndDecodeTest {
|
public class BuildAndDecodeTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws BrutException, IOException {
|
public static void beforeClass() throws Exception, BrutException {
|
||||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||||
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
|
sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
|
||||||
sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
|
sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
|
||||||
File testApk = new File(sTmpDir, "testapp.apk");
|
|
||||||
|
|
||||||
LOGGER.info("Unpacking testapp...");
|
LOGGER.info("Unpacking testapp...");
|
||||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class,
|
TestUtils.copyResourceDir(BuildAndDecodeTest.class,
|
||||||
"brut/apktool/testapp/", sTestOrigDir);
|
"brut/apktool/testapp/", sTestOrigDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void afterClass() throws BrutException {
|
||||||
|
OS.rmdir(sTmpDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAaptInstalledTest() throws Exception {
|
||||||
|
assertEquals(true, isAaptPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void encodeAndDecodeTest() throws BrutException, IOException {
|
||||||
|
|
||||||
LOGGER.info("Building testapp.apk...");
|
LOGGER.info("Building testapp.apk...");
|
||||||
|
File testApk = new File(sTmpDir, "testapp.apk");
|
||||||
ExtFile blank = null;
|
ExtFile blank = null;
|
||||||
new Androlib().build(sTestOrigDir, testApk, BuildAndDecodeTest.returnStock(),blank,"");
|
new Androlib().build(sTestOrigDir, testApk, BuildAndDecodeTest.returnStock(),blank,"");
|
||||||
|
|
||||||
@ -53,10 +67,6 @@ public class BuildAndDecodeTest {
|
|||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void afterClass() throws BrutException {
|
|
||||||
OS.rmdir(sTmpDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void valuesArraysTest() throws BrutException {
|
public void valuesArraysTest() throws BrutException {
|
||||||
@ -116,11 +126,6 @@ public class BuildAndDecodeTest {
|
|||||||
compareXmlFiles("res/xml/references.xml");
|
compareXmlFiles("res/xml/references.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void aaptPresent() throws BrutException {
|
|
||||||
checkIfAaptPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void qualifiersTest() throws BrutException {
|
public void qualifiersTest() throws BrutException {
|
||||||
compareValuesFiles("values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp" +
|
compareValuesFiles("values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp" +
|
||||||
@ -128,7 +133,8 @@ public class BuildAndDecodeTest {
|
|||||||
"-navhidden-dpad/strings.xml");
|
"-navhidden-dpad/strings.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfAaptPresent() throws BrutException {
|
private static boolean isAaptPresent() throws Exception {
|
||||||
|
boolean result = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process proc = Runtime.getRuntime().exec("aapt");
|
Process proc = Runtime.getRuntime().exec("aapt");
|
||||||
@ -136,9 +142,9 @@ public class BuildAndDecodeTest {
|
|||||||
String line = null;
|
String line = null;
|
||||||
while ( (line = br.readLine()) != null){}
|
while ( (line = br.readLine()) != null){}
|
||||||
} catch (Exception ex){
|
} catch (Exception ex){
|
||||||
System.out.println("Please install 'aapt' to your path. See project website for more information.");
|
result = false;
|
||||||
throw new BrutException(ex);
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void compareValuesFiles(String path) throws BrutException {
|
private void compareValuesFiles(String path) throws BrutException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user