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
+70
@@ -0,0 +1,70 @@
|
||||
//go:build !mygo_noinspector && !js
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/egoist/mygo"
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
// TestContentWindowInspector opens the inspector of native UI with the
|
||||
// Toggle Developer Tools menu item, beside the content, and closes it.
|
||||
func TestContentWindowInspector(t *testing.T) {
|
||||
var frames atomic.Int32
|
||||
var width atomic.Value
|
||||
width.Store(float32(0))
|
||||
view := func(c *ui.Context) {
|
||||
frames.Add(1)
|
||||
w, _ := c.Size()
|
||||
width.Store(w)
|
||||
ui.Box(c).Fill().Background(ui.RGB(30, 144, 255))
|
||||
}
|
||||
w := newWindow(t, mygo.WindowOptions{Title: "Inspector", Width: 600, Height: 400, Content: ui.View(view),
|
||||
Page: mygo.PageOptions{DevTools: mygo.DevToolsEnabled}})
|
||||
eventually(t, "a frame", func() bool { return frames.Load() > 0 })
|
||||
full := width.Load().(float32)
|
||||
menu := mygo.NewMenu([]*mygo.MenuItem{{Label: "Test", Submenu: []*mygo.MenuItem{{Role: mygo.RoleToggleDevTools}}}})
|
||||
mygo.App.SetMenu(menu)
|
||||
defer mygo.App.SetMenu(nil)
|
||||
w.Focus()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if err := activateMenu(w, "Test", "Toggle Developer Tools"); err != nil {
|
||||
t.Skip("menu automation not available on this platform: ", err)
|
||||
}
|
||||
eventually(t, "the content beside the inspector", func() bool {
|
||||
w := width.Load().(float32)
|
||||
return w > 0 && w < full
|
||||
})
|
||||
beside := width.Load().(float32)
|
||||
data, err := w.CapturePage()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
img, err := png.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := deviceScale(w)
|
||||
b := img.Bounds()
|
||||
at := func(x, y float64) color.RGBA {
|
||||
return color.RGBAModel.Convert(img.At(b.Min.X+int(x*s), b.Min.Y+int(y*s))).(color.RGBA)
|
||||
}
|
||||
if c := at(float64(beside)-20, 200); c.B < 200 || c.R > 60 {
|
||||
t.Errorf("the content's background is %v", c)
|
||||
}
|
||||
// The panel's background, in the theme's colors, not the content's.
|
||||
if c := at(float64(beside)+100, 200); c.A < 255 || c.B >= 200 && c.R <= 60 {
|
||||
t.Errorf("the inspector's background is %v", c)
|
||||
}
|
||||
if err := activateMenu(w, "Test", "Toggle Developer Tools"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
eventually(t, "the content filling the window again", func() bool { return width.Load().(float32) == full })
|
||||
}
|
||||
Reference in new issue
Block a user