Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
//go:build !js
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"slices"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo"
|
|
"github.com/egoist/mygo/internal/wait"
|
|
)
|
|
|
|
// clipboardChanges records the text the clipboard held at each change a
|
|
// listener heard.
|
|
type clipboardChanges struct {
|
|
mu sync.Mutex
|
|
texts []string
|
|
}
|
|
|
|
func (c *clipboardChanges) listen() {
|
|
text := mygo.Clipboard.ReadText()
|
|
c.mu.Lock()
|
|
c.texts = append(c.texts, text)
|
|
c.mu.Unlock()
|
|
}
|
|
|
|
func (c *clipboardChanges) heard(text string) func() bool {
|
|
return func() bool {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
return slices.Contains(c.texts, text)
|
|
}
|
|
}
|
|
|
|
func (c *clipboardChanges) count() int {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
return len(c.texts)
|
|
}
|
|
|
|
func TestClipboardChangeNotifications(t *testing.T) {
|
|
preserveClipboard(t)
|
|
var first, second clipboardChanges
|
|
off := mygo.Clipboard.OnChanged(first.listen)
|
|
t.Cleanup(off)
|
|
mygo.Clipboard.WriteText("clipboard observation 日本語")
|
|
wait.Until(t, "a change with the text written", first.heard("clipboard observation 日本語"))
|
|
mygo.Clipboard.Clear()
|
|
wait.Until(t, "a change for the cleared clipboard", first.heard(""))
|
|
|
|
// A listener that stays tells when a change was delivered: once it heard
|
|
// the next one, the listener removed before could have heard it too.
|
|
t.Cleanup(mygo.Clipboard.OnChanged(second.listen))
|
|
off()
|
|
off()
|
|
heard := first.count()
|
|
mygo.Clipboard.WriteText("after unsubscribe")
|
|
wait.Until(t, "the remaining listener to hear the change", second.heard("after unsubscribe"))
|
|
if n := first.count(); n != heard {
|
|
t.Fatalf("a removed listener heard %d more changes", n-heard)
|
|
}
|
|
}
|