Files
openclaw/apps/ios/Tests/AppCoverageTests.swift
NianJiu 067edbcb2d fix(ios): make Talk audio lifecycle-safe (#103072)
* fix(ios): cancel queued push-to-talk invokes

* fix(ios): make push-to-talk cancellation lifecycle-safe

* style(ios): use switch expression for PTT result

* fix(ios): bind audio capture to lifecycle owners

Co-authored-by: NianJiuZst <180004567+NianJiuZst@users.noreply.github.com>

* style(ios): format rebased lifecycle changes

Co-authored-by: NianJiuZst <180004567+NianJiuZst@users.noreply.github.com>

* fix(ios): preserve routing hydration across reconnects

Co-authored-by: NianJiuZst <180004567+NianJiuZst@users.noreply.github.com>

* fix(ios): cancel routing hydration on target switch

Co-authored-by: NianJiuZst <180004567+NianJiuZst@users.noreply.github.com>

* chore(ios): refresh native i18n inventory

Co-authored-by: NianJiuZst <180004567+NianJiuZst@users.noreply.github.com>

* fix(i18n): preserve native localization IDs

* chore: leave changelog to release automation

* refactor(apple): split lifecycle and gateway helpers

Co-authored-by: NianJiuZst <180004567+NianJiuZst@users.noreply.github.com>

* fix(ios): make lifecycle parsing nonisolated

* fix(ios): consume canonical Talk events

---------

Co-authored-by: NianJiuZst <180004567+NianJiuZst@users.noreply.github.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-10 15:03:40 +01:00

60 lines
2.0 KiB
Swift

import OpenClawKit
import SwiftUI
import Testing
@testable import OpenClaw
struct AppCoverageTests {
@Test @MainActor func `node app model updates backgrounded state`() {
let appModel = NodeAppModel()
appModel.setScenePhase(.background)
#expect(appModel.isBackgrounded == true)
appModel.setScenePhase(.inactive)
#expect(appModel.isBackgrounded == true)
appModel.setScenePhase(.active)
#expect(appModel.isBackgrounded == false)
}
@Test @MainActor func `initial scene admission stays closed until active`() async {
let talkMode = TalkModeManager(allowSimulatorCapture: true)
let appModel = NodeAppModel(
talkMode: talkMode,
audioAdmissionInitiallyAllowed: false)
talkMode.updateGatewayConnected(true)
#expect(appModel.isBackgrounded)
#expect(appModel.voiceWake._test_isSuppressedForBackground())
let blocked = await appModel._test_handleInvoke(BridgeInvokeRequest(
id: "initial-scene-blocked",
command: OpenClawTalkCommand.pttStart.rawValue))
#expect(!blocked.ok)
appModel.setScenePhase(.active)
#expect(!appModel.isBackgrounded)
#expect(!appModel.voiceWake._test_isSuppressedForBackground())
let admitted = await appModel._test_handleInvoke(BridgeInvokeRequest(
id: "initial-scene-active",
command: OpenClawTalkCommand.pttStart.rawValue))
#expect(admitted.ok)
_ = await appModel._test_handleInvoke(BridgeInvokeRequest(
id: "initial-scene-cleanup",
command: OpenClawTalkCommand.pttCancel.rawValue))
}
@Test @MainActor func `voice wake start reports unsupported on simulator`() async {
let voiceWake = VoiceWakeManager()
voiceWake.isEnabled = true
await voiceWake.start()
#expect(voiceWake.isListening == false)
#expect(voiceWake.statusText.contains("Simulator"))
voiceWake.stop()
#expect(voiceWake.statusText == "Off")
}
}