From fc6d61e41b1b0e0686d1346694445dc119b97872 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sun, 28 Jun 2026 23:58:07 +0800
Subject: [PATCH] Fix hold recording head and tail clipping
---
privatevoice.src/app_live_caption_test.go | 44 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/privatevoice.src/app_live_caption_test.go b/privatevoice.src/app_live_caption_test.go
index 7dd3a0a..c8380a7 100644
--- a/privatevoice.src/app_live_caption_test.go
+++ b/privatevoice.src/app_live_caption_test.go
@@ -29,12 +29,30 @@
}
}
-func TestReleaseTailCaptureDelayDefaultsToZero(t *testing.T) {
+func TestReleaseTailCaptureDelayCanBeDisabledByEngineCapability(t *testing.T) {
a := &App{}
- a.replaceEngine(plainTestEngine{})
+ a.replaceEngine(tailCaptureTestEngine{delay: 0})
if got := a.releaseTailCaptureDelay(); got != 0 {
t.Fatalf("releaseTailCaptureDelay() = %v, want 0", got)
+ }
+}
+
+func TestReleaseTailCaptureDelayDefaultsToProtectionWindow(t *testing.T) {
+ a := &App{}
+ a.replaceEngine(plainTestEngine{})
+
+ if got := a.releaseTailCaptureDelay(); got != defaultReleaseTailDelay {
+ t.Fatalf("releaseTailCaptureDelay() = %v, want %v", got, defaultReleaseTailDelay)
+ }
+}
+
+func TestReleaseTailCaptureDelayDisabledWithoutEngine(t *testing.T) {
+ a := &App{}
+ a.replaceEngine(nil)
+
+ if got := a.releaseTailCaptureDelay(); got != 0 {
+ t.Fatalf("releaseTailCaptureDelay() = %v, want 0 without engine", got)
}
}
@@ -47,12 +65,30 @@
}
}
-func TestHoldPreCaptureDefaultsToFalse(t *testing.T) {
+func TestHoldPreCaptureCanBeDisabledByEngineCapability(t *testing.T) {
+ a := &App{}
+ a.replaceEngine(holdPreCaptureTestEngine{enabled: false})
+
+ if a.holdPreCaptureEnabled.Load() {
+ t.Fatal("hold pre-capture should respect engine capability false")
+ }
+}
+
+func TestHoldPreCaptureDefaultsToTrueForReadyEngine(t *testing.T) {
a := &App{}
a.replaceEngine(plainTestEngine{})
+ if !a.holdPreCaptureEnabled.Load() {
+ t.Fatal("hold pre-capture should default to true for ready engines")
+ }
+}
+
+func TestHoldPreCaptureDisabledWithoutEngine(t *testing.T) {
+ a := &App{}
+ a.replaceEngine(nil)
+
if a.holdPreCaptureEnabled.Load() {
- t.Fatal("hold pre-capture should default to false")
+ t.Fatal("hold pre-capture should be disabled without an engine")
}
}
--
Gitblit v1.9.3