mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 13:57:46 +01:00
test: updates aapt1 tests to handle the new "compileSdk" attributes
This commit is contained in:
parent
b49bba19e4
commit
7a481f68e0
@ -20,17 +20,19 @@ import brut.androlib.*;
|
|||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
|
import org.custommonkey.xmlunit.XMLUnit;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Connor Tumbleson <connor.tumbleson@gmail.com>
|
* @author Connor Tumbleson <connor.tumbleson@gmail.com>
|
||||||
@ -70,16 +72,21 @@ public class DebugTagRetainedTest extends BaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void DebugIsTruePriorToBeingFalseTest() throws IOException {
|
public void DebugIsTruePriorToBeingFalseTest() throws IOException, SAXException {
|
||||||
String apk = "issue1235-new";
|
String apk = "issue1235-new";
|
||||||
|
|
||||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n" +
|
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>" +
|
||||||
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.ibotpeaches.issue1235\" platformBuildVersionCode=\"23\" platformBuildVersionName=\"6.0-2438415\">\n" +
|
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:compileSdkVersion=\"23\" " +
|
||||||
" <application android:debuggable=\"true\"/>" +
|
"android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue1235\" platformBuildVersionCode=\"23\" " +
|
||||||
"</manifest>");
|
"platformBuildVersionName=\"6.0-2438415\"> <application android:debuggable=\"true\"/></manifest>");
|
||||||
|
|
||||||
byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + File.separator + "AndroidManifest.xml"));
|
byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + File.separator + "AndroidManifest.xml"));
|
||||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||||
assertEquals(expected, obtained);
|
|
||||||
|
XMLUnit.setIgnoreWhitespace(true);
|
||||||
|
XMLUnit.setIgnoreAttributeOrder(true);
|
||||||
|
XMLUnit.setCompareUnmatched(false);
|
||||||
|
|
||||||
|
assertXMLEqual(expected, obtained);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,16 +23,18 @@ import brut.androlib.TestUtils;
|
|||||||
import brut.directory.ExtFile;
|
import brut.directory.ExtFile;
|
||||||
import brut.common.BrutException;
|
import brut.common.BrutException;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
|
import org.custommonkey.xmlunit.XMLUnit;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ProviderAttributeTest extends BaseTest {
|
public class ProviderAttributeTest extends BaseTest {
|
||||||
@ -50,7 +52,7 @@ public class ProviderAttributeTest extends BaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isProviderStringReplacementWorking() throws BrutException, IOException {
|
public void isProviderStringReplacementWorking() throws BrutException, IOException, SAXException {
|
||||||
String apk = "issue636.apk";
|
String apk = "issue636.apk";
|
||||||
|
|
||||||
// decode issue636.apk
|
// decode issue636.apk
|
||||||
@ -70,7 +72,7 @@ public class ProviderAttributeTest extends BaseTest {
|
|||||||
apkDecoder.decode();
|
apkDecoder.decode();
|
||||||
|
|
||||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n" +
|
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n" +
|
||||||
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.ibotpeaches.issue636\" platformBuildVersionCode=\"23\" platformBuildVersionName=\"6.0-2438415\">\n" +
|
"<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" package=\"com.ibotpeaches.issue636\" platformBuildVersionCode=\"23\" platformBuildVersionName=\"6.0-2438415\">\n" +
|
||||||
" <application android:allowBackup=\"true\" android:debuggable=\"true\" android:icon=\"@mipmap/ic_launcher\" android:label=\"@string/app_name\" android:theme=\"@style/AppTheme\">\n" +
|
" <application android:allowBackup=\"true\" android:debuggable=\"true\" android:icon=\"@mipmap/ic_launcher\" android:label=\"@string/app_name\" android:theme=\"@style/AppTheme\">\n" +
|
||||||
" <provider android:authorities=\"com.ibotpeaches.issue636.Provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.Provider\"/>\n" +
|
" <provider android:authorities=\"com.ibotpeaches.issue636.Provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.Provider\"/>\n" +
|
||||||
" <provider android:authorities=\"com.ibotpeaches.issue636.ProviderTwo\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.ProviderTwo\"/>\n" +
|
" <provider android:authorities=\"com.ibotpeaches.issue636.ProviderTwo\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:label=\"@string/app_name\" android:multiprocess=\"false\" android:name=\"com.ibotpeaches.issue636.ProviderTwo\"/>\n" +
|
||||||
@ -80,7 +82,12 @@ public class ProviderAttributeTest extends BaseTest {
|
|||||||
|
|
||||||
byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + ".out.two" + File.separator + "AndroidManifest.xml"));
|
byte[] encoded = Files.readAllBytes(Paths.get(sTmpDir + File.separator + apk + ".out.two" + File.separator + "AndroidManifest.xml"));
|
||||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||||
assertEquals(expected, obtained);
|
|
||||||
|
XMLUnit.setIgnoreWhitespace(true);
|
||||||
|
XMLUnit.setIgnoreAttributeOrder(true);
|
||||||
|
XMLUnit.setCompareUnmatched(false);
|
||||||
|
|
||||||
|
assertXMLEqual(expected, obtained);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean fileExists(String filepath) {
|
private boolean fileExists(String filepath) {
|
||||||
|
@ -62,11 +62,11 @@ public class ExternalEntityTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
public void doctypeTest() throws IOException {
|
public void doctypeTest() throws IOException {
|
||||||
|
|
||||||
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
|
String expected = TestUtils.replaceNewlines("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||||
"<manifest android:versionCode=\"1\" android:versionName=\"1.0\" hardwareAccelerated=\"true\" package=\"com.ibotpeaches.doctype\" platformBuildVersionCode=\"23\" platformBuildVersionName=\"6.0-2438415\"\n" +
|
"<manifest android:versionCode=\"1\" android:versionName=\"1.0\" android:compileSdkVersion=\"23\" android:compileSdkVersionCodename=\"6.0-2438415\" " +
|
||||||
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
|
"hardwareAccelerated=\"true\" package=\"com.ibotpeaches.doctype\" platformBuildVersionCode=\"23\" platformBuildVersionName=\"6.0-2438415\" " +
|
||||||
" <supports-screens android:anyDensity=\"true\" android:smallScreens=\"true\" android:normalScreens=\"true\" android:largeScreens=\"true\" android:resizeable=\"true\" android:xlargeScreens=\"true\" />\n" +
|
"xmlns:android=\"http://schemas.android.com/apk/res/android\"> <supports-screens android:anyDensity=\"true\" android:smallScreens=\"true\" " +
|
||||||
"</manifest>");
|
"android:normalScreens=\"true\" android:largeScreens=\"true\" android:resizeable=\"true\" android:xlargeScreens=\"true\" /></manifest>");
|
||||||
|
|
||||||
byte[] encoded = Files.readAllBytes(Paths.get(sTestOrigDir + File.separator + "output" + File.separator + "AndroidManifest.xml"));
|
byte[] encoded = Files.readAllBytes(Paths.get(sTestOrigDir + File.separator + "output" + File.separator + "AndroidManifest.xml"));
|
||||||
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
String obtained = TestUtils.replaceNewlines(new String(encoded));
|
||||||
|
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="brut.apktool.testapp" platformBuildVersionCode="23" platformBuildVersionName="6.0-2438415">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="23" android:compileSdkVersionCodename="6.0-2438415" package="brut.apktool.testapp" platformBuildVersionCode="23" platformBuildVersionName="6.0-2438415">
|
||||||
<uses-feature android:glEsVersion="0x00020000" />
|
<uses-feature android:glEsVersion="0x00020000" />
|
||||||
<uses-feature android:glEsVersion="0x00030002" />
|
<uses-feature android:glEsVersion="0x00030002" />
|
||||||
</manifest>
|
</manifest>
|
||||||
|
Loading…
Reference in New Issue
Block a user