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

52 lines
1.5 KiB
Go

package platform
import "testing"
func TestInRegion(t *testing.T) {
region := []Rect{{X: 10, Y: 20, Width: 30, Height: 40}, {X: 100, Y: 0, Width: 5, Height: 5}}
for _, c := range []struct {
x, y float64
want bool
}{
{10, 20, true}, // the near corner
{39.9, 59.9, true}, // just inside the far one
{40, 30, false}, // the far edges are out
{20, 60, false},
{9.9, 30, false},
{102, 2, true}, // the second rectangle
{-1, -1, false},
} {
if got := InRegion(region, c.x, c.y); got != c.want {
t.Errorf("InRegion(%v, %v) = %v, want %v", c.x, c.y, got, c.want)
}
}
if InRegion(nil, 0, 0) || InRegion([]Rect{}, 0, 0) {
t.Error("an empty region holds a point")
}
if InRegion([]Rect{{X: 5, Y: 5}}, 5, 5) {
t.Error("a rectangle without area holds a point")
}
}
func TestLetsMouseThrough(t *testing.T) {
region := []Rect{{X: 0, Y: 0, Width: 10, Height: 10}}
for _, c := range []struct {
name string
x, y float64
held, through bool
want bool
}{
{"on the region", 5, 5, false, true, false},
{"off the region", 50, 5, false, false, true},
{"a press on the window dragged off it", 50, 5, true, false, false},
{"a press behind dragged onto the region", 5, 5, true, true, true},
} {
if got := LetsMouseThrough(region, c.x, c.y, c.held, c.through); got != c.want {
t.Errorf("%s: %v, want %v", c.name, got, c.want)
}
}
if !LetsMouseThrough([]Rect{}, 5, 5, false, false) {
t.Error("an empty region takes the mouse")
}
}