From d14fa75079de570cb9c4dbf63f6b5bd65f959b09 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sun, 14 Jun 2026 20:14:34 +0800
Subject: [PATCH] Fix X-ASR release tail capture
---
privatevoice.src/app_live_caption_test.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/privatevoice.src/app_live_caption_test.go b/privatevoice.src/app_live_caption_test.go
index 55b8316..b8804c1 100644
--- a/privatevoice.src/app_live_caption_test.go
+++ b/privatevoice.src/app_live_caption_test.go
@@ -3,6 +3,7 @@
import (
"strings"
"testing"
+ "time"
)
func TestLiveCaptionDisplayTextFitsOverlayBuffer(t *testing.T) {
@@ -18,3 +19,56 @@
t.Fatalf("caption = %q, want leading truncation marker", got)
}
}
+
+func TestReleaseTailCaptureDelayUsesEngineCapability(t *testing.T) {
+ a := &App{}
+ a.replaceEngine(tailCaptureTestEngine{delay: 300 * time.Millisecond})
+
+ if got := a.releaseTailCaptureDelay(); got != 300*time.Millisecond {
+ t.Fatalf("releaseTailCaptureDelay() = %v, want 300ms", got)
+ }
+}
+
+func TestReleaseTailCaptureDelayDefaultsToZero(t *testing.T) {
+ a := &App{}
+ a.replaceEngine(plainTestEngine{})
+
+ if got := a.releaseTailCaptureDelay(); got != 0 {
+ t.Fatalf("releaseTailCaptureDelay() = %v, want 0", got)
+ }
+}
+
+func TestStartRecordingIgnoredWhileStoppingRecording(t *testing.T) {
+ a := &App{isStoppingRecording: true}
+
+ a.startRecordingLocked()
+
+ if a.isRecording {
+ t.Fatal("startRecordingLocked should not start while stop tail capture is pending")
+ }
+}
+
+func TestStartTapRecordingIgnoredWhileStoppingRecording(t *testing.T) {
+ a := &App{isStoppingRecording: true}
+
+ a.startTapRecordingLocked()
+
+ if a.isRecording || a.isFreetalking {
+ t.Fatal("startTapRecordingLocked should not start while stop tail capture is pending")
+ }
+}
+
+type plainTestEngine struct{}
+
+func (plainTestEngine) Recognize([]float32) (string, error) { return "", nil }
+func (plainTestEngine) HardwareInfo() string { return "test" }
+func (plainTestEngine) Close() {}
+
+type tailCaptureTestEngine struct {
+ plainTestEngine
+ delay time.Duration
+}
+
+func (e tailCaptureTestEngine) ReleaseTailCaptureDelay() time.Duration {
+ return e.delay
+}
--
Gitblit v1.9.3