Ariver
2026-06-14 e86df221fa8f9d6796fb7fe59020767d7c806fac
privatevoice.src/app_live_caption_test.go
@@ -38,6 +38,56 @@
   }
}
func TestHoldPreCaptureUsesEngineCapability(t *testing.T) {
   a := &App{}
   a.replaceEngine(holdPreCaptureTestEngine{enabled: true})
   if !a.holdPreCaptureEnabled.Load() {
      t.Fatal("hold pre-capture should be enabled by engine capability")
   }
}
func TestHoldPreCaptureDefaultsToFalse(t *testing.T) {
   a := &App{}
   a.replaceEngine(plainTestEngine{})
   if a.holdPreCaptureEnabled.Load() {
      t.Fatal("hold pre-capture should default to false")
   }
}
func TestShouldStartHoldPreCaptureLocked(t *testing.T) {
   a := &App{}
   a.holdPreCaptureEnabled.Store(true)
   if !a.shouldStartHoldPreCaptureLocked() {
      t.Fatal("expected hold pre-capture to start when enabled and idle")
   }
   a.isRecording = true
   if a.shouldStartHoldPreCaptureLocked() {
      t.Fatal("should not pre-capture while already recording")
   }
   a.isRecording = false
   a.isStoppingRecording = true
   if a.shouldStartHoldPreCaptureLocked() {
      t.Fatal("should not pre-capture while stopping")
   }
   a.isStoppingRecording = false
   a.isFreetalking = true
   if a.shouldStartHoldPreCaptureLocked() {
      t.Fatal("should not pre-capture while tap recording is active")
   }
   a.isFreetalking = false
   a.lastStopTime = time.Now()
   if a.shouldStartHoldPreCaptureLocked() {
      t.Fatal("should not pre-capture during post-stop debounce")
   }
}
func TestStartRecordingIgnoredWhileStoppingRecording(t *testing.T) {
   a := &App{isStoppingRecording: true}
@@ -72,3 +122,12 @@
func (e tailCaptureTestEngine) ReleaseTailCaptureDelay() time.Duration {
   return e.delay
}
type holdPreCaptureTestEngine struct {
   plainTestEngine
   enabled bool
}
func (e holdPreCaptureTestEngine) HoldPreCaptureEnabled() bool {
   return e.enabled
}