Files
openchamber-android-native/third_party/mygo/ui/editor/trailing_ellipsis_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.7 KiB
Go

package editor
import (
"strings"
"testing"
"github.com/egoist/mygo/ui"
)
func TestTrailingInlayEllipsisStaysOnOneRow(t *testing.T) {
st := &State{Buffer: NewBuffer("abc\n"), SoftWrap: true}
st.SetInlays([]Inlay{{
Offset: 3, Text: " You, 2 months ago • a commit subject too long for this editor",
Trailing: true, Ellipsis: "…",
}})
tt := ui.NewTester(func(c *ui.Context) { View(c, st).Fill() }, 240, 120)
tt.Frame()
line := st.ed.view.line(0)
if len(line.rows) != 1 {
t.Fatalf("trailing inlay used %d rows: %q", len(line.rows), line.disp)
}
if !strings.HasPrefix(line.disp, "abc You,") || !strings.HasSuffix(line.disp, "…") {
t.Fatalf("ellipsized trailing inlay = %q", line.disp)
}
if got := st.ed.view.inlays[0].text; !strings.HasSuffix(got, "editor") {
t.Fatalf("layout changed the original inlay text to %q", got)
}
}
func TestTrailingInlayEllipsisMeasuresReplacementWidths(t *testing.T) {
st := &State{Buffer: NewBuffer("abc\n"), SoftWrap: true}
st.SetReplacements([]Replacement{box(0, 1, 140, "Replacement")})
st.SetInlays([]Inlay{{
Offset: 3, Text: " You, 2 months ago • a commit subject too long for this editor",
Trailing: true, Ellipsis: "…",
}})
tt := ui.NewTester(func(c *ui.Context) { View(c, st).Fill() }, 240, 120)
tt.Frame()
line := st.ed.view.line(0)
if len(line.rows) != 1 {
t.Fatalf("trailing inlay after a replacement used %d rows: %q", len(line.rows), line.disp)
}
if got, want := line.disp, objectChar+"bc…"; got != want {
t.Fatalf("ellipsized trailing inlay after a replacement = %q, want %q", got, want)
}
if strings.Contains(line.disp, "months") {
t.Fatalf("the replacement's 140-DIP width was not included in elision: %q", line.disp)
}
}