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.
67 lines
2.8 KiB
Go
67 lines
2.8 KiB
Go
package ui
|
|
|
|
import "testing"
|
|
|
|
// TestMenuButtonHasPopup checks that the buttons opening a menu as they
|
|
// are pressed tell assistive technology so (aria-haspopup="menu"), with
|
|
// no HasPopup of the app's (#1434), that HasPopup before or after wins
|
|
// over it, and that an element with a context menu tells nothing.
|
|
func TestMenuButtonHasPopup(t *testing.T) {
|
|
var menuOpen bool
|
|
build := func(m *Menu) { m.Item("Duplicate") }
|
|
tt := coreNewTester(func(c *context) {
|
|
coreColumn(c).Padding(20).Gap(10).AlignItems(Start).Children(func() {
|
|
coreMenuButton(c, "Sort by", build)
|
|
corePopoverMenuButton(c, "View", build)
|
|
coreButtonBase(c).Label("More").Padding(4).Children(func() { coreText(c, "…") }).Menu(build)
|
|
coreButtonBase(c).Label("Options").Padding(4).Children(func() { coreText(c, "⋯") }).PopoverMenuButton(build)
|
|
m := coreMenuBase(c, &menuOpen)
|
|
m.Trigger.Label("Actions").Padding(4).Children(func() { coreText(c, "Actions") })
|
|
m.Popup(func(panel *node) { m.Item().Children(func() { coreText(c, "Open") }) })
|
|
coreMenuButton(c, "Share", build).HasPopup(PopupDialog)
|
|
coreButtonBase(c).Label("Plain").Padding(4).Children(func() { coreText(c, "Plain") }).HasPopup(PopupNone).Menu(build)
|
|
coreRow(c).Padding(8).Focusable().Label("Report").Children(func() { coreText(c, "Report.pdf") }).ContextMenu(build)
|
|
})
|
|
}, 400, 600)
|
|
for name, want := range map[string]Popup{
|
|
"Sort by": PopupMenu, "View": PopupMenu, "More": PopupMenu, "Options": PopupMenu, "Actions": PopupMenu,
|
|
"Share": PopupDialog, "Plain": PopupNone,
|
|
} {
|
|
info, ok := tt.AccessByRole(RoleMenuButton, name)
|
|
if !ok {
|
|
t.Errorf("no menu button %q", name)
|
|
continue
|
|
}
|
|
if info.HasPopup != want {
|
|
t.Errorf("%q: HasPopup = %d, want %d", name, info.HasPopup, want)
|
|
}
|
|
}
|
|
if info, ok := tt.Access("Report"); !ok || info.HasPopup != PopupNone {
|
|
t.Errorf("the row with a context menu: %+v", info)
|
|
}
|
|
// A drawn menu's button is expanded while its menu shows, and still
|
|
// opens a menu.
|
|
if info, _ := tt.AccessByRole(RoleMenuButton, "View"); info.Expanded {
|
|
t.Error("View is expanded before its menu opens")
|
|
}
|
|
if err := tt.Click("View"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if info, _ := tt.AccessByRole(RoleMenuButton, "View"); !info.Expanded || info.HasPopup != PopupMenu {
|
|
t.Errorf("View with its menu open: %+v", info)
|
|
}
|
|
}
|
|
|
|
// TestMenuButtonHasPopupDrawnMenus checks Element.Menu's button in a
|
|
// window drawing its menus (PopoverMenus), which builds it as
|
|
// PopoverMenuButton's.
|
|
func TestMenuButtonHasPopupDrawnMenus(t *testing.T) {
|
|
tt := coreNewTester(func(c *context) {
|
|
c.SetMenuPresentation(PopoverMenus)
|
|
coreMenuButton(c, "Sort by", func(m *Menu) { m.Item("Name") })
|
|
}, 400, 400)
|
|
if info, ok := tt.AccessByRole(RoleMenuButton, "Sort by"); !ok || info.HasPopup != PopupMenu {
|
|
t.Errorf("Sort by: %+v", info)
|
|
}
|
|
}
|