Files
openchamber-android-native/third_party/mygo/ui/access_autocomplete_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

57 lines
2.1 KiB
Go

package ui_test
import (
"testing"
"github.com/egoist/mygo/ui"
)
// TestAccessAutoComplete reads what the suggestions of fields complete
// (aria-autocomplete) as assistive technology gets it: what a combobox of
// one's own tells, AutoCompleteList for the widgets whose options match
// what was typed, a token field whose app suggests for its Query among
// them while it has no suggestions yet, and none for a field without
// suggestions or one taken back.
func TestAccessAutoComplete(t *testing.T) {
var query, city, font, recipient string
var tags, labels, to []string
kind := ui.AutoCompleteList
tt := ui.NewTester(func(c *ui.Context) {
ui.Column(c).Children(func() {
ui.TextInputBase(c, &query).Role(ui.RoleComboBox).Label("Search").Expanded(query != "").AutoComplete(kind)
ui.Autocomplete(c, &city, []string{"Paris", "Prague"}).Label("City")
ui.Combobox(c, &font, []string{"Helvetica", "Courier"}).Label("Font")
ui.TokenField(c, &tags, []string{"go", "zig"}).Label("Tags")
ui.TokenField(c, &labels, nil).Label("Labels")
ui.TokenField(c, &to, nil).Label("To").Query(&recipient)
ui.TextInput(c, &query).Label("Note")
})
}, 400, 400)
for _, want := range []struct {
role ui.Role
name string
kind ui.AutoComplete
}{
{ui.RoleComboBox, "Search", ui.AutoCompleteList},
{ui.RoleComboBox, "City", ui.AutoCompleteList},
{ui.RoleComboBox, "Font", ui.AutoCompleteList},
{ui.RoleComboBox, "Tags", ui.AutoCompleteList},
{ui.RoleTextField, "Labels", ui.AutoCompleteNone},
{ui.RoleComboBox, "To", ui.AutoCompleteList},
{ui.RoleTextField, "Note", ui.AutoCompleteNone},
} {
if a := accessOf(t, tt, want.role, want.name); a.AutoComplete != want.kind {
t.Errorf("%s completes %d, want %d", want.name, a.AutoComplete, want.kind)
}
}
// An element tells what it is given in the frame.
for _, k := range []ui.AutoComplete{ui.AutoCompleteInline, ui.AutoCompleteBoth, ui.AutoCompleteNone} {
kind = k
tt.Frame()
if a := accessOf(t, tt, ui.RoleComboBox, "Search"); a.AutoComplete != k {
t.Errorf("Search completes %d, want %d", a.AutoComplete, k)
}
}
}