ueb10 1+2: fix delayed sound playback
This commit is contained in:
parent
ff0cbe4973
commit
84b42aaccd
@ -67,6 +67,14 @@ public class LevelModelTest {
|
|||||||
assertEquals(2, levelModel.getRockfordPositionX());
|
assertEquals(2, levelModel.getRockfordPositionX());
|
||||||
assertEquals(2,levelModel.getRockfordPositionY());
|
assertEquals(2,levelModel.getRockfordPositionY());
|
||||||
|
|
||||||
|
// The sounds are played in a different thread after an action occurred.
|
||||||
|
// This might happen after we verify the number of method calls.
|
||||||
|
// To avoid this, we sleep one second.
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
// No sound is played
|
// No sound is played
|
||||||
verify(audioLoadHelper, never()).playSound(anyString());
|
verify(audioLoadHelper, never()).playSound(anyString());
|
||||||
}
|
}
|
||||||
@ -113,7 +121,15 @@ public class LevelModelTest {
|
|||||||
// The starting field of Rockford becomes an empty field
|
// The starting field of Rockford becomes an empty field
|
||||||
assertInstanceOf(EmptyModel.class, groundLevelModel[1][1]);
|
assertInstanceOf(EmptyModel.class, groundLevelModel[1][1]);
|
||||||
|
|
||||||
//The sound for collecting a diamond is played.
|
// The sounds are played in a different thread after an action occurred.
|
||||||
|
// This might happen after we verify the number of method calls (which would make this test fail).
|
||||||
|
// To avoid this, we sleep one second.
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
// The sound for collecting a diamond is played.
|
||||||
verify(audioLoadHelper).playSound("coin");
|
verify(audioLoadHelper).playSound("coin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +188,15 @@ public class LevelModelTest {
|
|||||||
// `this.groundGrid[oldX][oldY] = new EmptyModel();`
|
// `this.groundGrid[oldX][oldY] = new EmptyModel();`
|
||||||
assertInstanceOf(EmptyModel.class, groundLevelModel[1][1]);
|
assertInstanceOf(EmptyModel.class, groundLevelModel[1][1]);
|
||||||
|
|
||||||
// play sound
|
// The sounds are played in a different thread after an action occurred.
|
||||||
|
// This might happen after we verify the number of method calls (which would make this test fail).
|
||||||
|
// To avoid this, we sleep one second.
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
// The sound for collecting a diamond is played.
|
||||||
verify(audioLoadHelper).playSound("coin");
|
verify(audioLoadHelper).playSound("coin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user