(t *testing.T)
| 132 | } |
| 133 | |
| 134 | func TestAnimationComponentIntegration(t *testing.T) { |
| 135 | drawables := []Drawable{ |
| 136 | &TestDrawable{0}, |
| 137 | &TestDrawable{1}, |
| 138 | &TestDrawable{2}, |
| 139 | } |
| 140 | ac := NewAnimationComponent(drawables, 0.1) |
| 141 | firstFrames := []int{0, 1, 2} |
| 142 | secondFrames := []int{1, 2, 1, 0} |
| 143 | actions := []*Animation{ |
| 144 | { |
| 145 | Name: "ZeroOneTwo", |
| 146 | Frames: firstFrames, |
| 147 | }, |
| 148 | { |
| 149 | Name: "OneTwoOneZero", |
| 150 | Frames: secondFrames, |
| 151 | }, |
| 152 | } |
| 153 | def := &Animation{ |
| 154 | Name: "default", |
| 155 | Frames: []int{2, 1, 2}, |
| 156 | } |
| 157 | ac.AddAnimations(actions) |
| 158 | ac.AddDefaultAnimation(def) |
| 159 | ac.SelectAnimationByName("ZeroOneTwo") |
| 160 | exp := []int{0, 1, 2, 2, 1, 2, 2, 1, 2} |
| 161 | for _, e := range exp { |
| 162 | if ac.CurrentAnimation == nil { |
| 163 | ac.SelectAnimationByAction(def) |
| 164 | } |
| 165 | d := ac.Cell() |
| 166 | td := d.(*TestDrawable) |
| 167 | if td.ID != e { |
| 168 | t.Errorf("Wrong frame from AnimationComponent.Cell()\nWanted: %v\nGot: %v", e, td.ID) |
| 169 | return |
| 170 | } |
| 171 | ac.NextFrame() |
| 172 | } |
| 173 | ac.SelectAnimationByName("OneTwoOneZero") |
| 174 | exp = []int{1, 2, 1, 0, 2, 1, 2} |
| 175 | for _, e := range exp { |
| 176 | if ac.CurrentAnimation == nil { |
| 177 | ac.SelectAnimationByAction(def) |
| 178 | } |
| 179 | d := ac.Cell() |
| 180 | td := d.(*TestDrawable) |
| 181 | if td.ID != e { |
| 182 | t.Errorf("Wrong frame from AnimationComponent.Cell()\nWanted: %v\nGot: %v", e, td.ID) |
| 183 | return |
| 184 | } |
| 185 | ac.NextFrame() |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | func TestAnimationComponentNextFrameNoData(t *testing.T) { |
| 190 | var buf bytes.Buffer |
nothing calls this directly
no test coverage detected