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

76 lines
2.3 KiB
Go

//go:build linux && !android && (amd64 || arm64)
package linux
import (
"reflect"
"testing"
"github.com/egoist/mygo/internal/platform"
)
// TestTouchPoints checks that GDK's touch sequences become IDs that
// stay with a finger from its begin to its end or cancel, and that a
// sequence GDK frees and gives the next finger gets another (#1879).
func TestTouchPoints(t *testing.T) {
type touch struct {
typ int32 // 37 begin, 38 update, 39 end, 40 cancel, 0 reset
seq uintptr
}
type finger struct {
kind platform.SurfaceEventKind
id uint64
}
const (
down = platform.TouchDown
move = platform.TouchMove
up = platform.TouchUp
cancel = platform.TouchCancel
)
for _, tc := range []struct {
name string
touches []touch
want []finger
}{
{"one finger", []touch{{37, 0xa0}, {38, 0xa0}, {39, 0xa0}}, []finger{{down, 1}, {move, 1}, {up, 1}}},
{"four fingers swiping", []touch{
{37, 0xa0}, {37, 0xb0}, {37, 0xc0}, {37, 0xd0},
{38, 0xc0}, {38, 0xa0}, {38, 0xd0}, {38, 0xb0},
{39, 0xb0}, {39, 0xa0}, {39, 0xd0}, {39, 0xc0},
}, []finger{
{down, 1}, {down, 2}, {down, 3}, {down, 4},
{move, 3}, {move, 1}, {move, 4}, {move, 2},
{up, 2}, {up, 1}, {up, 4}, {up, 3},
}},
{"canceled", []touch{{37, 0xa0}, {37, 0xb0}, {40, 0xa0}, {38, 0xb0}, {38, 0xa0}},
[]finger{{down, 1}, {down, 2}, {cancel, 1}, {move, 2}}},
// GDK frees a sequence as its finger lifts, and may give the next
// finger the same.
{"sequence used again", []touch{{37, 0xa0}, {39, 0xa0}, {37, 0xa0}, {39, 0xa0}},
[]finger{{down, 1}, {up, 1}, {down, 2}, {up, 2}}},
// Fingers whose ends went unseen, as under a grab, are canceled
// as new touches begin.
{"reset", []touch{{37, 0xa0}, {37, 0xb0}, {0, 0}, {37, 0xa0}, {38, 0xb0}},
[]finger{{down, 1}, {down, 2}, {cancel, 1}, {cancel, 2}, {down, 3}}},
{"unknown sequences", []touch{{38, 0xe0}, {39, 0xe0}, {40, 0xe0}}, nil},
{"begun twice", []touch{{37, 0xa0}, {37, 0xa0}}, []finger{{down, 1}}},
} {
var p touchPoints
var got []finger
for _, tt := range tc.touches {
if tt.typ == 0 {
for _, id := range p.reset() {
got = append(got, finger{cancel, id})
}
continue
}
if kind, id, ok := p.event(tt.typ, tt.seq); ok {
got = append(got, finger{kind, id})
}
}
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("%s:\n got %v\nwant %v", tc.name, got, tc.want)
}
}
}