From 5a4ffe6ca0560be724a43d540d029726b9b2444c Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Fri, 18 Jan 2013 06:39:48 -0600 Subject: [PATCH] fixed BuildAndDecodeTest, Thanks aspack --- .../brut/androlib/BuildAndDecodeTest.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index df475f4f..fe54793a 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -33,17 +33,31 @@ import org.xml.sax.SAXException; public class BuildAndDecodeTest { @BeforeClass - public static void beforeClass() throws BrutException, IOException { + public static void beforeClass() throws Exception, BrutException { sTmpDir = new ExtFile(OS.createTempDirectory()); sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig"); sTestNewDir = new ExtFile(sTmpDir, "testapp-new"); - File testApk = new File(sTmpDir, "testapp.apk"); - LOGGER.info("Unpacking testapp..."); TestUtils.copyResourceDir(BuildAndDecodeTest.class, "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..."); + File testApk = new File(sTmpDir, "testapp.apk"); ExtFile blank = null; new Androlib().build(sTestOrigDir, testApk, BuildAndDecodeTest.returnStock(),blank,""); @@ -53,10 +67,6 @@ public class BuildAndDecodeTest { apkDecoder.decode(); } - @AfterClass - public static void afterClass() throws BrutException { - OS.rmdir(sTmpDir); - } @Test public void valuesArraysTest() throws BrutException { @@ -116,11 +126,6 @@ public class BuildAndDecodeTest { compareXmlFiles("res/xml/references.xml"); } - @Test - public void aaptPresent() throws BrutException { - checkIfAaptPresent(); - } - @Test public void qualifiersTest() throws BrutException { compareValuesFiles("values-mcc004-mnc4-en-rUS-ldrtl-sw100dp-w200dp-h300dp" + @@ -128,7 +133,8 @@ public class BuildAndDecodeTest { "-navhidden-dpad/strings.xml"); } - private void checkIfAaptPresent() throws BrutException { + private static boolean isAaptPresent() throws Exception { + boolean result = true; try { Process proc = Runtime.getRuntime().exec("aapt"); @@ -136,9 +142,9 @@ public class BuildAndDecodeTest { String line = null; while ( (line = br.readLine()) != null){} } catch (Exception ex){ - System.out.println("Please install 'aapt' to your path. See project website for more information."); - throw new BrutException(ex); + result = false; } + return result; } private void compareValuesFiles(String path) throws BrutException {