Snapshots: hide view until ReduceMotion applies; Spinner repaints when motion setting flips

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 12:11:04 -04:00
1 parent 5978b0dd60
commit bae0a48351
2 files changed
+8 -2

No files matched your search

+7 -1
View File
@@ -20,11 +20,17 @@ var update = flag.Bool("update", false, "rewrite snapshots")
func snapshot(t *testing.T, name string, w, h int, view func(c *ui.Context)) {
t.Helper()
for _, m := range []Mode{Light, Dark} {
ready := false
tt := ui.NewTester(func(c *ui.Context) {
Use(c, Settings{Mode: m})
view(c)
if ready {
view(c)
}
}, w, h)
// Animations must not paint before ReduceMotion applies.
tt.SetPreferences(ui.Preferences{ReduceMotion: true, TextScale: 1})
ready = true
tt.Frame()
got := encode(t, tt.Image())
path := filepath.Join("testdata", "snapshots", runtime.GOOS, name+"-"+strings.ToLower(m.String())+".png")
if *update {
+1 -1
View File
@@ -36,7 +36,7 @@ func Spinner(c *ui.Context, opts SpinnerOptions) *ui.Element {
still := c.Preferences().ReduceMotion
row := ui.Row(c).Gap(Density(c).Unit() * 2).AlignItems(ui.Center).Role(ui.RoleProgress).Label(label)
row.Children(func() {
ui.Box(c).Size(size, size).Shrink(0).Draw(func(p *ui.Painter, r ui.Rect) {
ui.Box(c).Key(still).Size(size, size).Shrink(0).Draw(func(p *ui.Painter, r ui.Rect) {
turn := 0.0
if !still {
turn = float64(p.Now().UnixMilli()%1200) / 1200