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.
56 lines
2.0 KiB
Go
56 lines
2.0 KiB
Go
//go:build windows && (amd64 || arm64)
|
|
|
|
package windows
|
|
|
|
import (
|
|
"bytes"
|
|
"runtime"
|
|
"testing"
|
|
"unsafe"
|
|
|
|
"github.com/egoist/mygo/transfer"
|
|
)
|
|
|
|
func TestTransferDataStreamPosition(t *testing.T) {
|
|
runtime.LockOSThread()
|
|
defer runtime.UnlockOSThread()
|
|
dropOnce.Do(initDropTarget)
|
|
|
|
format := uint16(registerClipboardFormat("application/vnd.mygo.stream-test"))
|
|
for _, clipboard := range []bool{false, true} {
|
|
for _, payload := range [][]byte{nil, {0, 1, 2, 0}, bytes.Repeat([]byte{1, 0}, 64<<10)} {
|
|
checkTransferDataStream(t, format, clipboard, payload)
|
|
}
|
|
}
|
|
}
|
|
|
|
func checkTransferDataStream(t *testing.T, format uint16, clipboard bool, payload []byte) {
|
|
t.Helper()
|
|
data := transfer.New(transfer.NewItem(transfer.Bytes("application/vnd.mygo.stream-test", payload)))
|
|
object := newTransferData(data, "", clipboard, false)
|
|
defer release(object)
|
|
f := nativeFormat(format)
|
|
f.Tymed = tymedStream
|
|
var medium stgMedium
|
|
if hr := comCall(object, dataGetData, uintptr(unsafe.Pointer(&f)), uintptr(unsafe.Pointer(&medium))); failed(hr) {
|
|
t.Fatal(hresultError("IDataObject::GetData", hr))
|
|
}
|
|
defer procReleaseStgMedium.Call(uintptr(unsafe.Pointer(&medium)))
|
|
if medium.Tymed != tymedStream || medium.Handle == 0 {
|
|
t.Fatalf("GetData returned an invalid stream: %+v", medium)
|
|
}
|
|
var position uint64
|
|
if hr := comCall(medium.Handle, 5, 0, 1, uintptr(unsafe.Pointer(&position))); failed(hr) { // STREAM_SEEK_CUR
|
|
t.Fatal(hresultError("IStream::Seek", hr))
|
|
}
|
|
if position != uint64(len(payload)) {
|
|
t.Fatalf("clipboard=%t: GetData stream position %d, want payload length %d", clipboard, position, len(payload))
|
|
}
|
|
if got, err := readDragStream(medium.Handle); err != nil || !bytes.Equal(got, payload) {
|
|
t.Fatalf("clipboard=%t: readDragStream returned %d bytes: %v; want %d", clipboard, len(got), err, len(payload))
|
|
}
|
|
if got, err := oleDataBytes(object, format); err != nil || !bytes.Equal(got, payload) {
|
|
t.Fatalf("clipboard=%t: oleDataBytes returned %d bytes: %v; want %d", clipboard, len(got), err, len(payload))
|
|
}
|
|
}
|