-
Notifications
You must be signed in to change notification settings - Fork 83
/
sceneLoop_test.go
49 lines (44 loc) · 1020 Bytes
/
sceneLoop_test.go
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
39
40
41
42
43
44
45
46
47
48
49
package oak
import (
"testing"
"time"
"github.com/oakmound/oak/v4/scene"
)
func TestSceneLoopUnknownScene(t *testing.T) {
c1 := NewWindow()
err := c1.SceneMap.AddScene("blank", scene.Scene{})
if err != nil {
t.Fatalf("Scene Add failed: %v", err)
}
err = c1.Init("bad")
if err == nil {
t.Fatal("expected error from Init on unknown scene")
}
}
func TestSceneLoopUnknownErrorScene(t *testing.T) {
c1 := NewWindow()
err := c1.SceneMap.AddScene("blank", scene.Scene{})
if err != nil {
t.Fatalf("Scene Add failed: %v", err)
}
c1.ErrorScene = "bad2"
err = c1.Init("bad")
if err == nil {
t.Fatal("expected error from Init to error scene")
}
}
func TestSceneLoopErrorScene(t *testing.T) {
c1 := NewWindow()
err := c1.SceneMap.AddScene("blank", scene.Scene{})
if err != nil {
t.Fatalf("Scene Add failed: %v", err)
}
c1.ErrorScene = "blank"
go func() {
err = c1.Init("bad")
}()
time.Sleep(2 * time.Second)
if err != nil {
t.Fatalf("error transitioning to unknown scene: %v", err)
}
}