Previously the PttController handed its real AudioTransmitGate to the platform backend and the backend wrote transmit_active directly on every key edge — bypassing the 200 ms release tail and the TransmitMode selector entirely. The tail timer was constructed and exposed on ChanoraSession but never received any input, so SDD-096 and SRS-206 were spec-only. Wire it: PttController now owns a synthetic 'press-edge gate' which it hands to the backend in place of the real one. An internal edge-watcher task subscribes to that press-gate, translating true/false transitions into ReleaseTailTimer.key_down/key_up calls. The release-tail timer feeds the selector's ptt_held input; the selector recomputes transmit_active honouring mode, in_channel, and hard_mute, and writes the real gate. Single owner of transmit_active is preserved (SAD-083 invariant). PttController::new now takes Arc<ReleaseTailTimer> instead of AudioTransmitGate; ChanoraSession threads its session-scoped timer through both the start_audio path and the supervisor reconnect path. The legacy bridge set_ptt call (still used by the in-focus Listener fallback and the e2e test) is rerouted through the timer so the same tail and mute semantics apply uniformly. ReleaseTailTimer gains force_release() — cancels any pending task AND clears the selector's ptt_held. PttController::stop uses it so shutdown can't leave transmit_active stuck at true. Tests - press_edge_drives_selector_through_release_tail: backend press edge → real gate follows, key_up → tail keeps gate true for tail window then clears. - stop_clears_press_and_cancels_tail: stop() drops transmit even with a tail in flight. - e2e test now sets release_tail_ms=0 + waits one tick so the pttActive=false assertion isn't racing the default 200 ms tail. cargo test --workspace --lib: 74 passed / 0 failed / 1 ignored (+2 new tests vs. the previous 72). flutter analyze: clean (6 pre-existing Radio.groupValue infos).
76 lines
2.7 KiB
Dart
76 lines
2.7 KiB
Dart
// Beta end-to-end verification test.
|
|
//
|
|
// Runs the full Dart → FRB → Rust → tsclientlib → cn.teamspeak.app
|
|
// path, including the audio engine. Verifies:
|
|
// 1. Connect + snapshot still work (Alpha regression).
|
|
// 2. Audio engine starts.
|
|
// 3. PTT toggles successfully.
|
|
// 4. Encoder produces Opus frames while PTT is held.
|
|
// 5. Disconnect cleans both protocol and audio.
|
|
//
|
|
// Network-dependent. Quietly tolerates a server that rejects voice
|
|
// (e.g. because the test account is not yet allowed to talk).
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:chanora_flutter/src/rust/api.dart' as rust;
|
|
import 'package:chanora_flutter/src/rust/frb_generated.dart';
|
|
|
|
void main() {
|
|
setUpAll(() async {
|
|
await RustLib.init();
|
|
});
|
|
|
|
test('connect → start_audio → PTT cycle → disconnect', () async {
|
|
// Defensive cleanup in case a previous test left state.
|
|
try {
|
|
await rust.disconnect();
|
|
} catch (_) {}
|
|
|
|
final snap = await rust.connect(
|
|
host: 'cn.teamspeak.app',
|
|
nickname: 'ChanoraBetaTest',
|
|
password: '',
|
|
);
|
|
expect(snap.serverName, isNotEmpty);
|
|
expect(snap.channels, isNotEmpty);
|
|
|
|
await rust.voiceJoin(channelId: snap.channels.first.id, password: '');
|
|
|
|
// Zero out the release tail so set_ptt(false) takes effect
|
|
// synchronously — the default 200 ms tail (SDD-096) would
|
|
// otherwise delay the assertion below.
|
|
await rust.setReleaseTailMs(ms: 0);
|
|
|
|
// Initial stats: PTT off, no frames sent yet.
|
|
final s0 = await rust.audioStats();
|
|
expect(s0.pttActive, isFalse);
|
|
expect(s0.framesSent, 0);
|
|
|
|
// Press PTT, wait ~250 ms, then read stats. If the host has a
|
|
// real microphone the encoder will emit ~10-12 frames. If the
|
|
// host has only a null source (typical headless), capture will
|
|
// have logged a warning at startAudio time and run in
|
|
// playback-only mode; framesSent stays at 0. Either outcome is
|
|
// a successful test of the wiring — what we actually verify
|
|
// here is that the PTT flag changes and no exception is thrown.
|
|
await rust.setPtt(active: true);
|
|
await Future<void>.delayed(const Duration(milliseconds: 250));
|
|
final s1 = await rust.audioStats();
|
|
expect(s1.pttActive, isTrue);
|
|
|
|
await rust.setPtt(active: false);
|
|
// Give the release-tail (set to 0 above) one tick to settle.
|
|
await Future<void>.delayed(const Duration(milliseconds: 50));
|
|
final s2 = await rust.audioStats();
|
|
expect(s2.pttActive, isFalse);
|
|
|
|
await rust.disconnect();
|
|
final connectedAfter = await rust.isConnected();
|
|
expect(connectedAfter, isFalse);
|
|
|
|
// ignore: avoid_print
|
|
print('Beta E2E: TX=${s1.framesSent} frames, RX=${s1.framesReceived} frames');
|
|
}, timeout: const Timeout(Duration(seconds: 30)));
|
|
}
|