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.
88 lines
2.7 KiB
Go
88 lines
2.7 KiB
Go
//go:build linux && !android && (amd64 || arm64)
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo"
|
|
"github.com/egoist/mygo/internal/linux"
|
|
"github.com/egoist/mygo/internal/wait"
|
|
)
|
|
|
|
// programName is the helper process of TestProgramNameByALink: it prints
|
|
// the name GLib has for the program once the app runs.
|
|
func programName() {
|
|
if name := os.Getenv("MYGO_E2E_PROGRAM_NAME_SET"); name != "" {
|
|
if err := linux.TestSetProgramName(name); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
mygo.App.WhenReady(func() {
|
|
fmt.Println("program:", linux.TestProgramName())
|
|
go mygo.App.Quit()
|
|
})
|
|
if err := mygo.App.Run(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
// TestProgramNameByALink starts the app through a link of another name, as
|
|
// linux.command puts in /usr/bin: it is the program of its executable all
|
|
// the same, after which GTK names the class of its windows, as the desktop
|
|
// entry does, and WebKitGTK the directories of its pages' data. It was the
|
|
// program of the link, whose window no desktop entry named and whose pages
|
|
// found another localStorage.
|
|
func TestProgramNameByALink(t *testing.T) {
|
|
exe, err := os.Executable()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
link := filepath.Join(t.TempDir(), "another-name")
|
|
if err := os.Symlink(exe, link); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
ctx := wait.Context(t)
|
|
for _, name := range []string{exe, link} {
|
|
cmd := exec.CommandContext(ctx, name, "-test.run=^$")
|
|
cmd.Env = append(os.Environ(), "MYGO_E2E_PROGRAM_NAME=1")
|
|
out, err := cmd.Output()
|
|
if want := "program: " + filepath.Base(exe); err != nil || strings.TrimSpace(string(out)) != want {
|
|
t.Errorf("started as %s: output %q, %v, want %q", name, out, err, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestProgramNameTheAppSet starts an app that names the program itself
|
|
// before Run, as one does to give its windows the reverse-DNS ID of its
|
|
// desktop entry: it keeps that name, by its executable or a link, so its
|
|
// windows match the entry. Run named it after the executable all the same,
|
|
// and the windows had the executable's class and app id.
|
|
func TestProgramNameTheAppSet(t *testing.T) {
|
|
exe, err := os.Executable()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
link := filepath.Join(t.TempDir(), "another-name")
|
|
if err := os.Symlink(exe, link); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
const id = "org.example.ProgramName"
|
|
ctx := wait.Context(t)
|
|
for _, name := range []string{exe, link} {
|
|
cmd := exec.CommandContext(ctx, name, "-test.run=^$")
|
|
cmd.Env = append(os.Environ(), "MYGO_E2E_PROGRAM_NAME=1", "MYGO_E2E_PROGRAM_NAME_SET="+id)
|
|
out, err := cmd.Output()
|
|
if want := "program: " + id; err != nil || strings.TrimSpace(string(out)) != want {
|
|
t.Errorf("started as %s: output %q, %v, want %q", name, out, err, want)
|
|
}
|
|
}
|
|
}
|