NextCommit (macOS, 0.1.1244) hovered the menu bar item for today's
tokens split into input, output and cache and saw nothing. Nothing was
shown at all: Wails v3.0.0-beta.24's macosSystemTray.setTooltip is a
no-op ("Tooltips not supported on macOS"), so neither the idle tip nor a
card's tooltip (usage:today already said "6.3M tokens (912K in · 318K
out · 5.1M cached)") ever reached a Mac. Linux has its own setTrayTip
(SNI); Windows keeps Wails'.
setTrayTip on the Mac now sets the status item's button toolTip on the
main queue (trayTipNative, mpTip in trayimage_darwin.go), returning false
while the item isn't up yet so it is tried again, as Linux's does.
Run: TestMacTrayTipIsSet (darwin, cgo): setTrayTip reaches the native
setter, false before the item is up, and a real NSStatusBarButton keeps a
multi-line tip whole. go vet: darwin (cgo, GUI) and -tags nogui for
darwin, linux and windows. Not tried: hovering the icon in a built app.
Full suite: SUITE_LINE
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
//go:build darwin && cgo && !nogui
|
|
|
|
package gui
|
|
|
|
import "testing"
|
|
|
|
// NextCommit on Discord: hovering the Mac's menu bar item showed no
|
|
// tooltip at all, so neither today's tokens split into input, output and
|
|
// cache nor the quotas were ever seen there. Wails' SetTooltip does nothing
|
|
// on macOS; the tooltip is set on the item's button, its lines kept, and a
|
|
// tooltip set before the item is up is tried again (false).
|
|
func TestMacTrayTipIsSet(t *testing.T) {
|
|
var got []string
|
|
ok := false
|
|
old := trayTipNative
|
|
trayTipNative = func(tip string) bool { got = append(got, tip); return ok }
|
|
t.Cleanup(func() { trayTipNative = old })
|
|
|
|
tip := "Today in magpie\n6.3M tokens (912K in · 318K out · 5.1M cached)\n≈$3.40+\n152 requests"
|
|
if setTrayTip(nil, tip) {
|
|
t.Error("set before the item is up: want false, to be tried again")
|
|
}
|
|
ok = true
|
|
if !setTrayTip(nil, tip) {
|
|
t.Error("set on the item: want true")
|
|
}
|
|
if len(got) != 2 || got[0] != tip || got[1] != tip {
|
|
t.Fatalf("native tooltip set %q, want %q twice", got, tip)
|
|
}
|
|
|
|
// what a status bar button shows: the text whole, every line of it
|
|
if shown := trayTipShown(tip); shown != tip {
|
|
t.Errorf("button shows %q, want %q", shown, tip)
|
|
}
|
|
if shown := trayTipShown(""); shown != "" {
|
|
t.Errorf("empty tip shows %q", shown)
|
|
}
|
|
}
|