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.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
+136
@@ -0,0 +1,136 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/internal/platform"
|
||||
)
|
||||
|
||||
func bufferTester(value *TextBuffer, multiline bool) *Tester {
|
||||
return coreNewTester(func(c *context) { bufferInputBase(c, value, multiline).Fill().AutoFocus() }, 400, 140)
|
||||
}
|
||||
|
||||
func TestBufferInputsEditComposeAndUndo(t *testing.T) {
|
||||
for _, multiline := range []bool{false, true} {
|
||||
b := NewTextBuffer("A😀cafe")
|
||||
tt := bufferTester(b, multiline)
|
||||
c := tt.h.ime.Client
|
||||
c.ReplaceText(&TextInputRange{Start: 6, End: 7}, "é")
|
||||
tt.Frame()
|
||||
if b.String() != "A😀café" {
|
||||
t.Fatal("indexed replacement", b.String())
|
||||
}
|
||||
c.SetMarkedText(&TextInputRange{Start: 6, End: 7}, "😀", TextInputRange{Start: 2, End: 2})
|
||||
tt.Frame()
|
||||
if b.String() != "A😀caf" {
|
||||
t.Fatal("preedit in committed buffer", b.String())
|
||||
}
|
||||
var order platform.InputComposition
|
||||
order.End(c)
|
||||
order.Replace(c, nil, "e")
|
||||
tt.Frame()
|
||||
if b.String() != "A😀cafe" {
|
||||
t.Fatal("commit", b.String())
|
||||
}
|
||||
tt.Key(Cmd, KeyZ)
|
||||
if b.String() != "A😀café" {
|
||||
t.Fatal("composition undo", b.String())
|
||||
}
|
||||
tt.Key(Cmd, KeyZ)
|
||||
if b.String() != "A😀cafe" {
|
||||
t.Fatal("replacement undo", b.String())
|
||||
}
|
||||
tt.Key(Cmd|Shift, KeyZ)
|
||||
if b.String() != "A😀café" {
|
||||
t.Fatal("redo", b.String())
|
||||
}
|
||||
tt.rt.close()
|
||||
}
|
||||
}
|
||||
|
||||
func TestBufferAreaNativeQueriesAndLineEditing(t *testing.T) {
|
||||
b := NewTextBuffer(strings.Repeat("line😀\n", 30000) + "tail")
|
||||
tt := bufferTester(b, true)
|
||||
defer tt.rt.close()
|
||||
ed := tt.rt.states[tt.rt.focused].editor
|
||||
if ed.buf.s != "" || !ed.buf.indexed {
|
||||
t.Fatal("buffer control materialized the document")
|
||||
}
|
||||
c := tt.h.ime.Client
|
||||
end := b.UTF16Len()
|
||||
c.ReplaceText(&TextInputRange{Start: end - 4, End: end}, "last\nnext")
|
||||
tt.Frame()
|
||||
if b.Snapshot().Line(30000) != "last" || b.Snapshot().Line(30001) != "next" {
|
||||
t.Fatal("newline indexes")
|
||||
}
|
||||
c.ReplaceText(&TextInputRange{Start: 0, End: 4}, "first")
|
||||
tt.Frame()
|
||||
if b.Snapshot().Line(0) != "first😀" || b.Snapshot().Line(20000) != "line😀" {
|
||||
t.Fatal("later paragraph positions")
|
||||
}
|
||||
query, r := c.TextForRange(TextInputRange{Start: b.UTF16Len() - 4, End: b.UTF16Len()})
|
||||
if query != "next" || r.End != b.UTF16Len() {
|
||||
t.Fatal("late document query", query, r)
|
||||
}
|
||||
tt.Key(Cmd, KeyA)
|
||||
tt.Key(0, KeyBackspace)
|
||||
if b.Len() != 0 || b.LineCount() != 1 {
|
||||
t.Fatal("delete all")
|
||||
}
|
||||
tt.Key(Cmd, KeyZ)
|
||||
if b.Snapshot().Line(0) != "first😀" {
|
||||
t.Fatal("large delete undo")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBufferInputBidiReplacementAndExternalChange(t *testing.T) {
|
||||
b := NewTextBuffer("abc אבג def")
|
||||
tt := bufferTester(b, true)
|
||||
defer tt.rt.close()
|
||||
ed := tt.rt.states[tt.rt.focused].editor
|
||||
ed.move(6, false)
|
||||
tt.Frame()
|
||||
for range 3 {
|
||||
tt.Key(Shift, KeyRight)
|
||||
}
|
||||
tt.Key(Cmd, KeyC)
|
||||
if tt.Clipboard() != "אב " {
|
||||
t.Fatal(tt.Clipboard())
|
||||
}
|
||||
tt.Type("X")
|
||||
if b.String() != "abc Xגdef" {
|
||||
t.Fatal("bidi replacement", b.String())
|
||||
}
|
||||
b.Replace(0, b.Len(), "external😀")
|
||||
tt.Frame()
|
||||
if ed.buf.n != b.Len() || len(ed.undo) != 0 {
|
||||
t.Fatal("external edit did not reset stale widget state")
|
||||
}
|
||||
tt.Key(0, KeyEnd)
|
||||
tt.Type("!")
|
||||
if b.String() != "external😀!" {
|
||||
t.Fatal("edit after external change", b.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestBufferInputBindingSwapAndStringCompatibility(t *testing.T) {
|
||||
b := NewTextBuffer("buffer")
|
||||
s := "string"
|
||||
indexed := true
|
||||
tt := coreNewTester(func(c *context) {
|
||||
if indexed {
|
||||
coreTextInputBuffer(c, b).AutoFocus()
|
||||
} else {
|
||||
coreTextInput(c, &s).AutoFocus()
|
||||
}
|
||||
}, 300, 100)
|
||||
defer tt.rt.close()
|
||||
indexed = false
|
||||
tt.Frame()
|
||||
tt.Key(0, KeyEnd)
|
||||
tt.Type("!")
|
||||
if s != "string!" || b.String() != "buffer" {
|
||||
t.Fatal("binding swap changed the other document")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user