feat: port the client to MyGo native UI (0.3.0)
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.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
+103
@@ -0,0 +1,103 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/egoist/mygo/internal/platform"
|
||||
)
|
||||
|
||||
// TestMenuItemTooltip gives an item a tooltip: the system's menu takes it
|
||||
// as its own items' (shown on macOS and Linux), and a drawn menu shows it
|
||||
// as the pointer rests on the item.
|
||||
func TestMenuItemTooltip(t *testing.T) {
|
||||
const tip = "Runs the query under the caret"
|
||||
menu := func(m *Menu) {
|
||||
m.Item("Open")
|
||||
m.Item("Run").Tooltip(tip)
|
||||
}
|
||||
t.Run("system", func(t *testing.T) {
|
||||
tt := coreNewTester(func(c *context) {
|
||||
coreRow(c).Padding(20).Children(func() { coreText(c, "Report.pdf") }).ContextMenu(menu)
|
||||
}, 400, 300)
|
||||
if err := tt.RightClick("Report.pdf"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m := tt.h.menu; m == nil || len(m.Items) != 2 || m.Items[1].ToolTip != tip || m.Items[0].ToolTip != "" {
|
||||
t.Fatalf("the system's menu %v", m)
|
||||
}
|
||||
})
|
||||
t.Run("drawn", func(t *testing.T) {
|
||||
tt, now := clockTester(func(c *context) {
|
||||
coreRow(c).Padding(20).Children(func() { coreText(c, "Report.pdf") }).PopoverMenu(menu)
|
||||
}, 400, 300)
|
||||
tick := ticker(tt, now)
|
||||
if err := tt.RightClick("Report.pdf"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, ok := tt.Find("Run")
|
||||
if !ok {
|
||||
t.Fatal("no drawn item Run")
|
||||
}
|
||||
tt.Move(r.X+r.W/2, r.Y+r.H/2)
|
||||
tick(700 * time.Millisecond)
|
||||
if !tt.HasText(tip) {
|
||||
t.Fatalf("no tip once the pointer rested on the item: texts %q", tt.Texts())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TestMenuItemTooltipByKeys shows a drawn item's tip as the keys rest on
|
||||
// it, as on a focused element's (the WAI-ARIA tooltip pattern): the menu
|
||||
// gives the focus to its highlighted item (ActiveDescendant). Assistive
|
||||
// technology reads the tip as the item's description, and the shortcut as
|
||||
// its key shortcuts.
|
||||
func TestMenuItemTooltipByKeys(t *testing.T) {
|
||||
const tip = "Runs the query under the caret"
|
||||
tt := coreNewTester(func(c *context) {
|
||||
coreRow(c).Padding(20).Focusable().Label("Report").Children(func() { coreText(c, "Report.pdf") }).PopoverMenu(func(m *Menu) {
|
||||
m.Item("Open")
|
||||
m.Item("Run").Shortcut(Cmd, KeyEnter).Tooltip(tip)
|
||||
})
|
||||
}, 400, 300)
|
||||
tt.send(platform.SurfaceEvent{Kind: platform.AccessibilityOn})
|
||||
tt.Click("Report.pdf")
|
||||
tt.Key(0, KeyContextMenu)
|
||||
tt.Key(0, KeyDown)
|
||||
wantFocus(t, tt, "Run")
|
||||
if n := accessFocus(t, tt); n.Description != tip || n.KeyShortcuts == "" {
|
||||
t.Errorf("Run reads with the description %q and key shortcuts %q", n.Description, n.KeyShortcuts)
|
||||
}
|
||||
tt.Advance(time.Second)
|
||||
if !tt.HasText(tip) {
|
||||
t.Error("no tip once the keys rested on the item")
|
||||
}
|
||||
}
|
||||
|
||||
// TestMenuKeysThenPointer keeps the focus a pointer's once the pointer
|
||||
// takes over in a menu the keys moved in: the menu button the focus goes
|
||||
// back to shows neither its focus nor its tip.
|
||||
func TestMenuKeysThenPointer(t *testing.T) {
|
||||
tt, now := clockTester(func(c *context) {
|
||||
coreColumn(c).Fill().Padding(40).AlignItems(Start).Children(func() {
|
||||
coreButton(c, "More").Tooltip("More actions").PopoverMenuButton(func(m *Menu) {
|
||||
m.Item("Copy")
|
||||
m.Item("Paste")
|
||||
})
|
||||
})
|
||||
}, 400, 300)
|
||||
tick := ticker(tt, now)
|
||||
tt.Click("More")
|
||||
tt.Key(0, KeyDown)
|
||||
r, _ := tt.Find("Paste")
|
||||
tt.Move(r.X+r.W/2, r.Y+r.H/2)
|
||||
tt.ClickAt(r.X+r.W/2, r.Y+r.H/2)
|
||||
if tt.HasText("Copy") {
|
||||
t.Fatal("the menu stays after a choice")
|
||||
}
|
||||
tt.Move(380, 280)
|
||||
tick(time.Second)
|
||||
if tt.rt.focusVisible || tt.HasText("More actions") {
|
||||
t.Errorf("after a pointer's choice: focus visible %v, tip %v", tt.rt.focusVisible, tt.HasText("More actions"))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user