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.
65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package ui
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestFrameStatsSetting(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
v string
|
|
threshold time.Duration
|
|
on bool
|
|
}{
|
|
{"", 0, false},
|
|
{"0", 0, false},
|
|
{"off", 0, false},
|
|
{"1", 8 * time.Millisecond, true},
|
|
{"true", 8 * time.Millisecond, true},
|
|
{"4", 4 * time.Millisecond, true},
|
|
{"16.5", 16500 * time.Microsecond, true},
|
|
{"all", 0, true},
|
|
{"fast", 8 * time.Millisecond, true},
|
|
} {
|
|
threshold, on := frameStatsSetting(tc.v)
|
|
if threshold != tc.threshold || on != tc.on {
|
|
t.Errorf("MYGO_FRAME_STATS=%q: %v, %v; want %v, %v", tc.v, threshold, on, tc.threshold, tc.on)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFrameStats(t *testing.T) {
|
|
var logged []string
|
|
defer func(f func(...any)) { frameLog = f }(frameLog)
|
|
frameLog = func(v ...any) { logged = append(logged, v[0].(string)) }
|
|
|
|
clicked := false
|
|
tt := coreNewTester(func(c *context) {
|
|
if coreButton(c, "Go").Clicked() {
|
|
clicked = true
|
|
}
|
|
coreText(c, "Hello")
|
|
}, 200, 100)
|
|
tt.rt.stats = newFrameStats(0)
|
|
if err := tt.Click("Go"); err != nil || !clicked {
|
|
t.Fatal(err, clicked)
|
|
}
|
|
if len(logged) == 0 {
|
|
t.Fatal("no frame logged")
|
|
}
|
|
line := logged[len(logged)-1]
|
|
for _, want := range []string{"build ", "layout ", "paint ", "present ", "(drawn in memory)", "allocations", "KB", "text layouts"} {
|
|
if !strings.Contains(line, want) {
|
|
t.Errorf("%q lacks %q", line, want)
|
|
}
|
|
}
|
|
// Frames under the threshold are not logged.
|
|
logged = nil
|
|
tt.rt.stats = newFrameStats(time.Hour)
|
|
tt.Frame()
|
|
if len(logged) > 0 {
|
|
t.Errorf("a fast frame logged %q", logged)
|
|
}
|
|
}
|