//go:build darwin
|
|
package input
|
|
import "testing"
|
|
func TestResolveDarwinRestoreTargetCarriesOriginalAcrossRapidPastes(t *testing.T) {
|
original := darwinClipboardSnapshot{text: "user clipboard", hasText: true}
|
current := darwinClipboardSnapshot{text: "first dictated text", hasText: true}
|
|
got := resolveDarwinRestoreTarget(current, true, "first dictated text", original)
|
if got != original {
|
t.Fatalf("restore target = %+v, want original %+v", got, original)
|
}
|
}
|
|
func TestResolveDarwinRestoreTargetUsesCurrentWhenClipboardChanged(t *testing.T) {
|
original := darwinClipboardSnapshot{text: "user clipboard", hasText: true}
|
current := darwinClipboardSnapshot{text: "external clipboard update", hasText: true}
|
|
got := resolveDarwinRestoreTarget(current, true, "first dictated text", original)
|
if got != current {
|
t.Fatalf("restore target = %+v, want current %+v", got, current)
|
}
|
}
|
|
func TestShouldRestoreDarwinClipboardRequiresCurrentGenerationAndText(t *testing.T) {
|
current := darwinClipboardSnapshot{text: "dictated text", hasText: true}
|
|
if !shouldRestoreDarwinClipboard(3, 3, true, "dictated text", "dictated text", current) {
|
t.Fatal("expected current generation with matching clipboard to restore")
|
}
|
|
if shouldRestoreDarwinClipboard(4, 3, true, "dictated text", "dictated text", current) {
|
t.Fatal("stale generation must not restore")
|
}
|
|
changed := darwinClipboardSnapshot{text: "user changed clipboard", hasText: true}
|
if shouldRestoreDarwinClipboard(3, 3, true, "dictated text", "dictated text", changed) {
|
t.Fatal("changed clipboard must not be overwritten")
|
}
|
}
|