Files
FlClash/android/tests/common/EnumsTest.kt
T
chen08209 ae29f38f6b feat(android): rework the VPN service, tile, lifecycle arbitration, and native build
ServiceState serializes start, stop, and restart intents so the latest
request wins, and switching between VPN and proxy mode tears the previous
service down the way stop() does before binding the next one, so a
system-started VpnService no longer outlives the switch. The package
resolver drops its cache on package add, replace, and remove broadcasts
and notifies Flutter, and the persistent notification can omit its stop
action through an application setting synced over the shared state.

The :core module takes the NDK clang directory and API level from the
setup build hook input instead of ANDROID_NDK and a hardcoded API 21, and
derives its ABI list from the target-platform property so a single-ABI
build no longer links ABIs the hook did not produce.

Changelog: Rework the Android VPN service and lifecycle handling
2026-09-10 12:42:59 +08:00

48 lines
1.4 KiB
Kotlin

package com.follow.clash.common
import com.google.gson.Gson
import org.junit.Assert.assertEquals
import org.junit.Test
/**
* The Flutter layer exchanges these enums as JSON, so the serialized spelling is a cross-language
* contract rather than an implementation detail.
*/
class EnumsTest {
private val gson = Gson()
@Test
fun `access control mode serializes to the Dart spelling`() {
assertEquals("\"acceptSelected\"", gson.toJson(AccessControlMode.ACCEPT_SELECTED))
assertEquals("\"rejectSelected\"", gson.toJson(AccessControlMode.REJECT_SELECTED))
}
@Test
fun `access control mode deserializes from the Dart spelling`() {
assertEquals(
AccessControlMode.ACCEPT_SELECTED,
gson.fromJson("\"acceptSelected\"", AccessControlMode::class.java),
)
assertEquals(
AccessControlMode.REJECT_SELECTED,
gson.fromJson("\"rejectSelected\"", AccessControlMode::class.java),
)
}
@Test
fun `quick action names back the intent action suffixes`() {
assertEquals(
listOf("STOP", "START", "TOGGLE"),
QuickAction.entries.map { it.name },
)
}
@Test
fun `broadcast action names back the intent action suffixes`() {
assertEquals(
listOf("VPN_START_REQUESTED", "VPN_REVOKED"),
BroadcastAction.entries.map { it.name },
)
}
}