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
+122
@@ -0,0 +1,122 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPressedSelectionRebuildsBeforePaint(t *testing.T) {
|
||||
for _, virtual := range []bool{false, true} {
|
||||
t.Run(fmt.Sprintf("virtual=%v", virtual), func(t *testing.T) {
|
||||
selected, draft, builds := 0, "", 0
|
||||
var state ListState
|
||||
tt := coreNewTester(func(c *context) {
|
||||
builds++
|
||||
coreColumn(c).Fill().Children(func() {
|
||||
coreTextf(c, "Selected %d", selected)
|
||||
list := coreColumn(c).Grow(1).Focusable().Label("Items")
|
||||
focused := list.FocusWithin()
|
||||
list.Children(func() {
|
||||
row := func(i int) {
|
||||
e := coreRow(c).Key(i).Height(32).Label(fmt.Sprintf("Row %d", i))
|
||||
if i == selected && focused {
|
||||
e.Background(c.theme.Accent)
|
||||
}
|
||||
if e.Pressed() || e.Clicked() {
|
||||
selected = i
|
||||
}
|
||||
e.Children(func() { coreTextf(c, "Row %d", i) })
|
||||
}
|
||||
if virtual {
|
||||
coreList(c, &state, 2, row).Grow(1)
|
||||
} else {
|
||||
for i := range 2 {
|
||||
row(i)
|
||||
}
|
||||
}
|
||||
})
|
||||
coreTextInput(c, &draft).Label("Editor")
|
||||
})
|
||||
}, 240, 200)
|
||||
if err := tt.Click("Editor"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r, ok := tt.Find("Row 1")
|
||||
if !ok {
|
||||
t.Fatal("row is missing")
|
||||
}
|
||||
builds = 0
|
||||
tt.Press(r.X+r.W/2, r.Y+r.H/2)
|
||||
if selected != 1 || !tt.HasText("Selected 1") {
|
||||
t.Fatalf("pointer down chose %d, but the painted frame still shows %q", selected, tt.Texts())
|
||||
}
|
||||
if builds != 2 {
|
||||
t.Fatalf("pointer down built %d passes, want 2", builds)
|
||||
}
|
||||
builds = 0
|
||||
tt.Frame()
|
||||
if builds != 1 {
|
||||
t.Fatalf("holding the pointer built %d passes, want 1", builds)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestButtonClickStillWaitsForRelease(t *testing.T) {
|
||||
clicks := 0
|
||||
tt := coreNewTester(func(c *context) {
|
||||
b := coreButton(c, "Button").Label("Button control")
|
||||
if b.Pressed() {
|
||||
b.Background(c.theme.Accent)
|
||||
}
|
||||
if b.Clicked() {
|
||||
clicks++
|
||||
}
|
||||
}, 240, 100)
|
||||
r, _ := tt.Find("Button control")
|
||||
tt.Press(r.X+r.W/2, r.Y+r.H/2)
|
||||
if clicks != 0 {
|
||||
t.Fatal("button activated on pointer down")
|
||||
}
|
||||
tt.Release(r.X+r.W/2, r.Y+r.H/2)
|
||||
if clicks != 1 {
|
||||
t.Fatalf("button click count %d", clicks)
|
||||
}
|
||||
tt.Press(r.X+r.W/2, r.Y+r.H/2)
|
||||
tt.Move(r.X+r.W+10, r.Y+r.H/2)
|
||||
tt.Release(r.X+r.W+10, r.Y+r.H/2)
|
||||
if clicks != 1 {
|
||||
t.Fatal("releasing outside the button activated it")
|
||||
}
|
||||
}
|
||||
|
||||
// PressedInside tells a press on an element or inside it without the
|
||||
// element taking the pointer: a table's row still chooses on a click on
|
||||
// a cell asking it, and a press elsewhere is not one.
|
||||
func TestPressedInsideLeavesThePress(t *testing.T) {
|
||||
sel := -1
|
||||
s := ListState{Selected: &sel}
|
||||
pressed := map[int]int{}
|
||||
tt := coreNewTester(func(c *context) {
|
||||
coreColumn(c).Fill().Padding(10).Children(func() {
|
||||
coreTable(c, &s, []TableColumn{{Title: "Name"}}, 3, func(row, col int) {
|
||||
cell := coreBox(c).Children(func() { coreTextf(c, "row %d", row) })
|
||||
if cell.PressedInside() {
|
||||
pressed[row]++
|
||||
}
|
||||
}).Grow(1)
|
||||
coreText(c, "elsewhere")
|
||||
})
|
||||
}, 400, 300)
|
||||
r, _ := tt.Find("row 1")
|
||||
tt.ClickAt(r.X+5, r.Y+r.H/2) // on the cell's text, inside it
|
||||
tt.Frame()
|
||||
if pressed[1] != 1 || sel != 1 {
|
||||
t.Fatalf("pressed %v, chosen %d", pressed, sel)
|
||||
}
|
||||
tt.Click("elsewhere")
|
||||
tt.Frame()
|
||||
if len(pressed) != 1 || pressed[1] != 1 {
|
||||
t.Fatalf("a press elsewhere counted: %v", pressed)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user