Files
bot/apps/macos/Tests/BotIPCTests/VoicePushToTalkHotkeyTests.swift
zeekay 4bdc9ee3e4 chore: rebrand openclaw → hanzo-bot for bridge merge
Comprehensive rename of all openclaw references to hanzo-bot equivalents:
- Package: openclaw → @hanzo/bot
- Binary: openclaw → hanzo-bot
- Types: OpenClaw* → Bot*
- Env vars: OPENCLAW_* → BOT_*
- Android: ai.openclaw.android → ai.hanzo.bot.android
- iOS/macOS: ai.openclaw.* → ai.hanzo.*
- Swift modules: OpenClaw* → Bot*
- Plugins: openclaw.plugin.json → bot.plugin.json
- Paths: .openclaw/ → .hanzo/bot/
- URLs: github.com/openclaw → github.com/hanzoai
2026-02-26 22:36:01 -08:00

38 lines
1.2 KiB
Swift

import AppKit
import Testing
@testable import HanzoBot
@Suite(.serialized) struct VoicePushToTalkHotkeyTests {
actor Counter {
private(set) var began = 0
private(set) var ended = 0
func incBegin() { self.began += 1 }
func incEnd() { self.ended += 1 }
func snapshot() -> (began: Int, ended: Int) { (self.began, self.ended) }
}
@Test func beginEndFiresOncePerHold() async {
let counter = Counter()
let hotkey = VoicePushToTalkHotkey(
beginAction: { await counter.incBegin() },
endAction: { await counter.incEnd() })
await MainActor.run {
hotkey._testUpdateModifierState(keyCode: 61, modifierFlags: [.option])
hotkey._testUpdateModifierState(keyCode: 61, modifierFlags: [.option])
hotkey._testUpdateModifierState(keyCode: 61, modifierFlags: [])
}
for _ in 0..<50 {
let snap = await counter.snapshot()
if snap.began == 1, snap.ended == 1 { break }
try? await Task.sleep(nanoseconds: 10_000_000)
}
let snap = await counter.snapshot()
#expect(snap.began == 1)
#expect(snap.ended == 1)
}
}