Add Event Cancellation #3

Merged
kske merged 6 commits from f/cancel-event into develop 2020-11-26 08:57:46 +01:00
Showing only changes of commit 659bd7888f - Show all commits

View File

@ -12,8 +12,7 @@ import org.junit.jupiter.api.*;
*/ */
class EventBusTest implements EventListener { class EventBusTest implements EventListener {
int hits; int hits, cancelledHits;
static int canceledHits;
@BeforeEach @BeforeEach
public void registerListener() { public void registerListener() {
@ -28,10 +27,8 @@ class EventBusTest implements EventListener {
@Test @Test
void testCancellation() { void testCancellation() {
var test2 = new EventBusTest();
test2.registerListener();
EventBus.getInstance().dispatch(new SimpleCancelEvent()); EventBus.getInstance().dispatch(new SimpleCancelEvent());
assertTrue(canceledHits == 1); assertTrue(cancelledHits == 1);
} }
@Event(eventType = SimpleEvent.class, includeSubtypes = true, priority = 200) @Event(eventType = SimpleEvent.class, includeSubtypes = true, priority = 200)
@ -54,8 +51,8 @@ class EventBusTest implements EventListener {
@Event(eventType = SimpleCancelEvent.class, priority = 500) @Event(eventType = SimpleCancelEvent.class, priority = 500)
private void onSimpleCancelFirst() { private void onSimpleCancelFirst() {
++canceledHits; ++cancelledHits;
assertTrue(canceledHits == 1); assertTrue(cancelledHits == 1);
EventBus.getInstance().cancel(); EventBus.getInstance().cancel();
} }