Skip to content

Commit bcaafb9

Browse files
committed
De-finalized classes to fix mocking. Widened threshold on synchronization tests
1 parent 43f5bd5 commit bcaafb9

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/main/java/bwapi/Player.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* @see PlayerType
1919
* @see Race
2020
*/
21-
public final class Player implements Comparable<Player> {
21+
public class Player implements Comparable<Player> {
2222
private final PlayerData playerData;
2323
private final Game game;
2424
private final int id;

src/main/java/bwapi/Unit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* However for units that were owned by the player, {@link #getPlayer} and {@link #getType} will continue to work for units
4040
* that have been destroyed.
4141
*/
42-
public final class Unit implements Comparable<Unit> {
42+
public class Unit implements Comparable<Unit> {
4343
private static final Set<Order> gatheringGasOrders = EnumSet.of(
4444
Harvest1, Harvest2, MoveToGas, WaitForGas, HarvestGas, ReturnGas, ResetCollision);
4545
private static final Set<Order> gatheringMineralOrders = EnumSet.of(

src/test/java/bwapi/SynchronizationTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public void sync_IfDelay_ThenNoBuffer() {
7373
public void async_IfBotDelay_ThenClientBuffers() {
7474
SynchronizationEnvironment environment = new SynchronizationEnvironment();
7575
environment.configuration
76-
.withAsync(true)
77-
.withMaxFrameDurationMs(10)
78-
.withAsyncFrameBufferCapacity(4);
76+
.withAsync(true)
77+
.withMaxFrameDurationMs(100)
78+
.withAsyncFrameBufferCapacity(4);
7979

8080
environment.onFrame(1, () -> {
81-
sleepUnchecked(50);
81+
sleepUnchecked(500);
8282
assertEquals("Bot should be observing an old frame", 1, environment.bwClient.getGame().getFrameCount());
8383
assertEquals("Client should be as far ahead as the frame buffer allows", 5, environment.liveGameData().getFrameCount());
8484
assertEquals("Bot should be behind the live game", 4, environment.bwClient.framesBehind());
@@ -97,20 +97,20 @@ public void async_IfBotDelay_ThenClientBuffers() {
9797
public void async_IfBotDelay_ThenClientStalls() {
9898
SynchronizationEnvironment environment = new SynchronizationEnvironment();
9999
environment.configuration
100-
.withAsync(true)
101-
.withMaxFrameDurationMs(50)
102-
.withAsyncFrameBufferCapacity(5);
100+
.withAsync(true)
101+
.withMaxFrameDurationMs(200)
102+
.withAsyncFrameBufferCapacity(5);
103103

104104
environment.onFrame(1, () -> {
105-
sleepUnchecked(125);
105+
sleepUnchecked(500);
106106
assertEquals("3: Bot should be observing an old frame", 1, environment.bwClient.getGame().getFrameCount());
107107
assertEquals("3: Client should have progressed as slowly as possible", 3, environment.liveGameData().getFrameCount());
108108
assertEquals("3: Bot should be behind the live game by as little as possible", 2, environment.bwClient.framesBehind());
109-
sleepUnchecked(50);
109+
sleepUnchecked(200);
110110
assertEquals("4: Bot should be observing an old frame", 1, environment.bwClient.getGame().getFrameCount());
111111
assertEquals("4: Client should have progressed as slowly as possible", 4, environment.liveGameData().getFrameCount());
112112
assertEquals("4: Bot should be behind the live game by as little as possible", 3, environment.bwClient.framesBehind());
113-
sleepUnchecked(50);
113+
sleepUnchecked(200);
114114
assertEquals("5: Bot should be observing an old frame", 1, environment.bwClient.getGame().getFrameCount());
115115
assertEquals("5: Client should have progressed as slowly as possible", 5, environment.liveGameData().getFrameCount());
116116
assertEquals("5: Bot should be behind the live game by as little as possible", 4, environment.bwClient.framesBehind());
@@ -211,7 +211,7 @@ public void async_MeasurePerformance_FrameBufferSizeAndFramesBehind() {
211211
* Number of milliseconds of leeway to give in potentially noisy performance metrics.
212212
* Increase if tests are flaky due to variance in execution speed.
213213
*/
214-
private final static long MS_MARGIN = 10;
214+
private final static long MS_MARGIN = 20;
215215

216216
@Test
217217
public void MeasurePerformance_BotResponse() {

0 commit comments

Comments
 (0)