mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-04-29 21:04:26 +02:00

This commit converts various APIs to Kotlin DSL. BREAKING CHANGE: Various old APIs are removed, and DSL APIs are added instead.
68 lines
1.7 KiB
Kotlin
68 lines
1.7 KiB
Kotlin
package app.revanced.patcher.patch
|
|
|
|
import app.revanced.patcher.fingerprint
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertEquals
|
|
|
|
internal object PatchTest {
|
|
@Test
|
|
fun `can create patch with name`() {
|
|
val patch = bytecodePatch(name = "Test") {}
|
|
|
|
assertEquals("Test", patch.name)
|
|
}
|
|
|
|
@Test
|
|
fun `can create patch with compatible packages`() {
|
|
val patch = bytecodePatch(name = "Test") {
|
|
compatibleWith(
|
|
"compatible.package"("1.0.0"),
|
|
)
|
|
}
|
|
|
|
assertEquals(1, patch.compatiblePackages!!.size)
|
|
assertEquals("compatible.package", patch.compatiblePackages!!.first().first)
|
|
}
|
|
|
|
@Test
|
|
fun `can create patch with fingerprints`() {
|
|
val externalFingerprint = fingerprint {}
|
|
|
|
val patch = bytecodePatch(name = "Test") {
|
|
val externalFingerprintMatch by externalFingerprint()
|
|
val internalFingerprintMatch by fingerprint {}
|
|
|
|
execute {
|
|
externalFingerprintMatch.method
|
|
internalFingerprintMatch.method
|
|
}
|
|
}
|
|
|
|
assertEquals(2, patch.fingerprints.size)
|
|
}
|
|
|
|
@Test
|
|
fun `can create patch with dependencies`() {
|
|
val patch = bytecodePatch(name = "Test") {
|
|
dependsOn(resourcePatch {})
|
|
}
|
|
|
|
assertEquals(1, patch.dependencies.size)
|
|
}
|
|
|
|
@Test
|
|
fun `can create patch with options`() {
|
|
val patch = bytecodePatch(name = "Test") {
|
|
val print by stringOption("print")
|
|
val custom = option<String>("custom")()
|
|
|
|
execute {
|
|
println(print)
|
|
println(custom.value)
|
|
}
|
|
}
|
|
|
|
assertEquals(2, patch.options.size)
|
|
}
|
|
}
|