-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhub_test.go
More file actions
38 lines (30 loc) · 732 Bytes
/
hub_test.go
File metadata and controls
38 lines (30 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package gease
import (
"math"
"testing"
"time"
"gioui.org/unit"
)
func TestConverge(t *testing.T) {
hub := NewHub()
es1 := Unit(unit.Dp(10))
es2 := Unit(unit.Dp(20))
es3 := Unit(unit.Dp(30))
es1.Target(unit.Dp(33))
es2.Target(unit.Dp(33))
es3.Target(unit.Dp(33))
hub.Add(es1, es2, es3)
hub.Remove(es1)
tt := time.Now().Add(time.Millisecond * 10)
for !hub.Step(tt) {
tt = tt.Add(time.Millisecond * 10)
}
// We expect it to have converged on both these two, but also
// that the first one ahs not been updated.
if es1.V() != unit.Dp(10) {
t.Error("expected not changed")
}
if math.Abs(float64(es2.V().V-33)) > 0.15 || math.Abs(float64(es3.V().V-33)) > 0.15 {
t.Error("expected them to change")
}
}