Increase time for replay tests, possible workaround for
-/*
- * Copyright 2018 MovingBlocks
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Copyright 2020 The Terasology Foundation
+// SPDX-License-Identifier: Apache-2.0
+
package org.terasology.recording;
import com.google.common.collect.Lists;
private TestEventHandler handler;
private RecordAndReplayCurrentStatus recordAndReplayCurrentStatus;
-
-
@BeforeEach
public void setup() {
ContextImpl context = new ContextImpl();
@@ -96,14 +82,13 @@ public void setup() {
handler = new TestEventHandler();
eventSystem.registerEventHandler(handler);
-
}
@Test
public void testReplayStatus() {
assertEquals(RecordAndReplayStatus.REPLAYING, recordAndReplayCurrentStatus.getStatus());
long startTime = System.currentTimeMillis();
- while ((System.currentTimeMillis() - startTime) < 30) {
+ while ((System.currentTimeMillis() - startTime) < 100) {
eventSystem.process();
}
assertEquals(RecordAndReplayStatus.REPLAY_FINISHED, recordAndReplayCurrentStatus.getStatus());
@@ -113,7 +98,7 @@ public void testReplayStatus() {
public void testProcessingRecordedEvent() {
assertEquals(0, handler.receivedAttackButtonList.size());
long startTime = System.currentTimeMillis();
- while ((System.currentTimeMillis() - startTime) < 10) {
+ while ((System.currentTimeMillis() - startTime) < 100) {
eventSystem.process();
}
assertEquals(3, handler.receivedAttackButtonList.size());
@@ -124,7 +109,7 @@ public void testBlockingEventDuringReplay() {
assertEquals(0, handler.receivedAttackButtonList.size());
eventSystem.send(entity, new AttackButton());
long startTime = System.currentTimeMillis();
- while ((System.currentTimeMillis() - startTime) < 10) {
+ while ((System.currentTimeMillis() - startTime) < 100) {
eventSystem.process();
}
assertEquals(3, handler.receivedAttackButtonList.size());
@@ -134,7 +119,7 @@ public void testBlockingEventDuringReplay() {
public void testSendingEventAfterReplay() {
assertEquals(0, handler.receivedAttackButtonList.size());
long startTime = System.currentTimeMillis();
- while ((System.currentTimeMillis() - startTime) < 10) {
+ while ((System.currentTimeMillis() - startTime) < 100) {
eventSystem.process();
}
eventSystem.send(entity, new AttackButton());
@@ -145,15 +130,13 @@ public void testSendingEventAfterReplay() {
public void testSendingAllowedEventDuringReplay() {
eventSystem.send(entity, new TestEvent());
long startTime = System.currentTimeMillis();
- while ((System.currentTimeMillis() - startTime) < 10) {
+ while ((System.currentTimeMillis() - startTime) < 100) {
eventSystem.process();
}
assertEquals(3, handler.receivedAttackButtonList.size());
assertEquals(1, handler.receivedTestEventList.size());
}
-
-
@AfterEach
public void cleanStates() {
recordAndReplayCurrentStatus.setStatus(RecordAndReplayStatus.NOT_ACTIVATED);
@@ -188,8 +171,4 @@ public void handleTestEvent(TestEvent event, EntityRef entity) {
private static class TestEvent extends AbstractConsumableEvent {
}
-
-
-
-
}
