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.
100 lines
3.9 KiB
Go
100 lines
3.9 KiB
Go
//go:build windows
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/egoist/mygo"
|
|
"github.com/egoist/mygo/internal/wait"
|
|
win "github.com/egoist/mygo/internal/windows"
|
|
)
|
|
|
|
// Alt alone, or held with Control or Shift, keeps a popup menu MyGo shows
|
|
// open, as it keeps open the menus of Windows 11 itself, WinUI's flyouts:
|
|
// the keyboard still reaches the menu afterwards to choose an item, which it
|
|
// couldn't were the menu gone.
|
|
func TestPageMenuKeepsOpenOnAlt(t *testing.T) {
|
|
if !pageMenusHooked {
|
|
t.Skip("right-clicking a page is not hooked here")
|
|
}
|
|
w := newWindow(t, mygo.WindowOptions{Title: "Alt menu", Width: 400, Height: 300})
|
|
w.Page().LoadHTML(contextMenuPage, "")
|
|
waitFor(t, w, "document.readyState === 'complete' && window.mygo")
|
|
|
|
chosen := make(chan struct{}, 1)
|
|
off := w.Page().OnContextMenu(func(e *mygo.ContextMenuEvent) {
|
|
// The web view's items gone, one of MyGo's own left: the keyboard's
|
|
// first Down and Return reach it.
|
|
for _, it := range e.Menu.Items() {
|
|
if it.ID != "" {
|
|
e.Menu.Remove(it.ID)
|
|
}
|
|
}
|
|
e.Menu.Append(&mygo.MenuItem{Label: "Choose", Click: func(*mygo.MenuItem, *mygo.Window) {
|
|
chosen <- struct{}{}
|
|
}})
|
|
})
|
|
defer off()
|
|
|
|
for _, c := range []struct {
|
|
name string
|
|
keys []byte
|
|
}{
|
|
{"Alt", []byte{0x12}}, // VK_MENU
|
|
{"Control then Alt", []byte{0x11, 0x12}}, // VK_CONTROL, which Windows takes for AltGr
|
|
{"Shift then Alt", []byte{0x10, 0x12}}, // VK_SHIFT
|
|
} {
|
|
// The keyboard types in the window in front.
|
|
front := false
|
|
mygo.RunOnMain(func() { front = win.TestForeground(w.NativeHandle()) })
|
|
if !front {
|
|
t.Skip("the window cannot come to the front, where the keyboard types")
|
|
}
|
|
if !rightClickPage(w, 20, 20) {
|
|
t.Fatalf("%s: right-clicking the page failed", c.name)
|
|
}
|
|
wait.Until(t, c.name+": the menu shown", func() bool { _, shown := pageMenu(); return shown })
|
|
keys := c.keys
|
|
mygo.RunOnMain(func() { win.TestPressKeys(keys...) })
|
|
// The menu's own keys, after theirs: they reach it only if it
|
|
// stayed open, as Windows 11's menus do.
|
|
mygo.RunOnMain(func() { win.TestPressKeys(0x28, 0x0D) }) // VK_DOWN, VK_RETURN
|
|
select {
|
|
case <-chosen:
|
|
case <-time.After(wait.Guard):
|
|
if _, shown := pageMenu(); shown {
|
|
t.Fatalf("%s: the menu stayed, and every key missed it", c.name)
|
|
}
|
|
t.Fatalf("%s: the menu left: the keyboard never chose its item", c.name)
|
|
}
|
|
wait.Until(t, c.name+": the menu closed", func() bool { _, shown := pageMenu(); return !shown })
|
|
}
|
|
}
|
|
|
|
// Alt alone leaves the menus of a window's own menu bar, as Win32 has them
|
|
// leave: MyGo keeps it open only in the popups it shows itself, not in the
|
|
// dropdowns Windows opens from the bar.
|
|
func TestMenuBarClosesOnAlt(t *testing.T) {
|
|
prev := mygo.App.Menu()
|
|
defer mygo.App.SetMenu(prev)
|
|
mygo.App.SetMenu(mygo.NewMenu([]*mygo.MenuItem{{Label: "App", Submenu: []*mygo.MenuItem{{Label: "Item"}}}}))
|
|
w := newWindow(t, mygo.WindowOptions{Title: "Alt in the bar", Width: 400, Height: 300})
|
|
eventually(t, "the menu bar on the window", func() bool { shown, _ := menuBarShown(w); return shown })
|
|
if !openMenus(w, 0) {
|
|
t.Skip("the window cannot come to the front, where the keyboard types")
|
|
}
|
|
// openMenus enters the bar from another goroutine: a key typed before
|
|
// its loop starts goes to the window, or to its page, not to the bar.
|
|
eventually(t, "the keyboard in the menu bar", func() bool { return inMenuLoop(w) })
|
|
// A Down in the bar opens its first menu, a menu of Windows'. The page,
|
|
// another process's window, would read some of the keys typed in the
|
|
// menus, had the bar not taken the keyboard from it.
|
|
mygo.RunOnMain(func() { win.TestPressKeys(0x28) }) // VK_DOWN
|
|
eventually(t, "the first menu of the bar open", func() bool { menus, _ := popupMenus(); return len(menus) > 0 })
|
|
mygo.RunOnMain(func() { win.TestPressKeys(0x12) }) // VK_MENU
|
|
eventually(t, "Alt to close the menu of the bar", func() bool { menus, _ := popupMenus(); return len(menus) == 0 })
|
|
closeMenus()
|
|
}
|