Files
openchamber-android-native/third_party/mygo/internal/e2e/swipe_darwin_test.go
T
OpenChamber 6c0ee61750 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.
2026-11-18 13:22:59 +08:00

45 lines
1.2 KiB
Go

//go:build darwin && !ios
package e2e
import (
"sync/atomic"
"testing"
"github.com/egoist/mygo"
"github.com/egoist/mygo/internal/darwin"
"github.com/egoist/mygo/ui"
)
// TestRouterSwipe goes back and forward with swipes, as a touchpad swiping
// between pages sends them, and as mice's side buttons do through their
// makers' software (Logi Options+): they come as KeyBack and KeyForward.
func TestRouterSwipe(t *testing.T) {
var frames atomic.Int32
var path atomic.Value
r := ui.NewRouter("/a")
r.Push("/b")
r.Transition = ui.TransitionNone
view := func(c *ui.Context) {
frames.Add(1)
r.View(c, func(rt *ui.Route) {
path.Store(rt.Path())
ui.Text(c, rt.Path())
})
}
w := newWindow(t, mygo.WindowOptions{Title: "Swipe", Width: 300, Height: 200, Content: ui.View(view)})
eventually(t, "a frame", func() bool { return frames.Load() > 0 })
swipe := func(back bool) {
t.Helper()
var ok bool
mygo.RunOnMain(func() { ok = darwin.TestSwipe(w.NativeHandle(), back) })
if !ok {
t.Fatal("couldn't make a swipe event of the right direction")
}
}
swipe(true)
eventually(t, "back to /a", func() bool { return path.Load() == "/a" })
swipe(false)
eventually(t, "forward to /b", func() bool { return path.Load() == "/b" })
}