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.
74 lines
2.7 KiB
Go
74 lines
2.7 KiB
Go
//go:build windows
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo"
|
|
win "github.com/egoist/mygo/internal/windows"
|
|
"github.com/egoist/mygo/ui"
|
|
)
|
|
|
|
// Hit-test codes.
|
|
const (
|
|
htClient = 1
|
|
htTop = 12
|
|
htTopLeft = 13
|
|
htTopRight = 14
|
|
)
|
|
|
|
// A resizable window without a caption resizes from its top edge, within
|
|
// the thickness of the system's resize border, above its page or native
|
|
// UI, as from its other edges; below, presses reach the content, whose
|
|
// drag regions move the window. One that cannot resize, or is maximized,
|
|
// leaves the whole top to the content.
|
|
func TestCaptionlessTopEdge(t *testing.T) {
|
|
page := `<body style="margin:0"><div style="--app-region:drag;height:48px">drag</div></body>`
|
|
for name, c := range map[string]struct {
|
|
opts mygo.WindowOptions
|
|
rightEdge bool // the edge reaches the top-right corner
|
|
}{
|
|
"frameless": {mygo.WindowOptions{Frameless: true}, true},
|
|
"frameless with acrylic": {mygo.WindowOptions{Frameless: true, Transparent: true, Vibrancy: mygo.VibrancyAcrylic}, true},
|
|
"frameless native UI": {mygo.WindowOptions{Frameless: true, Content: ui.View(func(c *ui.Context) { ui.Text(c, "native") })}, true},
|
|
"hidden title bar": {mygo.WindowOptions{TitleBarStyle: mygo.TitleBarHidden}, false},
|
|
"hidden title, no buttons": {mygo.WindowOptions{TitleBarStyle: mygo.TitleBarHidden, HideWindowButtons: true}, true},
|
|
} {
|
|
t.Run(name, func(t *testing.T) {
|
|
opts := c.opts
|
|
opts.X, opts.Y, opts.Width, opts.Height = 120, 120, 420, 300
|
|
w := newWindow(t, opts)
|
|
if opts.Content == nil {
|
|
w.Page().LoadHTML(page, "")
|
|
waitFor(t, w, "document.readyState === 'complete'")
|
|
}
|
|
hit := func(x, y int32) (h uintptr) {
|
|
mygo.RunOnMain(func() { h = win.TestHitTest(w.NativeHandle(), x, y) })
|
|
return h
|
|
}
|
|
eventually(t, "the top edge to resize the window", func() bool { return hit(210, 1) == htTop })
|
|
if h := hit(1, 1); h != htTopLeft {
|
|
t.Errorf("top-left corner: hit test = %d, want HTTOPLEFT", h)
|
|
}
|
|
if h := hit(-2, 1); c.rightEdge && h != htTopRight {
|
|
t.Errorf("top-right corner: hit test = %d, want HTTOPRIGHT", h)
|
|
}
|
|
// Below the resize border, 8 DIPs: the content's, at 300% too.
|
|
if h := hit(210, 40); h != htClient {
|
|
t.Errorf("below the top edge: hit test = %d, want HTCLIENT (the content's)", h)
|
|
}
|
|
w.SetResizable(false)
|
|
if h := hit(210, 1); h != htClient {
|
|
t.Errorf("not resizable: hit test at the top = %d, want HTCLIENT", h)
|
|
}
|
|
w.SetResizable(true)
|
|
w.Maximize()
|
|
eventually(t, "the window maximized", w.IsMaximized)
|
|
if h := hit(210, 1); h != htClient {
|
|
t.Errorf("maximized: hit test at the top = %d, want HTCLIENT", h)
|
|
}
|
|
})
|
|
}
|
|
}
|