Clicking magpie's Dock icon plays the header logo's .logo.wag on the tile: the same keyframes, turn points, .9s and cubic-bezier(.3, 0, .3, 1), a frame every 30ms. The icon macOS draws (its glass tile and glossy bird) is cut into body, tail and wing by index.html's own clip paths, the tile under the bird filled with the tile's colour read either side of it, and each frame turns the pieces over it, set as the Dock tile's content view. The tile goes back to the system's icon after. It plays only when the Dock draws icons light (no AppleIconAppearanceTheme, RegularLight, or RegularAutomatic in light mode); a dark, clear or tinted Dock is left as it is. A click while it plays doesn't start another. Run: - go test ./internal/gui/ -run TestDockFlap: TestDockFlapIsTheLogos holds the keyframes, origins, length and easing to app.css and parses the bird and clips out of the embedded index.html. Broken by hand: changing one keyframe in flapkeys.go turns it red. - TestDockFlapFrames (MAGPIE_DOCK_APP=/Applications/magpie.app) wrote the 31 frames; looked at by eye. Frame 0 against the system's own 512px render: inside the tile 0.03% of pixels differ by over 40/255 (the tile's rim resampled); the pieces' seams were visible until they overlapped by 1px. - A sandbox bundle (own bundle id, sandbox HOME, ports 3446/3447) got the Dock's reopen event by pid: a burst of screen captures of the real Dock shows the tile in different poses. - go vet ./internal/gui/, GOOS=windows go vet, GOOS=linux go vet -tags nogui, GOOS=linux go build -tags nogui, GOOS=windows go build, gofmt -l. Not tried: a dark or tinted Dock (skipped by the gate, not drawn), a real mouse click on the Dock (the same reopen event, sent by pid).
26 lines
627 B
Go
26 lines
627 B
Go
//go:build darwin && cgo
|
|
|
|
package gui
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// TestDockFlapFrames writes the Dock tile's frames, cut from the icon of
|
|
// MAGPIE_DOCK_APP (an installed magpie.app), into MAGPIE_DOCK_FRAMES, to
|
|
// look at by eye.
|
|
func TestDockFlapFrames(t *testing.T) {
|
|
app, dir := os.Getenv("MAGPIE_DOCK_APP"), os.Getenv("MAGPIE_DOCK_FRAMES")
|
|
if app == "" || dir == "" {
|
|
t.Skip("set MAGPIE_DOCK_APP and MAGPIE_DOCK_FRAMES")
|
|
}
|
|
for f := 0; f <= 30; f++ {
|
|
if !dockFramePNG(app, filepath.Join(dir, fmt.Sprintf("f%02d.png", f)), float64(f)/30) {
|
|
t.Fatalf("frame %d not written", f)
|
|
}
|
|
}
|
|
}
|