Files
openchamber-android-native/third_party/mygo/internal/e2e/access_disabled_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

60 lines
1.8 KiB
Go

//go:build darwin && !ios
package e2e
import (
"sync/atomic"
"testing"
"time"
"github.com/egoist/mygo"
"github.com/egoist/mygo/ui"
)
// TestAccessDisabled reads, as VoiceOver does, a button that is only
// unavailable (AccessDisabled, aria-disabled): AXEnabled false, yet
// focused when assistive technology asks, and not pressed, where a button
// Disabled takes neither.
func TestAccessDisabled(t *testing.T) {
var frames, deleted atomic.Int32
var focused atomic.Bool
view := func(c *ui.Context) {
frames.Add(1)
ui.Column(c).Padding(20).Gap(10).Children(func() {
del := ui.Button(c, "Delete project").AccessDisabled(true)
focused.Store(del.Focused())
if del.Clicked() {
deleted.Add(1)
}
ui.Button(c, "Close").Disabled(true)
})
}
w := newWindow(t, mygo.WindowOptions{Title: "Unavailable", Width: 400, Height: 200, Content: ui.View(view)})
eventually(t, "a frame", func() bool { return frames.Load() > 0 })
for _, label := range []string{"Delete project", "Close"} {
var v string
var named, ok bool
for end := time.Now().Add(30 * time.Second); ; time.Sleep(50 * time.Millisecond) {
if v, _, named, ok = axAttribute(w, label, "AXEnabled"); ok && v == "0" {
break
}
if time.Now().After(end) {
t.Fatalf("%s: AXEnabled %q (listed %v, found %v), want 0", label, v, named, ok)
}
}
}
if accessPerform(w, "Close", "focus", "") {
t.Error("assistive technology focused the disabled button")
}
if accessPerform(w, "Delete project", "press", "") {
t.Error("assistive technology pressed the unavailable button")
}
if !accessPerform(w, "Delete project", "focus", "") {
t.Fatal("cannot focus the unavailable button")
}
eventually(t, "the unavailable button focused", focused.Load)
if deleted.Load() != 0 {
t.Error("the unavailable button was pressed")
}
}