public void testBroadcastWait() { Sprite sprite = new Sprite("spriteOne"); Script scriptWait = new StartScript(sprite); String message = "waitTest"; BroadcastWaitBrick broadcastWaitBrick = new BroadcastWaitBrick(sprite, message); int testPosition = 100; SetXBrick setXBrick = new SetXBrick(sprite, testPosition); scriptWait.addBrick(broadcastWaitBrick); scriptWait.addBrick(setXBrick); sprite.addScript(scriptWait); BroadcastScript broadcastScript = new BroadcastScript(sprite, message); WaitBrick waitBrick = new WaitBrick(sprite, 500); int setTestPosition = 20; SetXBrick setXBrick2 = new SetXBrick(sprite, setTestPosition); broadcastScript.addBrick(waitBrick); broadcastScript.addBrick(setXBrick2); sprite.addScript(broadcastScript); Project project = new Project(getContext(), "testProject"); project.addSprite(sprite); ProjectManager.getInstance().setProject(project); sprite.createStartScriptActionSequence(); while (!sprite.look.getAllActionsAreFinished()) { sprite.look.act(1.0f); } assertEquals( "Broadcast and wait failed", testPosition, (int) sprite.look.getXInUserInterfaceDimensionUnit()); }
@Override public void render() { Gdx.gl.glClearColor(1f, 1f, 1f, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if (reloadProject) { int spriteSize = sprites.size(); for (int i = 0; i < spriteSize; i++) { sprites.get(i).pause(); } stage.clear(); SoundManager.getInstance().clear(); Sprite sprite; if (spriteSize > 0) { sprites.get(0).look.setLookData(createWhiteBackgroundLookData()); } for (int i = 0; i < spriteSize; i++) { sprite = sprites.get(i); sprite.resetSprite(); sprite.look.createBrightnessContrastShader(); stage.addActor(sprite.look); sprite.pause(); } stage.addActor(passepartout); paused = true; firstStart = true; reloadProject = false; synchronized (stageDialog) { stageDialog.notify(); } } batch.setProjectionMatrix(camera.combined); if (firstStart) { int spriteSize = sprites.size(); if (spriteSize > 0) { sprites.get(0).look.setLookData(createWhiteBackgroundLookData()); } Sprite sprite; for (int i = 0; i < spriteSize; i++) { sprite = sprites.get(i); sprite.createStartScriptActionSequence(); if (!sprite.getLookDataList().isEmpty()) { sprite.look.setLookData(sprite.getLookDataList().get(0)); } } firstStart = false; } if (!paused) { float deltaTime = Gdx.graphics.getDeltaTime(); /* * Necessary for UiTests, when EMMA - code coverage is enabled. * * Without setting DYNAMIC_SAMPLING_RATE_FOR_ACTIONS to false(via reflection), before * the UiTest enters the stage, random segmentation faults(triggered by EMMA) will occur. * * Can be removed, when EMMA is replaced by an other code coverage tool, or when a * future EMMA - update will fix the bugs. */ if (DYNAMIC_SAMPLING_RATE_FOR_ACTIONS == false) { stage.act(deltaTime); } else { float optimizedDeltaTime = deltaTime / deltaActionTimeDivisor; long timeBeforeActionsUpdate = SystemClock.uptimeMillis(); while (deltaTime > 0f) { stage.act(optimizedDeltaTime); deltaTime -= optimizedDeltaTime; } long executionTimeOfActionsUpdate = SystemClock.uptimeMillis() - timeBeforeActionsUpdate; if (executionTimeOfActionsUpdate <= ACTIONS_COMPUTATION_TIME_MAXIMUM) { deltaActionTimeDivisor += 1f; deltaActionTimeDivisor = Math.min(DELTA_ACTIONS_DIVIDER_MAXIMUM, deltaActionTimeDivisor); } else { deltaActionTimeDivisor -= 1f; deltaActionTimeDivisor = Math.max(1f, deltaActionTimeDivisor); } } } if (!finished) { stage.draw(); } if (makeAutomaticScreenshot) { if (skipFirstFrameForAutomaticScreenshot) { skipFirstFrameForAutomaticScreenshot = false; } else { thumbnail = ScreenUtils.getFrameBufferPixels( screenshotX, screenshotY, screenshotWidth, screenshotHeight, true); makeAutomaticScreenshot = false; } } if (makeScreenshot) { screenshot = ScreenUtils.getFrameBufferPixels( screenshotX, screenshotY, screenshotWidth, screenshotHeight, true); makeScreenshot = false; } if (axesOn && !finished) { drawAxes(); } if (DEBUG) { fpsLogger.log(); } if (makeTestPixels) { testPixels = ScreenUtils.getFrameBufferPixels(testX, testY, testWidth, testHeight, false); makeTestPixels = false; } }