diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/AaptTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/AaptTest.java new file mode 100644 index 00000000..5f2d30ca --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/AaptTest.java @@ -0,0 +1,49 @@ +/** + * Copyright 2011 Ryszard Wiśniewski + * + * 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 + */ +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; + } +} 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 e3f57044..a89f5beb 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 @@ -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 returnStock() throws BrutException { - HashMap tmp = new HashMap(); - 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; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/TestUtils.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/TestUtils.java index 5b5f3992..a66c7d9a 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/TestUtils.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/TestUtils.java @@ -76,6 +76,18 @@ public abstract class TestUtils { } } + public static HashMap returnStockHashMap() throws BrutException { + HashMap tmp = new HashMap(); + 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