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

54 lines
2.0 KiB
Go

//go:build windows && (amd64 || arm64)
package e2e
import (
"testing"
"github.com/egoist/mygo"
"github.com/egoist/mygo/ui"
)
// TestTransparentWebWindow reads the screen through a transparent web page.
// The red half must paint; the clear half must show the blue window behind it,
// rather than the opaque redirection bitmap of the page's host window.
func TestTransparentWebWindow(t *testing.T) {
for _, tc := range []struct {
name string
disableShadow bool
disableResize bool
}{
{"shadowless", true, false},
{"with shadow", false, false},
{"fixed size", true, true},
} {
t.Run(tc.name, func(t *testing.T) {
back := newWindow(t, mygo.WindowOptions{
X: 40, Y: 40, Width: 400, Height: 300, Frameless: true,
Content: ui.View(func(c *ui.Context) { c.Root().Background(ui.RGB(0, 0, 255)) }),
})
pixel := func(x float64, red bool) bool {
r, g, b, ok := screenColor(back, x, 150)
if red {
return ok && r > 200 && g < 60 && b < 60
}
return ok && b > 200 && r < 60 && g < 60
}
eventually(t, "the blue window on the screen", func() bool { return pixel(100, false) && pixel(300, false) })
front := newWindow(t, mygo.WindowOptions{
X: 40, Y: 40, Width: 400, Height: 300,
Frameless: true, Transparent: true, AlwaysOnTop: true,
DisableShadow: tc.disableShadow, DisableResize: tc.disableResize,
})
front.Page().LoadHTML(`<html style="background:transparent"><body style="margin:0;background:transparent"><div style="position:absolute;left:50%;top:0;right:0;bottom:0;background:#ff0000"></div></body></html>`, "")
waitFor(t, front, "document.readyState === 'complete' && document.querySelector('div') !== null")
if noRedirect, _, _ := composition(front); !noRedirect {
t.Fatal("the transparent WebView host still has an opaque redirection bitmap")
}
eventually(t, "the page's red half on the screen", func() bool { return pixel(300, true) })
eventually(t, "the blue window through the page's clear half", func() bool { return pixel(100, false) })
})
}
}