WIP components (as built)
This commit is contained in:
71 files changed
+3241
-468
No files matched your search
@@ -2,6 +2,7 @@ package mujica
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -83,3 +84,47 @@ func TestCountUpSnapshot(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestCountUpFiniteExtremeInterpolation(t *testing.T) {
|
||||
value := -math.MaxFloat64
|
||||
tt, _ := motionFrames(func(c *ui.Context) {
|
||||
CountUp(c, value, CountUpOptions{Duration: time.Second, Format: func(v float64) string {
|
||||
if math.IsNaN(v) || math.IsInf(v, 0) {
|
||||
t.Fatal("finite endpoints produced non-finite text")
|
||||
}
|
||||
return fmt.Sprintf("%g", v)
|
||||
}})
|
||||
}, 300, 80)
|
||||
value = math.MaxFloat64
|
||||
tt.Frame()
|
||||
}
|
||||
|
||||
func TestCountUpOffscreenStopsFrames(t *testing.T) {
|
||||
value := 1.0
|
||||
tt, n := motionFrames(func(c *ui.Context) {
|
||||
ui.Column(c).Height(80).Clip().Children(func() {
|
||||
ui.Box(c).Size(10, 200).Shrink(0)
|
||||
CountUp(c, value, CountUpOptions{Duration: time.Second})
|
||||
})
|
||||
}, 300, 80)
|
||||
value = 2
|
||||
tt.Frame()
|
||||
if motionBusy(tt, n) {
|
||||
t.Fatal("offscreen CountUp requested continuous rebuilds")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCountUpRestoredMotionKeepsFinalValue(t *testing.T) {
|
||||
value := 0.0
|
||||
shown := 0.0
|
||||
tt, n := motionFrames(func(c *ui.Context) {
|
||||
CountUp(c, value, CountUpOptions{Duration: 5 * time.Second, Format: func(v float64) string { shown = v; return fmt.Sprintf("%g", v) }})
|
||||
}, 300, 100)
|
||||
value = 100
|
||||
tt.Frame()
|
||||
tt.SetPreferences(ui.Preferences{ReduceMotion: true, TextScale: 1})
|
||||
tt.SetPreferences(ui.Preferences{TextScale: 1})
|
||||
if shown != 100 || motionBusy(tt, n) {
|
||||
t.Fatalf("restored value %v", shown)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user