| 1 |
/* |
| 2 |
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]> |
| 3 |
* Copyright (C) 2010 Connor Tumbleson <[email protected]> |
| 4 |
* |
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
* you may not use this file except in compliance with the License. |
| 7 |
* You may obtain a copy of the License at |
| 8 |
* |
| 9 |
* https://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 11 |
* Unless required by applicable law or agreed to in writing, software |
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
* See the License for the specific language governing permissions and |
| 15 |
* limitations under the License. |
| 16 |
*/ |
| 17 |
package brut.androlib.aapt1; |
| 18 |
|
| 19 |
import brut.androlib.Androlib; |
| 20 |
import brut.androlib.ApkDecoder; |
| 21 |
import brut.androlib.BaseTest; |
| 22 |
import brut.androlib.TestUtils; |
| 23 |
import brut.directory.ExtFile; |
| 24 |
import brut.common.BrutException; |
| 25 |
import brut.util.OS; |
| 26 |
import java.io.File; |
| 27 |
import java.io.IOException; |
| 28 |
|
| 29 |
import org.junit.*; |
| 30 |
|
| 31 |
public class LargeIntsInManifestTest extends BaseTest { |
| 32 |
|
| 33 |
@BeforeClass |
| 34 |
public static void beforeClass() throws Exception { |
| 35 |
TestUtils.cleanFrameworkFile(); |
| 36 |
sTmpDir = new ExtFile(OS.createTempDirectory()); |
| 37 |
TestUtils.copyResourceDir(LargeIntsInManifestTest.class, "aapt1/issue767/", sTmpDir); |
| 38 |
} |
| 39 |
|
| 40 |
@AfterClass |
| 41 |
public static void afterClass() throws BrutException { |
| 42 |
OS.rmdir(sTmpDir); |
| 43 |
} |
| 44 |
|
| 45 |
@Test |
| 46 |
public void checkIfLargeIntsAreHandledTest() throws BrutException, IOException { |
| 47 |
String apk = "issue767.apk"; |
| 48 |
|
| 49 |
// decode issue767.apk |
| 50 |
ApkDecoder apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + apk)); |
| 51 |
sTestOrigDir = new ExtFile(sTmpDir + File.separator + apk + ".out"); |
| 52 |
|
| 53 |
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out")); |
| 54 |
apkDecoder.decode(); |
| 55 |
|
| 56 |
// build issue767 |
| 57 |
ExtFile testApk = new ExtFile(sTmpDir, apk + ".out"); |
| 58 |
new Androlib().build(testApk, null); |
| 59 |
String newApk = apk + ".out" + File.separator + "dist" + File.separator + apk; |
| 60 |
|
| 61 |
// decode issue767 again |
| 62 |
apkDecoder = new ApkDecoder(new File(sTmpDir + File.separator + newApk)); |
| 63 |
sTestNewDir = new ExtFile(sTmpDir + File.separator + apk + ".out.two"); |
| 64 |
|
| 65 |
apkDecoder.setOutDir(new File(sTmpDir + File.separator + apk + ".out.two")); |
| 66 |
apkDecoder.decode(); |
| 67 |
|
| 68 |
compareXmlFiles("AndroidManifest.xml"); |
| 69 |
} |
| 70 |
} |