feat: native clipboard image sync (Linux, opt-in sync_images)

This commit is contained in:
2026-08-14 09:51:25 -04:00
parent 884415c1c1
commit 147cba6d2a
15 changed files with 274 additions and 48 deletions
+32
View File
@@ -61,3 +61,35 @@ func TestBroadcastEmptyPeers(t *testing.T) {
b.Broadcast("test")
b.Broadcast("")
}
func TestBroadcastImage(t *testing.T) {
received := make(chan dedup.Payload, 1)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var p dedup.Payload
if err := json.NewDecoder(r.Body).Decode(&p); err != nil {
t.Errorf("decode: %v", err)
}
received <- p
w.WriteHeader(http.StatusNoContent)
}))
defer ts.Close()
b := NewBroadcaster([]config.PeerConfig{{Name: "p", Addr: ts.Listener.Addr().String()}}, "my-machine", Options{})
b.BroadcastImage("image/png", []byte{1, 2, 3})
select {
case p := <-received:
if p.Mime != "image/png" {
t.Errorf("mime = %q, want \"image/png\"", p.Mime)
}
if p.Data != "AQID" { // base64 of {1,2,3}
t.Errorf("data = %q, want \"AQID\"", p.Data)
}
if p.Text != "" {
t.Errorf("text = %q, want empty", p.Text)
}
case <-time.After(5 * time.Second):
t.Fatal("timeout waiting for image broadcast")
}
}