Files
openchamber-android-native/third_party/mygo/internal/e2e/frameless_edges_windows_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

66 lines
2.0 KiB
Go

//go:build windows && (amd64 || arm64)
package e2e
import (
"fmt"
"sync/atomic"
"testing"
"github.com/egoist/mygo"
win "github.com/egoist/mygo/internal/windows"
"github.com/egoist/mygo/ui"
)
// TestNativeUIFramelessEdges checks that a frameless window of native UI
// shows its content up to its edges, on the screen: on Windows 10, a white
// line went around it, between the content and the shadow, the visible
// pixel of the borders DWM draws in the non-client area, and the frame
// extended for the shadow along the top (#916). Windows 11 draws a border
// of its own over the outermost pixels, inside which the content shows.
// The content is the issue's: the root has no background, a column filling
// it has one.
func TestNativeUIFramelessEdges(t *testing.T) {
var frames atomic.Int32
w := newWindow(t, mygo.WindowOptions{X: 80, Y: 80, Width: 480, Height: 360, Frameless: true, AlwaysOnTop: true,
Content: ui.View(func(c *ui.Context) {
frames.Add(1)
ui.Column(c).Fill().Background(ui.RGB(180, 20, 20))
})})
eventually(t, "a frame", func() bool { return frames.Load() > 0 })
red := func(c [3]uint8) bool {
near := func(v, want uint8) bool { return int(v) >= int(want)-8 && int(v) <= int(want)+8 }
return near(c[0], 180) && near(c[1], 20) && near(c[2], 20)
}
eventually(t, "the content on the screen", func() bool {
r, g, b, ok := screenColor(w, 240, 180)
return ok && red([3]uint8{r, g, b})
})
var last string
t.Cleanup(func() {
if t.Failed() && last != "" {
t.Logf("at the edges, %s", last)
}
})
eventually(t, "the content at the window's edges", func() bool {
var edges [4][3]uint8
var in int32
var ok bool
mygo.RunOnMain(func() { edges, in, ok = win.TestWindowEdges(w.NativeHandle()) })
if !ok {
last = "unreadable"
return false
}
last = ""
for i, name := range []string{"left", "top", "right", "bottom"} {
if c := edges[i]; !red(c) {
last += fmt.Sprintf(" %s #%02x%02x%02x", name, c[0], c[1], c[2])
}
}
if last != "" {
last = fmt.Sprintf("%d pixels in:%s", in, last)
}
return last == ""
})
}