- internal/shortcut/kind.go: deteksi dari isi berkas - build info Go, magic AppImage, resources/*.asar untuk Electron, shebang untuk script, MZ untuk .exe - .exe Windows kini boleh dipasang dan dijalankan lewat wine (Exec=wine <path>); kalau wine tidak terpasang, install ditolak dengan pesan jelas - metadata menyimpan kind; chip jenis ditampilkan di setiap baris shortcut (data lama tetap tampil sebagai Executable/PWA) - dialog menampilkan hasil deteksi setelah berkas dipilih, mis. 'winbox.exe - windows' - README: bagian label otomatis + screenshot baru
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package ui
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"fyne.io/fyne/v2/test"
|
|
|
|
"lazyrun/internal/shortcut"
|
|
"lazyrun/internal/store"
|
|
)
|
|
|
|
func TestBuildMainWindow(t *testing.T) {
|
|
a := test.NewApp()
|
|
defer a.Quit()
|
|
|
|
ui, err := build(a, "test")
|
|
if err != nil {
|
|
t.Fatalf("build(): %v", err)
|
|
}
|
|
if ui.win.Content() == nil {
|
|
t.Fatal("window tanpa content")
|
|
}
|
|
|
|
// dialog harus bisa dibuka tanpa panic
|
|
ui.showExecutableDialog()
|
|
ui.showWebAppDialog()
|
|
ui.checkUpdates()
|
|
}
|
|
|
|
func TestMetaText(t *testing.T) {
|
|
sc := store.Shortcut{Type: store.TypeWebApp, URL: "https://example.com/x", Targets: store.Targets{Menu: true}}
|
|
if got := metaText(sc); got != "example.com" {
|
|
t.Errorf("metaText() = %q", got)
|
|
}
|
|
exe := store.Shortcut{Type: store.TypeExecutable, BinaryPath: "/home/u/.local/bin/winbox"}
|
|
if got := metaText(exe); got != "winbox" {
|
|
t.Errorf("metaText() = %q", got)
|
|
}
|
|
}
|
|
|
|
func TestKindLabel(t *testing.T) {
|
|
cases := map[string]string{
|
|
shortcut.KindGo: "Go",
|
|
shortcut.KindAppImage: "AppImage",
|
|
shortcut.KindElectron: "Electron",
|
|
shortcut.KindScript: "Script",
|
|
shortcut.KindWindows: "Windows",
|
|
shortcut.KindBinary: "Binary",
|
|
shortcut.KindPWA: "PWA",
|
|
}
|
|
for kind, want := range cases {
|
|
sc := store.Shortcut{Kind: kind, Type: store.TypeExecutable}
|
|
if got := kindLabel(sc); got != want {
|
|
t.Errorf("kindLabel(%q) = %q, mau %q", kind, got, want)
|
|
}
|
|
}
|
|
|
|
// data lama tanpa kind
|
|
if got := kindLabel(store.Shortcut{Type: store.TypeExecutable}); got != "Executable" {
|
|
t.Errorf("kindLabel(lama, executable) = %q", got)
|
|
}
|
|
if got := kindLabel(store.Shortcut{Type: store.TypeWebApp}); got != "PWA" {
|
|
t.Errorf("kindLabel(lama, webapp) = %q", got)
|
|
}
|
|
}
|