Files
openchamber-android-native/third_party/mygo/plugins/sfsymbols/symbol_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

50 lines
1.5 KiB
Go

package sfsymbols
import (
"testing"
"github.com/egoist/mygo/ui"
)
// box is an SVG square filling its view box, for a fallback that shows.
var box = ui.MustParseSVG([]byte(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10" fill="currentColor"/></svg>`))
// TestSymbolElement checks that a Symbol is named for assistive technology
// and sized as asked, at the theme's font size by default.
func TestSymbolElement(t *testing.T) {
tt := ui.NewTester(func(c *ui.Context) {
ui.Row(c).Children(func() {
Symbol(c, "gearshape")
Symbol(c, "trash").Size(32).Color(ui.RGB(255, 0, 0)).Weight(Bold).Fill()
})
}, 200, 100)
r, ok := tt.Find("gearshape")
if !ok || r.W != r.H || r.W <= 0 {
t.Errorf("gearshape: found %v at %v, want a square", ok, r)
}
if r, ok := tt.Find("trash"); !ok || r.W != 32 || r.H != 32 {
t.Errorf("trash: found %v at %v, want 32 square", ok, r)
}
}
// TestSymbolFallback checks that a name no system has draws the fallback,
// in the symbol's color.
func TestSymbolFallback(t *testing.T) {
tt := ui.NewTester(func(c *ui.Context) {
ui.Column(c).Fill().Background(ui.RGB(255, 255, 255)).Children(func() {
Symbol(c, "no.such.symbol").Size(20).Color(ui.RGB(255, 0, 0)).Fallback(box)
})
}, 40, 40)
tt.Frame()
r, ok := tt.Find("no.such.symbol")
if !ok {
t.Fatal("no.such.symbol not found")
}
img := tt.Image()
s := img.Rect.Dx() / 40
px := img.RGBAAt(int(r.X+r.W/2)*s, int(r.Y+r.H/2)*s)
if px.R < 200 || px.G > 60 || px.B > 60 {
t.Errorf("the fallback's middle is %v, want red", px)
}
}