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.
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
package text
|
|
|
|
import "testing"
|
|
|
|
// TestBlurBitmap blurs a square of coverage: it keeps its sum, spreads
|
|
// three standard deviations past it, symmetric, and shades a sharp
|
|
// shadow of a color glyph by its alpha.
|
|
func TestBlurBitmap(t *testing.T) {
|
|
b := bitmap{left: 2, top: -8, w: 4, h: 4, pix: make([]byte, 16)}
|
|
for i := range b.pix {
|
|
b.pix[i] = 255
|
|
}
|
|
sharp := blurBitmap(b, 0)
|
|
if sharp.w != 4 || sharp.h != 4 || sharp.left != 2 || sharp.top != -8 || sharp.pix[5] != 255 {
|
|
t.Fatalf("unblurred: %dx%d at (%d, %d)", sharp.w, sharp.h, sharp.left, sharp.top)
|
|
}
|
|
soft := blurBitmap(b, 2)
|
|
pad := (soft.w - 4) / 2
|
|
if pad != 7 || soft.h != soft.w || soft.left != 2-pad || soft.top != -8-pad {
|
|
t.Fatalf("blurred: %dx%d at (%d, %d)", soft.w, soft.h, soft.left, soft.top)
|
|
}
|
|
sum := 0
|
|
for _, v := range soft.pix {
|
|
sum += int(v)
|
|
}
|
|
if want := 16 * 255; sum < want*98/100 || sum > want*102/100 {
|
|
t.Errorf("the blur sums %d, the square %d", sum, want)
|
|
}
|
|
center := soft.pix[(soft.h/2)*soft.w+soft.w/2]
|
|
edge := soft.pix[(soft.h/2)*soft.w]
|
|
if center <= edge || center == 255 || soft.pix[(soft.h/2)*soft.w+1] != soft.pix[(soft.h/2)*soft.w+soft.w-2] {
|
|
t.Errorf("the blur shades the center %d, the edge %d, unevenly", center, edge)
|
|
}
|
|
emoji := bitmap{w: 1, h: 1, color: true, pix: []byte{200, 10, 10, 128}}
|
|
if s := blurBitmap(emoji, 0); s.color || s.pix[0] != 128 {
|
|
t.Errorf("a color glyph's shadow is %v", s.pix)
|
|
}
|
|
}
|