Files
openchamber-android-native/third_party/mygo/internal/gpu/metal/zoom_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

60 lines
1.4 KiB
Go

//go:build darwin && !ios
package metal
import (
"testing"
"github.com/egoist/mygo/internal/scene"
)
// TestZoomedFrames renders the frames of content zoomed 2 times on a
// screen of scale 2: the layer keeps the screen's scale, the frames
// changing a little draw in part, and a frame changing the zoom alone
// changes the layer not.
func TestZoomedFrames(t *testing.T) {
if err := load(); err != nil {
t.Skip("no Metal:", err)
}
var layer id
pool(func() { layer = send(class("CALayer"), "new") })
if layer == 0 {
t.Skip("no Core Animation")
}
defer pool(func() { release(&layer) })
r, err := New(uintptr(layer))
if err != nil {
unavailable(t, err)
}
defer r.Release()
frame := func(i int, scale, zoom float32) {
t.Helper()
s := &scene.Scene{}
s.Reset(128, 64, scene.Color{A: 255})
s.Scale, s.Zoom = scale, zoom
s.Ops = append(s.Ops, scene.Op{Kind: scene.OpFill, Rect: scene.Rect{X: float32(4 * i), W: 8, H: 8}, Color: scene.Color{R: 255, A: 255}})
if err := r.Render(s); err != nil {
t.Fatal(err)
}
r.pre.wait()
r.waitLast()
}
partial := 0
for i := range 8 {
frame(i, 4, 2)
if r.scale != 2 {
t.Fatalf("frame %d: the layer's scale is %v, want the screen's, 2", i, r.scale)
}
if r.redrew == redrewPart {
partial++
}
}
if partial == 0 {
t.Error("no zoomed frame drew in part")
}
frame(8, 2, 0)
if r.scale != 2 {
t.Errorf("unzoomed, the layer's scale is %v, want 2", r.scale)
}
}