@Test public void testSingleRunOnlyUpdateGameViewError() throws Exception { GameScene theScene = mock(GameScene.class); GameView theGameView = mock(GameView.class); doThrow(new RuntimeException()).when(theGameView).renderGame(anyLong(), anyLong(), eq(theScene), any(RuntimeStatistics.class)); GameRuntime theRuntime = mock(GameRuntime.class); GameEventManager theManager = mock(GameEventManager.class); when(theRuntime.getEventManager()).thenReturn(theManager); GameLoop theLoop = new GameLoop(theScene, theGameView, theRuntime); theLoop.singleRunOnlyUpdateGameView(); Thread.sleep(10); theLoop.singleRunOnlyUpdateGameView(); verify(theManager).fire(any(SystemException.class)); }
public void singleRunOnlyUpdateGameView() { if (lastInvocation == 0) { lastInvocation = System.currentTimeMillis(); return; } long theCurrentTime = System.currentTimeMillis(); long theGameTime = theCurrentTime - statistics.getStartTime(); long theElapsedTime = theCurrentTime - lastInvocation; if (theElapsedTime > 0) { try { long theNumberOfTicks = statistics.incrementTicks(); statistics.beginGameLoop(); for (GameView theView : gameViews) { theView.renderGame(theGameTime, theElapsedTime, scene, statistics); } lastInvocation = theCurrentTime; } catch (Exception e) { runtime.getEventManager().fire(new SystemException(e)); } finally { statistics.endGameLoop(); } } }
GameLoop implements Runnable { public void singleRunOnlyUpdateGameView() { if (lastInvocation == 0) { lastInvocation = System.currentTimeMillis(); return; } long theCurrentTime = System.currentTimeMillis(); long theGameTime = theCurrentTime - statistics.getStartTime(); long theElapsedTime = theCurrentTime - lastInvocation; if (theElapsedTime > 0) { try { long theNumberOfTicks = statistics.incrementTicks(); statistics.beginGameLoop(); for (GameView theView : gameViews) { theView.renderGame(theGameTime, theElapsedTime, scene, statistics); } lastInvocation = theCurrentTime; } catch (Exception e) { runtime.getEventManager().fire(new SystemException(e)); } finally { statistics.endGameLoop(); } } } }
GameLoop implements Runnable { public void singleRunOnlyUpdateGameView() { if (lastInvocation == 0) { lastInvocation = System.currentTimeMillis(); return; } long theCurrentTime = System.currentTimeMillis(); long theGameTime = theCurrentTime - statistics.getStartTime(); long theElapsedTime = theCurrentTime - lastInvocation; if (theElapsedTime > 0) { try { long theNumberOfTicks = statistics.incrementTicks(); statistics.beginGameLoop(); for (GameView theView : gameViews) { theView.renderGame(theGameTime, theElapsedTime, scene, statistics); } lastInvocation = theCurrentTime; } catch (Exception e) { runtime.getEventManager().fire(new SystemException(e)); } finally { statistics.endGameLoop(); } } } GameLoop(GameScene aScene, GameView aHumanGameView, GameRuntime aRuntime); }
GameLoop implements Runnable { public void singleRunOnlyUpdateGameView() { if (lastInvocation == 0) { lastInvocation = System.currentTimeMillis(); return; } long theCurrentTime = System.currentTimeMillis(); long theGameTime = theCurrentTime - statistics.getStartTime(); long theElapsedTime = theCurrentTime - lastInvocation; if (theElapsedTime > 0) { try { long theNumberOfTicks = statistics.incrementTicks(); statistics.beginGameLoop(); for (GameView theView : gameViews) { theView.renderGame(theGameTime, theElapsedTime, scene, statistics); } lastInvocation = theCurrentTime; } catch (Exception e) { runtime.getEventManager().fire(new SystemException(e)); } finally { statistics.endGameLoop(); } } } GameLoop(GameScene aScene, GameView aHumanGameView, GameRuntime aRuntime); void addGameView(GameView aNewGameView); GameView getHumanGameView(); GameScene getScene(); @Override void run(); void singleRunOnlyUpdateGameView(); void singleRun(); void shutdown(); boolean isShutdown(); }
GameLoop implements Runnable { public void singleRunOnlyUpdateGameView() { if (lastInvocation == 0) { lastInvocation = System.currentTimeMillis(); return; } long theCurrentTime = System.currentTimeMillis(); long theGameTime = theCurrentTime - statistics.getStartTime(); long theElapsedTime = theCurrentTime - lastInvocation; if (theElapsedTime > 0) { try { long theNumberOfTicks = statistics.incrementTicks(); statistics.beginGameLoop(); for (GameView theView : gameViews) { theView.renderGame(theGameTime, theElapsedTime, scene, statistics); } lastInvocation = theCurrentTime; } catch (Exception e) { runtime.getEventManager().fire(new SystemException(e)); } finally { statistics.endGameLoop(); } } } GameLoop(GameScene aScene, GameView aHumanGameView, GameRuntime aRuntime); void addGameView(GameView aNewGameView); GameView getHumanGameView(); GameScene getScene(); @Override void run(); void singleRunOnlyUpdateGameView(); void singleRun(); void shutdown(); boolean isShutdown();  }