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.
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package ui
|
|
|
|
import "testing"
|
|
|
|
// A box with nothing in it is as high as its padding at every width:
|
|
// contentHeight returns 0 for it, and naturalHeight adds the padding.
|
|
// naturalHeight returns that before it measures the box and keeps what it
|
|
// measured, which cannot change with the width.
|
|
func TestLeafHeightIsItsPadding(t *testing.T) {
|
|
var leaf *node
|
|
coreNewTester(func(c *context) {
|
|
leaf = coreBox(c).Padding(7)
|
|
}, 100, 100)
|
|
for _, w := range []float32{1, 10, 100, 1000} {
|
|
if h := contentHeight(leaf, w); h != 0 {
|
|
t.Errorf("contentHeight of a box with nothing in it is %v at width %v, want 0", h, w)
|
|
}
|
|
if h := naturalHeight(leaf, w, 0); h != leaf.padY() {
|
|
t.Errorf("naturalHeight of a box with nothing in it is %v at width %v, and its padding is %v",
|
|
h, w, leaf.padY())
|
|
}
|
|
}
|
|
}
|
|
|
|
// The leaves a wrapping row measures are not kept in measures: their
|
|
// height cannot change with the width, so nothing is there to keep. The
|
|
// containers around them are measured as they were.
|
|
func TestLeafIsNotMeasured(t *testing.T) {
|
|
var root *node
|
|
coreNewTester(func(c *context) {
|
|
root = coreColumn(c).Size(300, 400).Children(func() {
|
|
coreRow(c).Width(280).Wrap().Children(func() {
|
|
for range 8 {
|
|
coreBox(c).Width(60).Shrink(0)
|
|
}
|
|
coreBox(c).WidthPercent(50).Shrink(0)
|
|
})
|
|
})
|
|
}, 300, 400)
|
|
forgetLayout(root)
|
|
layoutBox(root, root.w, root.h)
|
|
var walk func(e *node)
|
|
walk = func(e *node) {
|
|
for ; e != nil; e = e.next {
|
|
if e.kind == kindBox && e.first == nil && e.list == nil && e.nmeasure != 0 {
|
|
t.Errorf("a box with nothing in it kept %d measurements, and its height cannot change with the width",
|
|
e.nmeasure)
|
|
}
|
|
walk(e.first)
|
|
}
|
|
}
|
|
walk(root)
|
|
}
|