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.
83 lines
2.7 KiB
Go
83 lines
2.7 KiB
Go
//go:build windows && (amd64 || arm64)
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"image/color"
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo"
|
|
win "github.com/egoist/mygo/internal/windows"
|
|
"github.com/egoist/mygo/ui"
|
|
)
|
|
|
|
// Menu items show icons beside their labels, with their checks, change
|
|
// them in place, and free their bitmaps (Windows 10's) as they do and as
|
|
// their menus go.
|
|
func TestMenuIconsWindows(t *testing.T) {
|
|
japan := menuIcon(t, 48, 32, color.NRGBA{255, 0, 0, 255}) // 3:2, as flags
|
|
square := menuIcon(t, 64, 64, color.NRGBA{0, 0, 255, 128})
|
|
menu := mygo.NewMenu([]*mygo.MenuItem{
|
|
{Label: "Servers", Icon: japan, Submenu: []*mygo.MenuItem{
|
|
{ID: "tokyo", Label: "Tokyo", Type: mygo.MenuItemRadio, Checked: true, Icon: japan},
|
|
{ID: "ny", Label: "New York", Type: mygo.MenuItemRadio, Icon: square},
|
|
{ID: "direct", Label: "Direct", Type: mygo.MenuItemRadio},
|
|
}},
|
|
})
|
|
w := newWindow(t, mygo.WindowOptions{Width: 300, Height: 200, Content: ui.View(func(c *ui.Context) { ui.Text(c, "menus") })})
|
|
w.SetMenu(menu)
|
|
type state struct {
|
|
w, h int
|
|
checked bool
|
|
}
|
|
at := func(path ...string) (s state) {
|
|
var err error
|
|
mygo.RunOnMain(func() { s.w, s.h, s.checked, err = win.TestMenuItemIcon(w.NativeHandle(), path...) })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return s
|
|
}
|
|
want := func(what string, got, want state) {
|
|
t.Helper()
|
|
if got != want {
|
|
t.Errorf("%s = %+v, want %+v", what, got, want)
|
|
}
|
|
}
|
|
want("Tokyo", at("Servers", "Tokyo"), state{16, 11, true})
|
|
want("New York", at("Servers", "New York"), state{16, 16, false})
|
|
want("Direct", at("Servers", "Direct"), state{0, 0, false})
|
|
|
|
menu.ItemByID("direct").SetIcon(square)
|
|
eventually(t, "Direct to get an icon", func() bool { return at("Servers", "Direct") == state{16, 16, false} })
|
|
menu.ItemByID("tokyo").SetIcon(nil)
|
|
eventually(t, "Tokyo to lose its icon", func() bool { return at("Servers", "Tokyo") == state{0, 0, true} })
|
|
menu.ItemByID("ny").SetChecked(true)
|
|
eventually(t, "New York checked with its icon", func() bool {
|
|
return at("Servers", "New York") == state{16, 16, true} && !at("Servers", "Tokyo").checked
|
|
})
|
|
|
|
// Replacing icons and building the menu again leaves no bitmaps behind.
|
|
var before int
|
|
mygo.RunOnMain(func() { before = win.TestGDIObjects() })
|
|
for i := range 200 {
|
|
ic := japan
|
|
if i%2 == 1 {
|
|
ic = square
|
|
}
|
|
for _, id := range []string{"tokyo", "ny", "direct"} {
|
|
menu.ItemByID(id).SetIcon(ic)
|
|
}
|
|
if i%10 == 0 {
|
|
w.SetMenu(menu)
|
|
}
|
|
}
|
|
w.SetMenu(menu)
|
|
eventually(t, "the last icons", func() bool { return at("Servers", "Tokyo") == state{16, 16, false} })
|
|
var after int
|
|
mygo.RunOnMain(func() { after = win.TestGDIObjects() })
|
|
if after > before+8 {
|
|
t.Errorf("GDI objects went from %d to %d over 600 replaced icons", before, after)
|
|
}
|
|
}
|