Skip to content

Commit

Permalink
tweak test for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorEisberg committed Jan 18, 2025
1 parent 02a87c5 commit 1f3f634
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package brut.androlib;

import brut.androlib.Config;
import brut.androlib.apk.ApkInfo;
import brut.androlib.res.Framework;
import brut.common.BrutException;
import brut.directory.ExtFile;
Expand Down Expand Up @@ -47,7 +46,6 @@ public class BaseTest {
protected static File sTmpDir;
protected static ExtFile sTestOrigDir;
protected static ExtFile sTestNewDir;
protected static ApkInfo sTestApkInfo;

private static void cleanFrameworkFile() throws BrutException {
File apkFile = new File(new Framework(sConfig).getDirectory(), "1.apk");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ public void valuesExtraLongExactLengthTest() throws BrutException {

@Test
public void storedMp3FilesAreNotCompressedTest() throws BrutException, IOException {
ExtFile testApk = new ExtFile(sTmpDir, "testapp.apk");
Integer compLevel = testApk.getDirectory().getCompressionLevel("res/raw/rain.mp3");
testApk.close();
assertEquals(Integer.valueOf(0), compLevel);
try (ExtFile testApk = new ExtFile(sTmpDir, "testapp.apk")) {
Integer compLevel = testApk.getDirectory().getCompressionLevel("res/raw/rain.mp3");
assertEquals(Integer.valueOf(0), compLevel);
}
}

@Test
Expand Down Expand Up @@ -503,9 +503,7 @@ private static boolean isTransparent(int pixel) {
@Test
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
ApkInfo testInfo = ApkInfo.load(sTestNewDir);
for (String path : testInfo.doNotCompress) {
assertNotEquals("jpg", path);
}
assertFalse(testInfo.doNotCompress.contains("jpg"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void beforeClass() throws Exception {
new ApkBuilder(sTestOrigDir, sConfig).build(testApk);

LOGGER.info("Decoding testapp.apk...");
sTestApkInfo = new ApkDecoder(testApk, sConfig).decode(sTestNewDir);
new ApkDecoder(testApk, sConfig).decode(sTestNewDir);
}

@Test
Expand Down Expand Up @@ -89,6 +89,13 @@ public void valuesBcp47LanguageScriptRegionVariantTest() throws BrutException {
compareValuesFiles("values-b+ast+Hant+IT+ARABEXT/strings.xml");
}

@Test
public void confirmFeatureFlagsRecorded() throws BrutException {
ApkInfo testInfo = ApkInfo.load(sTestNewDir);
assertTrue(testInfo.featureFlags.get("brut.feature.permission"));
assertTrue(testInfo.featureFlags.get("brut.feature.activity"));
}

@Test
public void confirmZeroByteFileExtensionIsNotStored() throws BrutException {
ApkInfo testInfo = ApkInfo.load(sTestNewDir);
Expand Down Expand Up @@ -159,15 +166,6 @@ public void unknownFolderTest() throws BrutException {
compareBinaryFolder("unknown");
}

@Test
public void featureFlagTest() {
assertNotNull(sTestApkInfo.featureFlags);
assertTrue(sTestApkInfo.featureFlags.containsKey("brut.feature.flag"));
// assertTrue(sTestApkInfo.featureFlags.containsKey("brut.activity.flag"));
assertEquals(true, sTestApkInfo.featureFlags.get("brut.feature.flag"));
// assertEquals(true, sTestApkInfo.featureFlags.get("brut.activity.flag"));
}

@Test
public void confirmPlatformManifestValuesTest() throws BrutException {
Document doc = loadDocument(new File(sTestNewDir, "AndroidManifest.xml"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<meta-data name="test_int_as_string" value="\ 12345" />
<meta-data name="test_int" value="12345" />
</application>
<activity android:name=".MainActivity" android:featureFlag="brut.activity.flag">
<activity android:name=".MainActivity" android:featureFlag="brut.feature.activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<permission android:featureFlag="brut.feature.flag" android:label="Test Permission" android:name="brut.permission.TEST" android:permissionGroup="android.permission-group.UNDEFINED" android:protectionLevel="signature" />
<permission android:featureFlag="brut.feature.permission" android:label="Test Permission" android:name="brut.permission.TEST" android:permissionGroup="android.permission-group.UNDEFINED" android:protectionLevel="signature" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ versionInfo:
versionCode: '1'
versionName: '1.0'
featureFlags:
brut.feature.flag: true
brut.activity.flag: true
brut.feature.permission: true
brut.feature.activity: true
doNotCompress:
- assets/0byte_file.jpg
sparseResources: false

0 comments on commit 1f3f634

Please sign in to comment.