Feedback: review r2 fixes
This commit is contained in:
6 files changed
+122
-28
No files matched your search
@@ -60,6 +60,9 @@ func TestFeedbackRejectsInvalidInput(t *testing.T) {
|
||||
"status unknown labeled": func(c *ui.Context) { StatusIndicator(c, 42, StatusIndicatorOptions{Label: "Custom"}) },
|
||||
"alert severity": func(c *ui.Context) { Alert(c, nil, "x", AlertOptions{Severity: 9}) },
|
||||
"toast severity": func(c *ui.Context) { ShowToast(c, ToastMessage{Message: "x", Severity: -1}) },
|
||||
"meter negative width": func(c *ui.Context) { Meter(c, 1, MeterOptions{Max: 2, Width: -1}) },
|
||||
"meter NaN width": func(c *ui.Context) { Meter(c, 1, MeterOptions{Max: 2, Width: float32(nan)}) },
|
||||
"meter infinite width": func(c *ui.Context) { Meter(c, 1, MeterOptions{Max: 2, Width: float32(inf)}) },
|
||||
} {
|
||||
func() {
|
||||
defer func() {
|
||||
@@ -82,3 +85,75 @@ func TestNotificationTitleOnlyHitHeight(t *testing.T) {
|
||||
t.Fatalf("title-only notification hit box %v %v", r, ok)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotificationHeaderWrapsAtDoubleText(t *testing.T) {
|
||||
items := []Notification{{ID: "a", Title: "Build failed"}, {ID: "b", Title: "Backup complete", Read: true}}
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
Use(c, Settings{})
|
||||
ui.Column(c).Width(520).Height(700).Children(func() {
|
||||
NotificationCenter(c, &items, NotificationCenterOptions{})
|
||||
})
|
||||
}, 600, 760)
|
||||
tt.SetPreferences(ui.Preferences{TextScale: 2})
|
||||
for _, s := range []string{"Notifications", "1 unread", "Mark all read", "Clear all"} {
|
||||
if r, ok := tt.Find(s); !ok || r.W == 0 || r.H == 0 || r.X < 0 || r.X+r.W > 520 {
|
||||
t.Errorf("%q at 200%%: %v %v", s, r, ok)
|
||||
}
|
||||
}
|
||||
if err := tt.Click("Clear all"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(items) != 0 {
|
||||
t.Fatalf("Clear all at 200%% left %d items", len(items))
|
||||
}
|
||||
}
|
||||
|
||||
func TestProgressRingCaptionFitsAtDoubleText(t *testing.T) {
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
Use(c, Settings{})
|
||||
ui.Row(c).Children(func() {
|
||||
Progress(c, 1, ProgressOptions{Shape: ProgressRing, ShowValue: true})
|
||||
})
|
||||
}, 400, 200)
|
||||
for _, scale := range []float32{1, 2} {
|
||||
tt.SetPreferences(ui.Preferences{TextScale: scale})
|
||||
tt.Frame()
|
||||
ring, ok := tt.Find("Loading")
|
||||
text, ok2 := tt.Find("100%")
|
||||
if !ok || !ok2 {
|
||||
t.Fatalf("scale %v: ring %v text %v", scale, ok, ok2)
|
||||
}
|
||||
stroke := max(float32(3), ring.W/10)
|
||||
inside := text.X >= ring.X+stroke && text.X+text.W <= ring.X+ring.W-stroke
|
||||
outside := text.X >= ring.X+ring.W
|
||||
if !inside && !outside {
|
||||
t.Errorf("scale %v: caption %v clipped by ring %v", scale, text, ring)
|
||||
}
|
||||
if scale == 1 && !inside {
|
||||
t.Errorf("caption left the ring at 100%%: %v", text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProgressResumesFromDisplayedValueAfterReducedMotion(t *testing.T) {
|
||||
v := 0.0
|
||||
var bar ui.Rect
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
Use(c, Settings{Mode: Light})
|
||||
ui.Column(c).Width(300).Children(func() {
|
||||
bar = Progress(c, v, ProgressOptions{}).Bounds()
|
||||
})
|
||||
}, 400, 100)
|
||||
tt.SetPreferences(ui.Preferences{ReduceMotion: true, TextScale: 1})
|
||||
v = 0.5
|
||||
tt.Frame()
|
||||
tt.SetPreferences(ui.Preferences{TextScale: 1})
|
||||
if got, want := progressPixel(tt, bar.X+bar.W*0.45, bar.Y+bar.H/2), theme.Light().AccentText; got != want {
|
||||
t.Fatalf("after motion returned the fill at 45%% is %v, want %v", got, want)
|
||||
}
|
||||
v = 1
|
||||
tt.Frame()
|
||||
if got := progressPixel(tt, bar.X+bar.W*0.95, bar.Y+bar.H/2); got == theme.Light().AccentText {
|
||||
t.Fatal("restored motion did not animate the next change")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user