Consolidate setup methods

This commit is contained in:
topjohnwu 2025-02-12 17:52:38 +08:00 committed by John Wu
parent b73d4a7022
commit 29043e1684
2 changed files with 17 additions and 22 deletions

View File

@ -42,33 +42,30 @@ class Environment : BaseTest {
} }
@Test @Test
fun setupMagisk() { fun setupEnvironment() {
runBlocking { runBlocking {
assertTrue( assertTrue(
"Magisk setup failed", "Magisk setup failed",
MagiskInstaller.Emulator(TimberLog, TimberLog).exec() MagiskInstaller.Emulator(TimberLog, TimberLog).exec()
) )
} }
}
@Test if (lsposed()) {
fun setupLsposed() { val notify = object : DownloadNotifier {
assumeTrue(lsposed()) override val context = appContext
override fun notifyUpdate(id: Int, editor: (Notification.Builder) -> Unit) {}
val notify = object : DownloadNotifier { }
override val context = appContext val processor = DownloadProcessor(notify)
override fun notifyUpdate(id: Int, editor: (Notification.Builder) -> Unit) {} val zip = appContext.cachedFile("lsposed.zip")
} runBlocking {
val processor = DownloadProcessor(notify) testContext.assets.open("lsposed.zip").use {
val zip = appContext.cachedFile("lsposed.zip") processor.handleModule(it, zip.toUri())
runBlocking { }
testContext.assets.open("lsposed.zip").use { assertTrue(
processor.handleModule(it, zip.toUri()) "LSPosed installation failed",
FlashZip(zip.toUri(), TimberLog, TimberLog).exec()
)
} }
assertTrue(
"LSPosed installation failed",
FlashZip(zip.toUri(), TimberLog, TimberLog).exec()
)
} }
} }

View File

@ -53,9 +53,7 @@ run_setup() {
local app='com.topjohnwu.magisk.test/com.topjohnwu.magisk.test.AppTestRunner' local app='com.topjohnwu.magisk.test/com.topjohnwu.magisk.test.AppTestRunner'
# Run setup through the test app # Run setup through the test app
am_instrument '.Environment#setupMagisk' $app am_instrument '.Environment#setupEnvironment' $app
# Install LSPosed
am_instrument '.Environment#setupLsposed' $app
} }
run_tests() { run_tests() {