test: tighten android node contracts

This commit is contained in:
Ayaan Zaidi 2026-03-30 11:22:20 +05:30
parent f1e7a5ce5f
commit df385a7ed6
No known key found for this signature in database
2 changed files with 41 additions and 0 deletions

View File

@ -213,6 +213,19 @@ class DeviceHandlerTest {
)
}
@Test
fun handleDevicePermissions_marksCallLogUnpromptableWhenFeatureDisabled() {
val handler = DeviceHandler(appContext(), callLogEnabled = false)
val result = handler.handleDevicePermissions(null)
assertTrue(result.ok)
val payload = parsePayload(result.payloadJson)
val callLog = payload.getValue("permissions").jsonObject.getValue("callLog").jsonObject
assertEquals("denied", callLog.getValue("status").jsonPrimitive.content)
assertTrue(!callLog.getValue("promptable").jsonPrimitive.boolean)
}
@Test
fun handleDeviceHealth_returnsExpectedShape() {
val handler = DeviceHandler(appContext())

View File

@ -12,6 +12,9 @@ import ai.openclaw.app.protocol.OpenClawNotificationsCommand
import ai.openclaw.app.protocol.OpenClawPhotosCommand
import ai.openclaw.app.protocol.OpenClawSmsCommand
import ai.openclaw.app.protocol.OpenClawSystemCommand
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
@ -203,6 +206,31 @@ class InvokeCommandRegistryTest {
assertFalse(capabilities.contains(OpenClawCapability.CallLog.rawValue))
}
@Test
fun advertisedCapabilities_includesVoiceWakeWithoutAdvertisingCommands() {
val capabilities = InvokeCommandRegistry.advertisedCapabilities(defaultFlags(voiceWakeEnabled = true))
val commands = InvokeCommandRegistry.advertisedCommands(defaultFlags(voiceWakeEnabled = true))
assertTrue(capabilities.contains(OpenClawCapability.VoiceWake.rawValue))
assertFalse(commands.any { it.contains("voice", ignoreCase = true) })
}
@Test
fun find_returnsForegroundMetadataForCameraCommands() {
val list = InvokeCommandRegistry.find(OpenClawCameraCommand.List.rawValue)
val location = InvokeCommandRegistry.find(OpenClawLocationCommand.Get.rawValue)
assertNotNull(list)
assertEquals(true, list?.requiresForeground)
assertNotNull(location)
assertEquals(false, location?.requiresForeground)
}
@Test
fun find_returnsNullForUnknownCommand() {
assertNull(InvokeCommandRegistry.find("not.real"))
}
private fun defaultFlags(
cameraEnabled: Boolean = false,
locationEnabled: Boolean = false,