From df385a7ed6f22b1cf5c0faed34e2f74e11585e54 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Mon, 30 Mar 2026 11:22:20 +0530 Subject: [PATCH] test: tighten android node contracts --- .../ai/openclaw/app/node/DeviceHandlerTest.kt | 13 +++++++++ .../app/node/InvokeCommandRegistryTest.kt | 28 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/apps/android/app/src/test/java/ai/openclaw/app/node/DeviceHandlerTest.kt b/apps/android/app/src/test/java/ai/openclaw/app/node/DeviceHandlerTest.kt index 28904867886..4414a2dbf6a 100644 --- a/apps/android/app/src/test/java/ai/openclaw/app/node/DeviceHandlerTest.kt +++ b/apps/android/app/src/test/java/ai/openclaw/app/node/DeviceHandlerTest.kt @@ -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()) diff --git a/apps/android/app/src/test/java/ai/openclaw/app/node/InvokeCommandRegistryTest.kt b/apps/android/app/src/test/java/ai/openclaw/app/node/InvokeCommandRegistryTest.kt index e2bc9bd7016..af75a06999a 100644 --- a/apps/android/app/src/test/java/ai/openclaw/app/node/InvokeCommandRegistryTest.kt +++ b/apps/android/app/src/test/java/ai/openclaw/app/node/InvokeCommandRegistryTest.kt @@ -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,