From 2ba1056c56435f8d98110eca18dba90dc344de66 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Wed, 01 Jul 2026 23:57:44 +0800
Subject: [PATCH] Polish Windows overlay preview
---
privatevoice.src/app_live_caption_test.go | 64 ++++++++++++++++++++++++++++++-
1 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/privatevoice.src/app_live_caption_test.go b/privatevoice.src/app_live_caption_test.go
index 7dd3a0a..321f388 100644
--- a/privatevoice.src/app_live_caption_test.go
+++ b/privatevoice.src/app_live_caption_test.go
@@ -29,12 +29,52 @@
}
}
-func TestReleaseTailCaptureDelayDefaultsToZero(t *testing.T) {
+func TestReleaseTailCaptureDelayCanBeDisabledByEngineCapability(t *testing.T) {
+ a := &App{}
+ a.replaceEngine(tailCaptureTestEngine{delay: 0})
+
+ if got := a.releaseTailCaptureDelay(); got != 0 {
+ t.Fatalf("releaseTailCaptureDelay() = %v, want 0", got)
+ }
+}
+
+func TestReleaseTailCaptureDelayDefaultsToNoProtectionWindow(t *testing.T) {
a := &App{}
a.replaceEngine(plainTestEngine{})
if got := a.releaseTailCaptureDelay(); got != 0 {
t.Fatalf("releaseTailCaptureDelay() = %v, want 0", got)
+ }
+}
+
+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)
+ }
+}
+
+func TestSlowRecognitionReason(t *testing.T) {
+ tests := []struct {
+ name string
+ recognizeMS int64
+ totalMS int64
+ want string
+ }{
+ {name: "fast", recognizeMS: 2000, totalMS: 2500, want: ""},
+ {name: "recognize", recognizeMS: 2001, totalMS: 2400, want: "recognize"},
+ {name: "total", recognizeMS: 1000, totalMS: 2501, want: "total"},
+ {name: "both", recognizeMS: 2001, totalMS: 2501, want: "recognize,total"},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := slowRecognitionReason(tt.recognizeMS, tt.totalMS); got != tt.want {
+ t.Fatalf("slowRecognitionReason(%d, %d) = %q, want %q", tt.recognizeMS, tt.totalMS, got, tt.want)
+ }
+ })
}
}
@@ -47,12 +87,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