Files
magpie/internal/gui/panel_options_test.go
T
yetone b2d558db97 gui: on the Mac the quick panel opens over a full-screen app, on the Space the user is on, not on the desktop it was first shown on (#2141)
With Chrome full screen and Settings > Click the tray icon set to the
quick panel, a click on the menu bar icon flashed the icon and showed the
panel on the non-full-screen desktop instead, out of sight until the user
swiped back (witt-bit, macOS 27.0.1, v0.1.1230). The panel's window had no
collection behaviour of its own, so Wails gave it FullScreenPrimary alone:
an ordinary window, kept on the Space it was first ordered in on, and not
allowed on a full-screen app's Space. It now has CanJoinAllSpaces |
FullScreenAuxiliary, as a menu bar extra's panel (and Wails' own notch
window) does, so it is on every Space, full-screen ones too. It never
moves to the active Space as well (AppKit refuses that pair), and nothing
calls setMovesToActiveSpace on it (showHere is the main window's only).
The panel lightweight mode makes again takes the same options.

Tests:
- TestPanelOnEverySpaceOnMac (panel_options_test.go) checks the options.
- TestPanelJoinsFullScreenSpaces (AppKit, runAppKit) makes the real panel
  through panelWin, at start and again after lightweight mode let it go,
  shows and hides it, and reads NSWindow.collectionBehavior
  (joinsFullScreenSpaces).
- Without the change both fail: "panel collection behaviour 0 is not on
  every Space and over full-screen ones" and "made at start: the panel
  isn't on every Space and over full-screen ones".

Run: gofmt -l (clean); go vet ./internal/gui/ (darwin),
GOOS=linux go vet -tags nogui, GOOS=windows go vet; go build,
GOOS=linux go build -tags nogui, GOOS=windows go build; go test
./internal/gui/ under a sandbox HOME with pinned caches. In the package
run, at load average ~300-420 from other sessions, two tests unrelated to
the panel failed: TestMainWindowCorners (40s deadline killed; fails the
same on clean origin/main c4c3cafa2, filed as #1936) and
TestSetAnswersWhileDevinAndProvidersHang (filed as #1375; passed on clean
c4c3cafa2 right after). Panel, dock and Space tests pass.

Not tried: a real full-screen Space. A test can't make one, and doing it
by hand would take over the owner's screen; the reporter is asked to
confirm on the next release.
2026-10-14 16:12:44 +08:00

65 lines
3.3 KiB
Go

//go:build !nogui
package gui
import (
"testing"
"github.com/wailsapp/wails/v3/pkg/application"
)
// #238: on Windows the frameless, translucent panel showed DWM's caption
// close X at its top right; its caption buttons are hidden there (no
// WS_SYSMENU), and left as they were on the Mac and Linux.
func TestPanelOptionsCaptionButtons(t *testing.T) {
w := panelOptions("windows", "")
if !w.Frameless || w.BackgroundType != application.BackgroundTypeTranslucent || !w.Windows.HiddenOnTaskbar {
t.Fatalf("windows panel lost its frameless, translucent, off-taskbar options: %+v", w)
}
if w.CloseButtonState != application.ButtonHidden || w.MinimiseButtonState != application.ButtonHidden || w.MaximiseButtonState != application.ButtonHidden {
t.Errorf("windows panel caption buttons = close %v min %v max %v, want all hidden", w.CloseButtonState, w.MinimiseButtonState, w.MaximiseButtonState)
}
if w.Windows.DisableFramelessWindowDecorations {
t.Errorf("windows panel should keep its shadow and round corners")
}
for _, goos := range []string{"darwin", "linux"} {
o := panelOptions(goos, "&theme=dark")
if o.CloseButtonState != application.ButtonEnabled || o.MinimiseButtonState != application.ButtonEnabled || o.MaximiseButtonState != application.ButtonEnabled {
t.Errorf("%s panel caption buttons changed: close %v min %v max %v", goos, o.CloseButtonState, o.MinimiseButtonState, o.MaximiseButtonState)
}
if o.URL != "/?mode=panel&theme=dark" || !o.Frameless || o.Mac.CornerRadius != 12 || o.Mac.Backdrop != application.MacBackdropTranslucent {
t.Errorf("%s panel options changed: %+v", goos, o)
}
}
}
// #1803: on Linux a see-through panel (an RGBA GTK window under a
// transparent webview) left a fainter copy of the old scroll position's
// paint behind; the panel is a solid window there, as the main window is.
// The Mac and Windows keep their translucent panel.
func TestPanelSolidOnLinux(t *testing.T) {
if o := panelOptions("linux", ""); o.BackgroundType != application.BackgroundTypeSolid || !o.Frameless || !o.AlwaysOnTop {
t.Errorf("linux panel = background %v frameless %v on top %v, want a solid, frameless, on-top window", o.BackgroundType, o.Frameless, o.AlwaysOnTop)
}
for _, goos := range []string{"darwin", "windows"} {
if o := panelOptions(goos, ""); o.BackgroundType != application.BackgroundTypeTranslucent {
t.Errorf("%s panel background = %v, want translucent", goos, o.BackgroundType)
}
}
}
// #2141: over a full-screen app the menu bar icon showed the quick panel on
// the desktop Space it was first shown on. On the Mac the panel is on every
// Space, full-screen ones among them, as a menu bar extra's panel is, and
// doesn't also move to the active Space (AppKit refuses the two together).
func TestPanelOnEverySpaceOnMac(t *testing.T) {
b := panelOptions("darwin", "").Mac.CollectionBehavior
want := application.MacWindowCollectionBehaviorCanJoinAllSpaces | application.MacWindowCollectionBehaviorFullScreenAuxiliary
if b&want != want {
t.Errorf("panel collection behaviour %d is not on every Space and over full-screen ones", b)
}
if b&(application.MacWindowCollectionBehaviorMoveToActiveSpace|application.MacWindowCollectionBehaviorFullScreenPrimary) != 0 {
t.Errorf("panel collection behaviour %d moves to the active Space or goes full screen itself", b)
}
}