diff --git a/jme3-core/src/main/java/com/jme3/app/Application.java b/jme3-core/src/main/java/com/jme3/app/Application.java old mode 100644 new mode 100755 index 9688a5d1edf..475193bfe52 --- a/jme3-core/src/main/java/com/jme3/app/Application.java +++ b/jme3-core/src/main/java/com/jme3/app/Application.java @@ -305,7 +305,7 @@ private void initCamera(){ * initializes joystick input if joysticks are enabled in the * AppSettings. */ - private void initInput(){ + protected void initInput(){ mouseInput = context.getMouseInput(); if (mouseInput != null) mouseInput.initialize(); diff --git a/jme3-core/src/main/java/com/jme3/app/TestApplication.java b/jme3-core/src/main/java/com/jme3/app/TestApplication.java new file mode 100755 index 00000000000..c7588651d58 --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/app/TestApplication.java @@ -0,0 +1,9 @@ +package com.jme3.app; + + +public class TestApplication extends SimpleApplication{ + @Override + public void simpleInitApp() { + + } +} diff --git a/jme3-core/src/main/java/com/jme3/input/JoyInput.java b/jme3-core/src/main/java/com/jme3/input/JoyInput.java old mode 100644 new mode 100755 diff --git a/jme3-core/src/main/java/com/jme3/input/TouchInput.java b/jme3-core/src/main/java/com/jme3/input/TouchInput.java old mode 100644 new mode 100755 diff --git a/jme3-core/src/main/resources/com/jme3/system/version.properties b/jme3-core/src/main/resources/com/jme3/system/version.properties index 90bccc1ffc3..6a18aebb503 100644 --- a/jme3-core/src/main/resources/com/jme3/system/version.properties +++ b/jme3-core/src/main/resources/com/jme3/system/version.properties @@ -1,5 +1,6 @@ # THIS IS AN AUTO-GENERATED FILE.. # DO NOT MODIFY! +<<<<<<< 9873a76327519d60380864617c1c74f58802b99c build.date=2016-03-21 git.revision=5389 git.branch=test-texture @@ -8,5 +9,15 @@ git.hash.short=b99b439 git.tag=v3.1-alpha1-231-gb99b439 name.full=jMonkeyEngine 3.1-test-texture-5389 version.full=3.1-test-texture-5389 +======= +build.date=2016-03-22 +git.revision=5475 +git.branch=master +git.hash=10947e8b5096f6d7e2bf0e327faa43b275adeb34 +git.hash.short=10947e8 +git.tag=null +name.full=jMonkeyEngine 3.1-5475 +version.full=3.1-5475 +>>>>>>> Init input Application tests version.number=3.1.0 version.tag=SNAPSHOT \ No newline at end of file diff --git a/jme3-core/src/test/java/com/jme3/app/ApplicationTest.java b/jme3-core/src/test/java/com/jme3/app/ApplicationTest.java new file mode 100755 index 00000000000..43abdb4705b --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/app/ApplicationTest.java @@ -0,0 +1,113 @@ +package com.jme3.app; + +import com.jme3.input.JoyInput; +import com.jme3.input.KeyInput; +import com.jme3.input.MouseInput; +import com.jme3.input.TouchInput; +import com.jme3.input.dummy.DummyKeyInput; +import com.jme3.input.dummy.DummyMouseInput; +import com.jme3.system.AppSettings; +import com.jme3.system.NullContext; +import com.jme3.texture.Texture; +import org.junit.Before; +import org.junit.Test; +import static org.mockito.Mockito.*; +import java.io.IOException; +import java.security.Key; + +import static org.junit.Assert.*; + + +public class ApplicationTest { + + Application app; + + @Before + public void setUp() { + app = new TestApplication(); + } + + @Test + public void testDestroyInput() throws Exception { + + } + + @Test + public void testInitInputWithJoyStick() throws Exception { + //setup settings + AppSettings settings = new AppSettings(true); + settings.setUseJoysticks(true); + app.setSettings(settings); + + //setup app + Application spyApp = spy(app); + assertNull(spyApp.getInputManager()); + + //setup context + NullContext spyContext = spy(new NullContext()); + MouseInput spyMouseInput = spy(new DummyMouseInput()); + KeyInput spyKeyInput = spy(new DummyKeyInput()); + TouchInput spyTouchInput = spy(new TestTouchInput()); + JoyInput spyJoyInput = spy(new TestJoyInput()); + doReturn(spyMouseInput).when(spyContext).getMouseInput(); + doReturn(spyKeyInput).when(spyContext).getKeyInput(); + doReturn(spyTouchInput).when(spyContext).getTouchInput(); + doReturn(spyJoyInput).when(spyContext).getJoyInput(); + spyApp.context = spyContext; + + spyApp.initInput(); + + verify(spyContext, times(1)).getMouseInput(); + verify(spyMouseInput, times(1)).initialize(); + verify(spyContext, times(1)).getKeyInput(); + verify(spyKeyInput, times(1)).initialize(); + verify(spyContext, times(1)).getTouchInput(); + verify(spyTouchInput, times(1)).initialize(); + verify(spyContext, times(1)).getJoyInput(); + verify(spyJoyInput, times(1)).initialize(); + + //verify(spyContext, times(1)).getJoyInput(); + + assertNotNull(spyApp.getInputManager()); + } + + @Test + public void testInitInputNoJoyStick() throws Exception { + //setup settings + AppSettings settings = new AppSettings(true); + settings.setUseJoysticks(false); + app.setSettings(settings); + + //setup app + Application spyApp = spy(app); + assertNull(spyApp.getInputManager()); + + //setup context + NullContext spyContext = spy(new NullContext()); + MouseInput spyMouseInput = spy(new DummyMouseInput()); + KeyInput spyKeyInput = spy(new DummyKeyInput()); + TouchInput spyTouchInput = spy(new TestTouchInput()); + JoyInput spyJoyInput = spy(new TestJoyInput()); + doReturn(spyMouseInput).when(spyContext).getMouseInput(); + doReturn(spyKeyInput).when(spyContext).getKeyInput(); + doReturn(spyTouchInput).when(spyContext).getTouchInput(); + doReturn(spyJoyInput).when(spyContext).getJoyInput(); + spyApp.context = spyContext; + + spyApp.initInput(); + + verify(spyContext, times(1)).getMouseInput(); + verify(spyMouseInput, times(1)).initialize(); + verify(spyContext, times(1)).getKeyInput(); + verify(spyKeyInput, times(1)).initialize(); + verify(spyContext, times(1)).getTouchInput(); + verify(spyTouchInput, times(1)).initialize(); + verify(spyContext, times(0)).getJoyInput(); + verify(spyJoyInput, times(0)).initialize(); + + //verify(spyContext, times(1)).getJoyInput(); + + assertNotNull(spyApp.getInputManager()); + } + +} \ No newline at end of file diff --git a/jme3-core/src/test/java/com/jme3/app/TestJoyInput.java b/jme3-core/src/test/java/com/jme3/app/TestJoyInput.java new file mode 100755 index 00000000000..f23ca21d16a --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/app/TestJoyInput.java @@ -0,0 +1,49 @@ +package com.jme3.app; + + +import com.jme3.input.InputManager; +import com.jme3.input.JoyInput; +import com.jme3.input.Joystick; +import com.jme3.input.RawInputListener; + +public class TestJoyInput implements JoyInput{ + @Override + public void setJoyRumble(int joyId, float amount) { + + } + + @Override + public Joystick[] loadJoysticks(InputManager inputManager) { + return new Joystick[0]; + } + + @Override + public void initialize() { + + } + + @Override + public void update() { + + } + + @Override + public void destroy() { + + } + + @Override + public boolean isInitialized() { + return false; + } + + @Override + public void setInputListener(RawInputListener listener) { + + } + + @Override + public long getInputTimeNanos() { + return 0; + } +} diff --git a/jme3-core/src/test/java/com/jme3/app/TestTouchInput.java b/jme3-core/src/test/java/com/jme3/app/TestTouchInput.java new file mode 100755 index 00000000000..1955b419892 --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/app/TestTouchInput.java @@ -0,0 +1,61 @@ +package com.jme3.app; + +import com.jme3.input.RawInputListener; +import com.jme3.input.TouchInput; + +public class TestTouchInput implements TouchInput{ + @Override + public void setSimulateMouse(boolean simulate) { + + } + + @Override + public boolean isSimulateMouse() { + return false; + } + + @Override + public void setSimulateKeyboard(boolean simulate) { + + } + + @Override + public boolean isSimulateKeyboard() { + return false; + } + + @Override + public void setOmitHistoricEvents(boolean dontSendHistory) { + + } + + @Override + public void initialize() { + + } + + @Override + public void update() { + + } + + @Override + public void destroy() { + + } + + @Override + public boolean isInitialized() { + return false; + } + + @Override + public void setInputListener(RawInputListener listener) { + + } + + @Override + public long getInputTimeNanos() { + return 0; + } +}