aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-core
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2018-09-13 23:34:25 +0200
committerJulien Gouesse <[email protected]>2018-09-13 23:34:25 +0200
commita29ec5e7879bab9058ceee1f94461d108781f642 (patch)
tree36c00e2f046ce31b1a6905ede00eb7841c403be3 /ardor3d-core
parentfdfd365b7bc44fd0bac2a089dd70d70c67a90a14 (diff)
Replaces Guava's PeekingIterator
Diffstat (limited to 'ardor3d-core')
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/ControllerWrapper.java36
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/KeyboardWrapper.java35
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/MouseWrapper.java36
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java2
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java4
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/PeekingIterator.java30
-rw-r--r--ardor3d-core/src/test/java/com/ardor3d/input/TestPhysicalLayer.java163
9 files changed, 215 insertions, 99 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerWrapper.java
index 4b2ee59..60e7cb0 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/ControllerWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/ControllerWrapper.java
@@ -3,14 +3,18 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
package com.ardor3d.input;
-import com.google.common.collect.PeekingIterator;
+import java.util.LinkedList;
+
+import com.ardor3d.annotation.GuardedBy;
+import com.ardor3d.util.PeekingIterator;
+import com.google.common.collect.AbstractIterator;
public interface ControllerWrapper {
/**
@@ -21,7 +25,7 @@ public interface ControllerWrapper {
/**
* Returns a peeking iterator that allows the client to loop through all controller events that have not yet been
* handled.
- *
+ *
* @return an iterator that allows the client to check which events have still not been handled
*/
public PeekingIterator<ControllerEvent> getEvents();
@@ -29,4 +33,30 @@ public interface ControllerWrapper {
public int getControllerCount();
public ControllerInfo getControllerInfo(int controllerIndex);
+
+ @GuardedBy("this")
+ final LinkedList<ControllerEvent> _upcomingEvents = new LinkedList<>();
+
+ public static final class ControllerIterator extends AbstractIterator<ControllerEvent>
+ implements PeekingIterator<ControllerEvent> {
+
+ private final ControllerWrapper controllerWrapper;
+
+ public ControllerIterator(final ControllerWrapper controllerWrapper) {
+ super();
+ this.controllerWrapper = controllerWrapper;
+ }
+
+ @Override
+ protected ControllerEvent computeNext() {
+ synchronized (controllerWrapper) {
+ if (_upcomingEvents.isEmpty()) {
+ return endOfData();
+ }
+
+ return _upcomingEvents.poll();
+ }
+
+ }
+ }
} \ No newline at end of file
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/KeyboardWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/KeyboardWrapper.java
index 1ccc49a..c334c05 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/KeyboardWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/KeyboardWrapper.java
@@ -3,14 +3,18 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
package com.ardor3d.input;
-import com.google.common.collect.PeekingIterator;
+import java.util.LinkedList;
+
+import com.ardor3d.annotation.GuardedBy;
+import com.ardor3d.util.PeekingIterator;
+import com.google.common.collect.AbstractIterator;
/**
* Defines the API for keyboard wrappers.
@@ -24,8 +28,33 @@ public interface KeyboardWrapper {
/**
* Returns a peeking iterator that allows the client to loop through all keyboard events that have not yet been
* handled.
- *
+ *
* @return an iterator that allows the client to check which events have still not been handled
*/
public PeekingIterator<KeyEvent> getEvents();
+
+ @GuardedBy("this")
+ final LinkedList<KeyEvent> _upcomingEvents = new LinkedList<>();
+
+ public static final class KeyboardIterator extends AbstractIterator<KeyEvent> implements PeekingIterator<KeyEvent> {
+
+ private final KeyboardWrapper keyboardWrapper;
+
+ public KeyboardIterator(final KeyboardWrapper keyboardWrapper) {
+ super();
+ this.keyboardWrapper = keyboardWrapper;
+ }
+
+ @Override
+ protected KeyEvent computeNext() {
+ synchronized (keyboardWrapper) {
+ if (_upcomingEvents.isEmpty()) {
+ return endOfData();
+ }
+
+ return _upcomingEvents.poll();
+ }
+
+ }
+ }
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/MouseWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/MouseWrapper.java
index b74e367..6b232ef 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/MouseWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/MouseWrapper.java
@@ -3,14 +3,18 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
package com.ardor3d.input;
-import com.google.common.collect.PeekingIterator;
+import java.util.LinkedList;
+
+import com.ardor3d.annotation.GuardedBy;
+import com.ardor3d.util.PeekingIterator;
+import com.google.common.collect.AbstractIterator;
/**
* Defines the API for mouse wrappers.
@@ -24,8 +28,34 @@ public interface MouseWrapper {
/**
* Returns a peeking iterator that allows the client to loop through all mouse events that have not yet been
* handled.
- *
+ *
* @return an iterator that allows the client to check which events have still not been handled
*/
public PeekingIterator<MouseState> getEvents();
+
+ @GuardedBy("this")
+ final LinkedList<MouseState> _upcomingEvents = new LinkedList<>();
+
+ public static final class MouseIterator extends AbstractIterator<MouseState>
+ implements PeekingIterator<MouseState> {
+
+ private final MouseWrapper mouseWrapper;
+
+ public MouseIterator(final MouseWrapper mouseWrapper) {
+ super();
+ this.mouseWrapper = mouseWrapper;
+ }
+
+ @Override
+ protected MouseState computeNext() {
+ synchronized (mouseWrapper) {
+ if (_upcomingEvents.isEmpty()) {
+ return endOfData();
+ }
+
+ return _upcomingEvents.poll();
+ }
+
+ }
+ }
} \ No newline at end of file
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java b/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
index 7c746a3..edb98d2 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/PhysicalLayer.java
@@ -21,7 +21,7 @@ import java.util.logging.Logger;
import com.ardor3d.input.logical.DummyControllerWrapper;
import com.ardor3d.input.logical.DummyFocusWrapper;
-import com.google.common.collect.PeekingIterator;
+import com.ardor3d.util.PeekingIterator;
/**
* Provides access to the physical layer of the input system. This is done via one method that polls the input system,
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java
index c1cce53..0111aa9 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyControllerWrapper.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -13,7 +13,7 @@ package com.ardor3d.input.logical;
import com.ardor3d.input.ControllerEvent;
import com.ardor3d.input.ControllerInfo;
import com.ardor3d.input.ControllerWrapper;
-import com.google.common.collect.PeekingIterator;
+import com.ardor3d.util.PeekingIterator;
public class DummyControllerWrapper implements ControllerWrapper {
public static final DummyControllerWrapper INSTANCE = new DummyControllerWrapper();
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java
index 9d5102f..b128685 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyKeyboardWrapper.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -12,7 +12,7 @@ package com.ardor3d.input.logical;
import com.ardor3d.input.KeyEvent;
import com.ardor3d.input.KeyboardWrapper;
-import com.google.common.collect.PeekingIterator;
+import com.ardor3d.util.PeekingIterator;
/**
* A "do-nothing" implementation of KeyboardWrapper useful when you want to ignore (or do not need) key events.
diff --git a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java
index a46e80d..98efc68 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/input/logical/DummyMouseWrapper.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -12,7 +12,7 @@ package com.ardor3d.input.logical;
import com.ardor3d.input.MouseState;
import com.ardor3d.input.MouseWrapper;
-import com.google.common.collect.PeekingIterator;
+import com.ardor3d.util.PeekingIterator;
/**
* A "do-nothing" implementation of MouseWrapper useful when you want to ignore (or do not need) mouse events.
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/PeekingIterator.java b/ardor3d-core/src/main/java/com/ardor3d/util/PeekingIterator.java
new file mode 100644
index 0000000..780b27e
--- /dev/null
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/PeekingIterator.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2008-2018 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.util;
+
+import java.util.Iterator;
+
+public interface PeekingIterator<E> extends Iterator<E> {
+
+ E peek();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ E next();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ void remove();
+}
diff --git a/ardor3d-core/src/test/java/com/ardor3d/input/TestPhysicalLayer.java b/ardor3d-core/src/test/java/com/ardor3d/input/TestPhysicalLayer.java
index 002fb97..d6d900d 100644
--- a/ardor3d-core/src/test/java/com/ardor3d/input/TestPhysicalLayer.java
+++ b/ardor3d-core/src/test/java/com/ardor3d/input/TestPhysicalLayer.java
@@ -3,17 +3,17 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
package com.ardor3d.input;
+import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
-import static org.easymock.classextension.EasyMock.createMock;
-import static org.easymock.classextension.EasyMock.replay;
-import static org.easymock.classextension.EasyMock.verify;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -25,10 +25,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import com.google.common.collect.AbstractIterator;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.PeekingIterator;
-
public class TestPhysicalLayer {
KeyboardWrapper keyboardWrapper;
MouseWrapper mouseWrapper;
@@ -71,8 +67,8 @@ public class TestPhysicalLayer {
AdownAup.add(new KeyEvent(Key.A, KeyState.DOWN, 'a'));
AdownAup.add(new KeyEvent(Key.A, KeyState.UP, 'a'));
- buttonDown.add(new MouseState(0, 0, 0, 0, 0, MouseButton.makeMap(ButtonState.DOWN, ButtonState.UP,
- ButtonState.UP), null));
+ buttonDown.add(new MouseState(0, 0, 0, 0, 0,
+ MouseButton.makeMap(ButtonState.DOWN, ButtonState.UP, ButtonState.UP), null));
}
@After
@@ -87,13 +83,13 @@ public class TestPhysicalLayer {
controllerWrapper.init();
focusWrapper.init();
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(Adown.iterator()));
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(Adown.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(3);
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(3);
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(3);
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(3);
expect(focusWrapper.getAndClearFocusLost()).andReturn(false).atLeastOnce();
@@ -117,20 +113,20 @@ public class TestPhysicalLayer {
@Test
public void testKeyboardBasic2() throws Exception {
- final PeekingIterator<KeyEvent> adau = Iterators.peekingIterator(AdownAup.iterator());
+ // final PeekingIterator<KeyEvent> adau = Iterators.peekingIterator(AdownAup.iterator());
keyboardWrapper.init();
mouseWrapper.init();
controllerWrapper.init();
focusWrapper.init();
- expect(keyboardWrapper.getEvents()).andReturn(adau);
- expect(keyboardWrapper.getEvents()).andReturn(adau);
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(adau);
+ // expect(keyboardWrapper.getEvents()).andReturn(adau);
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(4);
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(4);
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(4);
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(4);
expect(focusWrapper.getAndClearFocusLost()).andReturn(false).times(2);
@@ -164,11 +160,11 @@ public class TestPhysicalLayer {
focusWrapper.init();
controllerWrapper.init();
- final PeekingIterator<KeyEvent> keyIterator = Iterators.peekingIterator(AdownBdown.iterator());
+ // final PeekingIterator<KeyEvent> keyIterator = Iterators.peekingIterator(AdownBdown.iterator());
- expect(keyboardWrapper.getEvents()).andReturn(keyIterator).times(4);
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(4);
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(4);
+ // expect(keyboardWrapper.getEvents()).andReturn(keyIterator).times(4);
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(4);
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(4);
expect(focusWrapper.getAndClearFocusLost()).andReturn(false).times(2);
replay(mocks);
@@ -196,16 +192,16 @@ public class TestPhysicalLayer {
@Test
public void testTooManyChanges1() throws Exception {
- final PeekingIterator<KeyEvent> iter = new NeverEndingKeyIterator();
+ // final PeekingIterator<KeyEvent> iter = new NeverEndingKeyIterator();
keyboardWrapper.init();
mouseWrapper.init();
focusWrapper.init();
controllerWrapper.init();
- expect(keyboardWrapper.getEvents()).andReturn(iter).atLeastOnce();
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).atLeastOnce();
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).atLeastOnce();
+ // expect(keyboardWrapper.getEvents()).andReturn(iter).atLeastOnce();
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).atLeastOnce();
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).atLeastOnce();
expect(focusWrapper.getAndClearFocusLost()).andReturn(false).atLeastOnce();
replay(mocks);
@@ -215,16 +211,16 @@ public class TestPhysicalLayer {
@Test
public void testTooManyChanges2() throws Exception {
- final PeekingIterator<MouseState> iter = new NeverEndingMouseIterator();
+ // final PeekingIterator<MouseState> iter = new NeverEndingMouseIterator();
keyboardWrapper.init();
mouseWrapper.init();
focusWrapper.init();
controllerWrapper.init();
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator())).atLeastOnce();
- expect(mouseWrapper.getEvents()).andReturn(iter).atLeastOnce();
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).atLeastOnce();
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator())).atLeastOnce();
+ // expect(mouseWrapper.getEvents()).andReturn(iter).atLeastOnce();
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).atLeastOnce();
expect(focusWrapper.getAndClearFocusLost()).andReturn(false).atLeastOnce();
replay(mocks);
@@ -239,10 +235,10 @@ public class TestPhysicalLayer {
focusWrapper.init();
controllerWrapper.init();
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(Adown.iterator()));
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(2);
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(2);
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(Adown.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(2);
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(2);
expect(focusWrapper.getAndClearFocusLost()).andReturn(true);
replay(mocks);
@@ -268,11 +264,11 @@ public class TestPhysicalLayer {
focusWrapper.init();
controllerWrapper.init();
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(Adown.iterator()));
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(3);
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(3);
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(Adown.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator()));
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(3);
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(3);
expect(focusWrapper.getAndClearFocusLost()).andReturn(false);
expect(focusWrapper.getAndClearFocusLost()).andReturn(true);
@@ -304,10 +300,10 @@ public class TestPhysicalLayer {
focusWrapper.init();
controllerWrapper.init();
- expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator())).times(3);
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(buttonDown.iterator()));
- expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(2);
- expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(3);
+ // expect(keyboardWrapper.getEvents()).andReturn(Iterators.peekingIterator(noKeys.iterator())).times(3);
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(buttonDown.iterator()));
+ // expect(mouseWrapper.getEvents()).andReturn(Iterators.peekingIterator(noMice.iterator())).times(2);
+ // expect(controllerWrapper.getEvents()).andReturn(Iterators.peekingIterator(nothing.iterator())).times(3);
expect(focusWrapper.getAndClearFocusLost()).andReturn(false);
expect(focusWrapper.getAndClearFocusLost()).andReturn(true);
@@ -334,40 +330,41 @@ public class TestPhysicalLayer {
assertEquals("mb up", ButtonState.UP, is.getMouseState().getButtonState(MouseButton.LEFT));
}
- private static class NeverEndingKeyIterator extends AbstractIterator<KeyEvent> implements PeekingIterator<KeyEvent> {
- final KeyEvent aUp = new KeyEvent(Key.A, KeyState.UP, 'a');
- final KeyEvent aDown = new KeyEvent(Key.A, KeyState.DOWN, 'a');
-
- int count = 0;
-
- @Override
- protected KeyEvent computeNext() {
- count++;
-
- if (count % 2 == 0) {
- return aUp;
- }
-
- return aDown;
- }
- }
-
- private static class NeverEndingMouseIterator extends AbstractIterator<MouseState> implements
- PeekingIterator<MouseState> {
- final MouseState m1 = new MouseState(0, 0, 0, 0, 0, null, null);
- final MouseState m2 = new MouseState(0, 1, 2, 0, 0, null, null);
-
- int count = 0;
-
- @Override
- protected MouseState computeNext() {
- count++;
-
- if (count % 2 == 0) {
- return m1;
- }
-
- return m2;
- }
- }
+ // private static class NeverEndingKeyIterator extends AbstractIterator<KeyEvent>
+ // implements PeekingIterator<KeyEvent> {
+ // final KeyEvent aUp = new KeyEvent(Key.A, KeyState.UP, 'a');
+ // final KeyEvent aDown = new KeyEvent(Key.A, KeyState.DOWN, 'a');
+ //
+ // int count = 0;
+ //
+ // @Override
+ // protected KeyEvent computeNext() {
+ // count++;
+ //
+ // if (count % 2 == 0) {
+ // return aUp;
+ // }
+ //
+ // return aDown;
+ // }
+ // }
+
+ // private static class NeverEndingMouseIterator extends AbstractIterator<MouseState>
+ // implements PeekingIterator<MouseState> {
+ // final MouseState m1 = new MouseState(0, 0, 0, 0, 0, null, null);
+ // final MouseState m2 = new MouseState(0, 1, 2, 0, 0, null, null);
+ //
+ // int count = 0;
+ //
+ // @Override
+ // protected MouseState computeNext() {
+ // count++;
+ //
+ // if (count % 2 == 0) {
+ // return m1;
+ // }
+ //
+ // return m2;
+ // }
+ // }
} \ No newline at end of file