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

87 lines
3.0 KiB
Go

package ui
import (
"testing"
"github.com/egoist/mygo/internal/platform"
)
func TestDisabledColorsKeepInputAndAccessibilitySemantics(t *testing.T) {
for _, explicitColors := range []bool{false, true} {
clicks := 0
var paragraph *node
tt := coreNewTester(func(c *context) {
theme := LightTheme()
theme.DisableAutoDimming = explicitColors
c.SetTheme(theme)
coreColumn(c).Padding(10).Gap(4).Children(func() {
if coreButtonBase(c).Label("Disabled").Size(30, 20).Background(RGB(0, 0, 0)).Disabled(true).Clicked() {
clicks++
}
paragraph = coreRichText(c).Children(func() {
coreText(c, "Inline").TextColor(RGB(0, 0, 0)).Disabled(true)
})
coreButton(c, "Enabled")
})
}, 140, 140)
pixel := tt.Image().RGBAAt(15, 15)
if explicitColors && pixel.R != 0 || !explicitColors && pixel.R == 0 {
t.Fatalf("disabled block opacity: explicit=%v, pixel=%v", explicitColors, pixel)
}
if len(paragraph.spans) != 1 || (paragraph.spans[0].Color.A == 255) != explicitColors {
t.Fatalf("disabled inline opacity: explicit=%v, spans=%+v", explicitColors, paragraph.spans)
}
tt.Click("Disabled")
if clicks != 0 || tt.Focused("Disabled") {
t.Fatal("disabled button accepted input")
}
tt.Key(0, KeyTab)
if !tt.Focused("Enabled") {
t.Fatal("Tab did not skip disabled button")
}
tt.send(platform.SurfaceEvent{Kind: platform.AccessibilityOn})
n := accessNode(t, tt.h.access, platform.RoleButton, "Disabled")
if n.States&platform.AccessDisabled == 0 {
t.Fatal("disabled button lost accessibility state")
}
tt.send(platform.SurfaceEvent{Kind: platform.AccessAction, ID: n.ID, Action: platform.AccessPress})
if clicks != 0 {
t.Fatal("accessibility activated disabled button")
}
}
}
func TestDisableAutoDimmingThemed(t *testing.T) {
for _, windowOptOut := range []bool{false, true} {
var block, paragraph, outside *node
tt := coreNewTester(func(c *context) {
window, local := LightTheme(), LightTheme()
window.DisableAutoDimming = windowOptOut
local.DisableAutoDimming = !windowOptOut
c.SetTheme(window)
coreColumn(c).Children(func() {
coreThemed(c, local).Children(func() {
block = coreBox(c).Size(20, 20).Background(RGB(0, 0, 0)).Disabled(true)
paragraph = coreRichText(c).Children(func() {
coreText(c, "Inline").TextColor(RGB(0, 0, 0)).Disabled(true)
})
})
outside = coreBox(c).Size(20, 20).Background(RGB(0, 0, 0)).Disabled(true)
})
}, 140, 140)
img := tt.Image()
for _, tc := range []struct {
e *node
undimmed bool
}{{block, !windowOptOut}, {outside, windowOptOut}} {
pixel := img.RGBAAt(int(tc.e.x+5), int(tc.e.y+5))
if (pixel.R == 0) != tc.undimmed {
t.Errorf("window opt-out=%v: disabled block at y=%v has pixel %v, want undimmed=%v", windowOptOut, tc.e.y, pixel, tc.undimmed)
}
}
if len(paragraph.spans) != 1 || (paragraph.spans[0].Color.A == 255) != !windowOptOut {
t.Errorf("window opt-out=%v: scoped inline spans=%+v", windowOptOut, paragraph.spans)
}
}
}