forked from jMonkeyEngine/jmonkeyengine
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
244 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.jme3.app; | ||
|
||
|
||
public class TestApplication extends SimpleApplication{ | ||
@Override | ||
public void simpleInitApp() { | ||
|
||
} | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
jme3-core/src/test/java/com/jme3/app/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |