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.
58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
//go:build !js
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"math"
|
|
"sync/atomic"
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo"
|
|
"github.com/egoist/mygo/ui"
|
|
)
|
|
|
|
// A touchpad's pinch over an element of native UI comes to it as
|
|
// InputZoom, with the scale and where the pointer is over the element.
|
|
func TestPinchZooms(t *testing.T) {
|
|
type zoom struct{ x, y, scale float32 }
|
|
var got atomic.Pointer[zoom]
|
|
var drawn atomic.Bool
|
|
var missed atomic.Pointer[zoom] // a pinch outside the element
|
|
view := func(c *ui.Context) {
|
|
ui.Box(c).Fill().HandleInput(func(ev ui.InputEvent) bool {
|
|
if ev.Kind == ui.InputZoom {
|
|
missed.Store(&zoom{ev.X, ev.Y, ev.Scale})
|
|
}
|
|
return false
|
|
}).Children(func() {
|
|
ui.Box(c).Absolute().Left(40).Top(30).Size(200, 120).HandleInput(func(ev ui.InputEvent) bool {
|
|
if ev.Kind != ui.InputZoom {
|
|
return false
|
|
}
|
|
z := zoom{ev.X, ev.Y, ev.Scale}
|
|
if p := got.Load(); p != nil {
|
|
z.scale *= p.scale
|
|
}
|
|
got.Store(&z)
|
|
return true
|
|
}).Draw(func(*ui.Painter, ui.Rect) { drawn.Store(true) })
|
|
})
|
|
}
|
|
w := newWindow(t, mygo.WindowOptions{Title: "Pinch", Width: 320, Height: 220, Content: ui.View(view)})
|
|
eventually(t, "the first frame", drawn.Load)
|
|
want, ok := pinch(w, 100, 90, 1.5)
|
|
if !ok {
|
|
t.Skip("pinch automation unavailable")
|
|
}
|
|
eventually(t, "the pinch", func() bool {
|
|
if m := missed.Load(); m != nil {
|
|
t.Fatalf("the pinch zoomed by %v at (%v, %v) of the window, outside the element", m.scale, m.x, m.y)
|
|
}
|
|
return got.Load() != nil
|
|
})
|
|
z := got.Load()
|
|
if math.Abs(float64(z.scale)-want) > 1e-3 || math.Abs(float64(z.x-60)) > 1 || math.Abs(float64(z.y-60)) > 1 {
|
|
t.Fatalf("the pinch zoomed by %v at (%v, %v), want %v at (60, 60)", z.scale, z.x, z.y, want)
|
|
}
|
|
}
|