-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add State for RunTestAndroidCorellium
- Loading branch information
Showing
7 changed files
with
221 additions
and
110 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
corellium/adapter/src/main/kotlin/flank/corellium/adapter/ParseApk.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package flank.corellium.adapter | ||
|
||
import com.linkedin.dex.parser.DexParser | ||
import com.linkedin.dex.parser.TestMethod | ||
import flank.corellium.api.Apk | ||
import net.dongliu.apk.parser.ApkFile | ||
import org.xml.sax.InputSource | ||
import java.io.StringReader | ||
import javax.xml.parsers.DocumentBuilderFactory | ||
|
||
object ParseApkTestCases : Apk.ParseTestCases, (String) -> List<String> by { path -> | ||
DexParser.findTestMethods(path).map(TestMethod::testName) | ||
} | ||
|
||
object ParseApkPackageName : Apk.ParsePackageName, (String) -> String by { path -> | ||
ApkFile(path).apkMeta.packageName | ||
} | ||
|
||
object ParseApkInfo : Apk.ParseInfo, (String) -> Apk.Info by { path -> | ||
Apk.Info( | ||
packageName = ApkFile(path).apkMeta.packageName, | ||
testRunner = DocumentBuilderFactory.newInstance() | ||
.newDocumentBuilder() | ||
.parse(InputSource(StringReader(ApkFile(path).manifestXml))) | ||
.getElementsByTagName("instrumentation").item(0).attributes | ||
.getNamedItem("android:name").nodeValue | ||
) | ||
} |
13 changes: 0 additions & 13 deletions
13
corellium/adapter/src/main/kotlin/flank/corellium/adapter/ParseTestApk.kt
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
corellium/adapter/src/test/kotlin/flank/corellium/adapter/ParseApkTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package flank.corellium.adapter | ||
|
||
import flank.corellium.api.Apk | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
private const val TEST_APK_PATH = "../../test_artifacts/master/apk/app-single-success-debug-androidTest.apk" | ||
|
||
class ParseApkTest { | ||
|
||
@Test | ||
fun parseTestCases() { | ||
assertEquals( | ||
listOf( | ||
"com.example.test_app.InstrumentedTest#ignoredTestWithIgnore", | ||
"com.example.test_app.InstrumentedTest#ignoredTestWithSuppress", | ||
"com.example.test_app.InstrumentedTest#test", | ||
), | ||
ParseApkTestCases(TEST_APK_PATH) | ||
) | ||
} | ||
|
||
@Test | ||
fun parsePackageName() { | ||
assertEquals( | ||
"com.example.test_app.test", | ||
ParseApkPackageName(TEST_APK_PATH) | ||
) | ||
} | ||
|
||
@Test | ||
fun parseInfo() { | ||
assertEquals( | ||
Apk.Info( | ||
packageName = "com.example.test_app.test", | ||
testRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
), | ||
ParseApkInfo(TEST_APK_PATH) | ||
) | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
corellium/adapter/src/test/kotlin/flank/corellium/adapter/ParseTestApkTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.