mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
test: add testcase for static field values
This commit is contained in:
parent
280a3d8c01
commit
468ead8f10
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@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.res.src;
|
||||
|
||||
import brut.androlib.*;
|
||||
import brut.androlib.aapt2.BuildAndDecodeTest;
|
||||
import brut.common.BrutException;
|
||||
import brut.directory.ExtFile;
|
||||
import brut.util.OS;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DexStaticFieldValueTest extends BaseTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
TestUtils.cleanFrameworkFile();
|
||||
|
||||
sTmpDir = new ExtFile(OS.createTempDirectory());
|
||||
sTestOrigDir = new ExtFile(sTmpDir, "issue2543-orig");
|
||||
sTestNewDir = new ExtFile(sTmpDir, "issue2543-new");
|
||||
LOGGER.info("Unpacking issue2543...");
|
||||
TestUtils.copyResourceDir(BuildAndDecodeTest.class, "decode/issue2543/", sTestOrigDir);
|
||||
|
||||
ApkOptions apkOptions = new ApkOptions();
|
||||
|
||||
LOGGER.info("Building issue2543.apk...");
|
||||
File testApk = new File(sTmpDir, "issue2543.apk");
|
||||
new Androlib(apkOptions).build(sTestOrigDir, testApk);
|
||||
|
||||
LOGGER.info("Decoding issue2543.apk...");
|
||||
ApkDecoder apkDecoder = new ApkDecoder(testApk);
|
||||
apkDecoder.setOutDir(sTestNewDir);
|
||||
apkDecoder.setBaksmaliDebugMode(false);
|
||||
apkDecoder.decode();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws BrutException {
|
||||
OS.rmdir(sTmpDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disassembleDexFileToKeepDefaultParameters() throws IOException {
|
||||
String expected = TestUtils.replaceNewlines(
|
||||
".class public LHelloWorld;\n"
|
||||
+ ".super Ljava/lang/Object;\n"
|
||||
+ "\n"
|
||||
+ "\n"
|
||||
+ "# static fields\n"
|
||||
+ ".field private static b:Z = false\n"
|
||||
+ "\n"
|
||||
+ ".field private static c:Z = true\n"
|
||||
+ "\n"
|
||||
+ "\n"
|
||||
+ "# direct methods\n"
|
||||
+ ".method public static main([Ljava/lang/String;)V\n"
|
||||
+ " .locals 1\n"
|
||||
+ "\n"
|
||||
+ " return-void\n"
|
||||
+ ".end method");
|
||||
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(sTestNewDir + File.separator + "smali" + File.separator
|
||||
+ "HelloWorld.smali"));
|
||||
|
||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||
assertEquals(expected, obtained);
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<manifest package="com.ibotpeaches.issue2543" platformBuildVersionCode="24" platformBuildVersionName="6.0-2456767" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
</manifest>
|
@ -0,0 +1,12 @@
|
||||
version: 2.0.0
|
||||
apkFileName: issue2543.apk
|
||||
isFrameworkApk: false
|
||||
usesFramework:
|
||||
ids:
|
||||
- 1
|
||||
packageInfo:
|
||||
forcedPackageId: '127'
|
||||
versionInfo:
|
||||
versionCode: '1'
|
||||
versionName: '1.0'
|
||||
compressionType: false
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user