mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-21 09:17:35 +01:00
refactor aapt test into own test class, move helper function into TestUtils
This commit is contained in:
parent
2d0fb1f6ca
commit
19a1a260a0
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright 2011 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package brut.androlib;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||
*/
|
||||
public class AaptTest {
|
||||
|
||||
@Test
|
||||
public void isAaptInstalledTest() throws Exception {
|
||||
assertEquals(true, isAaptPresent());
|
||||
}
|
||||
|
||||
private static boolean isAaptPresent() throws Exception {
|
||||
boolean result = true;
|
||||
try {
|
||||
Process proc = Runtime.getRuntime().exec("aapt");
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
proc.getErrorStream()));
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ public class BuildAndDecodeTest {
|
||||
LOGGER.info("Building testapp.apk...");
|
||||
File testApk = new File(sTmpDir, "testapp.apk");
|
||||
new Androlib().build(sTestOrigDir, testApk,
|
||||
BuildAndDecodeTest.returnStock(),"");
|
||||
TestUtils.returnStockHashMap(),"");
|
||||
|
||||
LOGGER.info("Decoding testapp.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
@ -64,11 +64,6 @@ public class BuildAndDecodeTest {
|
||||
assertTrue(sTestNewDir.isDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAaptInstalledTest() throws Exception {
|
||||
assertEquals(true, isAaptPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesAnimsTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/anims.xml");
|
||||
@ -219,21 +214,6 @@ public class BuildAndDecodeTest {
|
||||
compareLibsFolder("libs");
|
||||
}
|
||||
|
||||
private static boolean isAaptPresent() throws Exception {
|
||||
boolean result = true;
|
||||
try {
|
||||
Process proc = Runtime.getRuntime().exec("aapt");
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
proc.getErrorStream()));
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean compareBinaryFolder(String path, boolean res) throws BrutException, IOException {
|
||||
|
||||
String tmp = "";
|
||||
@ -298,18 +278,6 @@ public class BuildAndDecodeTest {
|
||||
diff.similar());
|
||||
}
|
||||
|
||||
private static HashMap<String, Boolean> returnStock() throws BrutException {
|
||||
HashMap<String, Boolean> tmp = new HashMap<String, Boolean>();
|
||||
tmp.put("forceBuildAll", false);
|
||||
tmp.put("debug", false);
|
||||
tmp.put("verbose", false);
|
||||
tmp.put("framework", false);
|
||||
tmp.put("update", false);
|
||||
tmp.put("copyOriginal", false);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private static ExtFile sTmpDir;
|
||||
private static ExtFile sTestOrigDir;
|
||||
private static ExtFile sTestNewDir;
|
||||
|
@ -76,6 +76,18 @@ public abstract class TestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<String, Boolean> returnStockHashMap() throws BrutException {
|
||||
HashMap<String, Boolean> tmp = new HashMap<String, Boolean>();
|
||||
tmp.put("forceBuildAll", false);
|
||||
tmp.put("debug", false);
|
||||
tmp.put("verbose", false);
|
||||
tmp.put("framework", false);
|
||||
tmp.put("update", false);
|
||||
tmp.put("copyOriginal", false);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: move to brut.util.Jar - it's not possible for now, because below
|
||||
* implementation uses brut.dir. I think I should merge all my projects to
|
||||
|
Loading…
x
Reference in New Issue
Block a user