mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Fixed AnimationState tests, added notes.
This commit is contained in:
parent
058b7587e1
commit
1254b06a91
@ -100,6 +100,13 @@ public class AnimationStateTests {
|
||||
}
|
||||
|
||||
private void add (Result result) {
|
||||
while (expected.size > actual.size) {
|
||||
Result note = expected.get(actual.size);
|
||||
if (!note.note) break;
|
||||
actual.add(note);
|
||||
log(note.name);
|
||||
}
|
||||
|
||||
String message = result.toString();
|
||||
if (actual.size >= expected.size) {
|
||||
message += "FAIL: <none>";
|
||||
@ -151,7 +158,7 @@ public class AnimationStateTests {
|
||||
expect(0, "dispose", 0, 0), //
|
||||
expect(1, "dispose", 0, 0), //
|
||||
|
||||
// First 2 set/addAnimation calls are done.
|
||||
note("First 2 set/addAnimation calls are done."),
|
||||
|
||||
expect(0, "start", 0, 0), //
|
||||
expect(0, "event 0", 0, 0), //
|
||||
@ -580,7 +587,7 @@ public class AnimationStateTests {
|
||||
expect(1, "event 0", 0, 0), //
|
||||
expect(1, "event 14", 0.5f, 0.5f), //
|
||||
|
||||
// First 2 setAnimation calls are done.
|
||||
note("First 2 setAnimation calls are done."),
|
||||
|
||||
expect(1, "interrupt", 0.8f, 0.8f), //
|
||||
|
||||
@ -612,7 +619,7 @@ public class AnimationStateTests {
|
||||
}
|
||||
});
|
||||
|
||||
setup("setAnimation twice with mix", // 22
|
||||
setup("setAnimation twice with mixing", // 22
|
||||
expect(0, "start", 0, 0), //
|
||||
expect(0, "interrupt", 0, 0), //
|
||||
expect(0, "end", 0, 0), //
|
||||
@ -621,7 +628,7 @@ public class AnimationStateTests {
|
||||
expect(1, "start", 0, 0), //
|
||||
expect(1, "event 0", 0, 0), //
|
||||
|
||||
// First 2 setAnimation calls are done.
|
||||
note("First 2 setAnimation calls are done."),
|
||||
|
||||
expect(1, "interrupt", 0.2f, 0.2f), //
|
||||
|
||||
@ -633,7 +640,70 @@ public class AnimationStateTests {
|
||||
expect(2, "start", 0, 0.2f), //
|
||||
expect(2, "event 0", 0.1f, 0.3f), //
|
||||
|
||||
// Second 2 setAnimation calls are done.
|
||||
note("Second 2 setAnimation calls are done."),
|
||||
|
||||
expect(2, "interrupt", 0.2f, 0.4f), //
|
||||
|
||||
expect(1, "start", 0, 0.4f), //
|
||||
expect(1, "interrupt", 0, 0.4f), //
|
||||
expect(1, "end", 0, 0.4f), //
|
||||
expect(1, "dispose", 0, 0.4f), //
|
||||
|
||||
expect(0, "start", 0, 0.4f), //
|
||||
expect(0, "event 0", 0.1f, 0.5f), //
|
||||
|
||||
expect(2, "end", 0.3f, 0.6f), //
|
||||
expect(2, "dispose", 0.3f, 0.6f), //
|
||||
|
||||
expect(0, "event 14", 0.5f, 0.9f), //
|
||||
|
||||
expect(1, "complete", 1, 1), //
|
||||
expect(1, "end", 1, 1.1f), //
|
||||
expect(1, "dispose", 1, 1.1f), //
|
||||
|
||||
expect(0, "event 30", 1, 1.4f), //
|
||||
expect(0, "complete", 1, 1.4f), //
|
||||
expect(0, "end", 1, 1.5f), //
|
||||
expect(0, "dispose", 1, 1.5f) //
|
||||
);
|
||||
stateData.setDefaultMix(0.6f);
|
||||
state.setAnimation(0, "events0", false); // First should be ignored.
|
||||
state.setAnimation(0, "events1", false);
|
||||
run(0.1f, 1000, new TestListener() {
|
||||
public void frame (float time) {
|
||||
if (MathUtils.isEqual(time, 0.2f)) {
|
||||
state.setAnimation(0, "events0", false); // First should be ignored.
|
||||
state.setAnimation(0, "events2", false);
|
||||
}
|
||||
if (MathUtils.isEqual(time, 0.4f)) {
|
||||
state.setAnimation(0, "events1", false); // First should be ignored.
|
||||
state.setAnimation(0, "events0", false).setTrackEnd(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setup("setAnimation twice with multiple mixing", // 23
|
||||
expect(0, "start", 0, 0), //
|
||||
expect(0, "interrupt", 0, 0), //
|
||||
expect(0, "end", 0, 0), //
|
||||
expect(0, "dispose", 0, 0), //
|
||||
|
||||
expect(1, "start", 0, 0), //
|
||||
expect(1, "event 0", 0, 0), //
|
||||
|
||||
note("First 2 setAnimation calls are done."),
|
||||
|
||||
expect(1, "interrupt", 0.2f, 0.2f), //
|
||||
|
||||
expect(0, "start", 0, 0.2f), //
|
||||
expect(0, "interrupt", 0, 0.2f), //
|
||||
expect(0, "end", 0, 0.2f), //
|
||||
expect(0, "dispose", 0, 0.2f), //
|
||||
|
||||
expect(2, "start", 0, 0.2f), //
|
||||
expect(2, "event 0", 0.1f, 0.3f), //
|
||||
|
||||
note("Second 2 setAnimation calls are done."),
|
||||
|
||||
expect(2, "interrupt", 0.2f, 0.4f), //
|
||||
|
||||
@ -659,6 +729,7 @@ public class AnimationStateTests {
|
||||
expect(0, "dispose", 1, 1.5f) //
|
||||
);
|
||||
stateData.setDefaultMix(0.6f);
|
||||
state.setMultipleMixing(true);
|
||||
state.setAnimation(0, "events0", false); // First should be ignored.
|
||||
state.setAnimation(0, "events1", false);
|
||||
run(0.1f, 1000, new TestListener() {
|
||||
@ -673,8 +744,9 @@ public class AnimationStateTests {
|
||||
}
|
||||
}
|
||||
});
|
||||
state.setMultipleMixing(false);
|
||||
|
||||
setup("addAnimation with delay on empty track", // 23
|
||||
setup("addAnimation with delay on empty track", // 24
|
||||
expect(0, "start", 0, 0), //
|
||||
expect(0, "event 0", 0, 5), //
|
||||
expect(0, "event 14", 0.5f, 5.5f), //
|
||||
@ -686,7 +758,7 @@ public class AnimationStateTests {
|
||||
state.addAnimation(0, "events0", false, 5).setTrackEnd(1);
|
||||
run(0.1f, 10, null);
|
||||
|
||||
setup("setAnimation during AnimationStateListener"); // 24
|
||||
setup("setAnimation during AnimationStateListener"); // 25
|
||||
state.addListener(new AnimationStateListener() {
|
||||
public void start (TrackEntry entry) {
|
||||
if (entry.getAnimation().getName().equals("events0")) state.setAnimation(1, "events1", false);
|
||||
@ -717,7 +789,7 @@ public class AnimationStateTests {
|
||||
state.setAnimation(1, "events1", false).setTrackEnd(1);
|
||||
run(0.1f, 10, null);
|
||||
|
||||
setup("clearTrack", // 25
|
||||
setup("clearTrack", // 26
|
||||
expect(0, "start", 0, 0), //
|
||||
expect(0, "event 0", 0, 0), //
|
||||
expect(0, "event 14", 0.5f, 0.5f), //
|
||||
@ -731,7 +803,7 @@ public class AnimationStateTests {
|
||||
}
|
||||
});
|
||||
|
||||
setup("setEmptyAnimation", // 26
|
||||
setup("setEmptyAnimation", // 27
|
||||
expect(0, "start", 0, 0), //
|
||||
expect(0, "event 0", 0, 0), //
|
||||
expect(0, "event 14", 0.5f, 0.5f), //
|
||||
@ -753,7 +825,7 @@ public class AnimationStateTests {
|
||||
}
|
||||
});
|
||||
|
||||
setup("TrackEntry listener"); // 27
|
||||
setup("TrackEntry listener"); // 28
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
state.addAnimation(0, "events0", false, 0).setListener(new AnimationStateListener() {
|
||||
public void start (TrackEntry entry) {
|
||||
@ -785,7 +857,7 @@ public class AnimationStateTests {
|
||||
state.setAnimation(1, "events1", false).setTrackEnd(1);
|
||||
run(0.1f, 10, null);
|
||||
if (counter.get() != 15082016) {
|
||||
log("TEST 26 FAILED! " + counter);
|
||||
log("TEST 28 FAILED! " + counter);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@ -893,6 +965,13 @@ public class AnimationStateTests {
|
||||
return result;
|
||||
}
|
||||
|
||||
Result note (String message) {
|
||||
Result result = new Result();
|
||||
result.name = message;
|
||||
result.note = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
void log (String message) {
|
||||
System.out.println(message);
|
||||
}
|
||||
@ -901,6 +980,7 @@ public class AnimationStateTests {
|
||||
String name;
|
||||
int animationIndex;
|
||||
float trackTime, totalTime;
|
||||
boolean note;
|
||||
|
||||
public int hashCode () {
|
||||
int result = 31 + animationIndex;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user