Exemplo n.º 1
0
  @Given("^'(\\w+)' has a Start script$")
  public void object_has_start_script(String object) {
    programWaitLockPermits -= 1;
    Project project = ProjectManager.getInstance().getCurrentProject();
    Sprite sprite = Util.findSprite(project, object);
    StartScript script = new StartScript(sprite);

    script.addBrick(
        new CallbackBrick(
            sprite,
            new CallbackBrick.BrickCallback() {
              @Override
              public void onCallback() {
                synchronized (programStartWaitLock) {
                  if (!programHasStarted) {
                    programHasStarted = true;
                    programStartWaitLock.notify();
                  }
                }
              }
            }));

    sprite.addScript(script);
    Cucumber.put(Cucumber.KEY_CURRENT_SCRIPT, script);
  }
Exemplo n.º 2
0
  @Override
  protected void setUp() {
    Project project = new Project(null, "testProject");
    firstSprite = new SingleSprite("firstSprite");
    StartScript startScript = new StartScript();
    ChangeSizeByNBrick changeBrick = new ChangeSizeByNBrick(10);
    firstSprite.addScript(startScript);
    startScript.addBrick(changeBrick);
    project.getDefaultScene().addSprite(firstSprite);
    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(firstSprite);

    dataContainer = ProjectManager.getInstance().getCurrentScene().getDataContainer();
    dataContainer.addProjectUserList(PROJECT_USER_LIST_NAME);
    dataContainer.addSpriteUserListToSprite(firstSprite, SPRITE_USER_LIST_NAME);
    dataContainer.addProjectUserList(PROJECT_USER_LIST_NAME_2);
  }
Exemplo n.º 3
0
  @Override
  protected void setUp() {
    this.project = new Project(null, "testProject");
    firstSprite = new Sprite("firstSprite");
    startScript = new StartScript();
    changeBrick = new ChangeSizeByNBrick(10);
    firstSprite.addScript(startScript);
    startScript.addBrick(changeBrick);
    project.addSprite(firstSprite);
    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(firstSprite);

    UserVariablesContainer userVariableContainer =
        ProjectManager.getInstance().getCurrentProject().getUserVariables();
    userVariableContainer
        .addProjectUserVariable(PROJECT_USER_VARIABLE)
        .setValue(USER_VARIABLE_1_VALUE_TYPE_DOUBLE);
    userVariableContainer
        .addSpriteUserVariableToSprite(firstSprite, SPRITE_USER_VARIABLE)
        .setValue(USER_VARIABLE_2_VALUE_TYPE_DOUBLE);
    userVariableContainer
        .addProjectUserVariable(PROJECT_USER_VARIABLE_2)
        .setValue(USER_VARIABLE_3_VALUE_TYPE_STRING);
  }
Exemplo n.º 4
0
  private void createProject() {
    ScreenValues.SCREEN_HEIGHT = SCREEN_HEIGHT;
    ScreenValues.SCREEN_WIDTH = SCREEN_WIDTH;

    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);

    // yellow Sprite
    Sprite yellowSprite = new Sprite("yellowSprite");
    StartScript yellowStartScript = new StartScript();
    LookData yellowLookData = new LookData();
    String yellowImageName = "yellow_image.bmp";

    yellowLookData.setLookName(yellowImageName);

    yellowSprite.getLookDataList().add(yellowLookData);

    yellowStartScript.addBrick(new PlaceAtBrick(-21, 21));

    yellowSprite.addScript(yellowStartScript);

    WhenScript yellowWhenScript = new WhenScript();
    SetGhostEffectBrick yellowSetGhostEffectBrick = new SetGhostEffectBrick(100d);
    yellowWhenScript.addBrick(yellowSetGhostEffectBrick);

    yellowSprite.addScript(yellowWhenScript);

    // blue Sprite
    Sprite blueSprite = new Sprite("blueSprite");
    StartScript blueStartScript = new StartScript();
    LookData blueLookData = new LookData();
    String blueImageName = "blue_image.bmp";

    blueLookData.setLookName(blueImageName);

    blueSprite.getLookDataList().add(blueLookData);

    blueStartScript.addBrick(new PlaceAtBrick(21, 21));

    blueSprite.addScript(blueStartScript);

    WhenScript blueWhenScript = new WhenScript();
    SetSizeToBrick blueSetSizeToBrick = new SetSizeToBrick(200d);
    blueWhenScript.addBrick(blueSetSizeToBrick);

    blueSprite.addScript(blueWhenScript);

    // green Sprite
    Sprite greenSprite = new Sprite("greenSprite");
    StartScript greenStartScript = new StartScript();
    LookData greenLookData = new LookData();
    String greenImageName = "green_image.bmp";

    greenLookData.setLookName(greenImageName);

    greenSprite.getLookDataList().add(greenLookData);

    greenStartScript.addBrick(new PlaceAtBrick(21, -21));

    greenSprite.addScript(greenStartScript);

    WhenScript greenWhenScript = new WhenScript();
    ComeToFrontBrick greenComeToFrontBrick = new ComeToFrontBrick();
    greenWhenScript.addBrick(greenComeToFrontBrick);

    greenSprite.addScript(greenWhenScript);

    // red Sprite
    Sprite redSprite = new Sprite("redSprite");
    StartScript redStartScript = new StartScript();
    LookData redLookData = new LookData();
    String redImageName = "red_image.bmp";

    redLookData.setLookName(redImageName);

    redSprite.getLookDataList().add(redLookData);

    redStartScript.addBrick(new PlaceAtBrick(-21, -21));

    redSprite.addScript(redStartScript);

    WhenScript redWhenScript = new WhenScript();
    ComeToFrontBrick redComeToFrontBrick = new ComeToFrontBrick();
    SetBrightnessBrick redSetBrightnessBrick = new SetBrightnessBrick(50d);
    TurnLeftBrick redTurnLeftBrick = new TurnLeftBrick(45d);
    redWhenScript.addBrick(redComeToFrontBrick);
    redWhenScript.addBrick(redSetBrightnessBrick);
    redWhenScript.addBrick(redTurnLeftBrick);

    redSprite.addScript(redWhenScript);

    // black Sprite
    Sprite blackSprite = new Sprite("blackSprite");
    StartScript blackStartScript = new StartScript();
    LookData blackLookData = new LookData();
    String blackImageName = "black_image.bmp";

    blackLookData.setLookName(blackImageName);

    blackSprite.getLookDataList().add(blackLookData);

    blackStartScript.addBrick(new PlaceAtBrick(-50, 50));

    blackSprite.addScript(blackStartScript);

    WhenScript blackWhenScript = new WhenScript();
    ComeToFrontBrick blackComeToFrontBrick = new ComeToFrontBrick();
    SetBrightnessBrick blackSetBrightnessBrick = new SetBrightnessBrick(150d);
    blackWhenScript.addBrick(blackComeToFrontBrick);
    blackWhenScript.addBrick(blackSetBrightnessBrick);

    blackSprite.addScript(blackWhenScript);

    project.addSprite(blackSprite);
    project.addSprite(yellowSprite);
    project.addSprite(redSprite);
    project.addSprite(greenSprite);
    project.addSprite(blueSprite);

    StorageHandler.getInstance().saveProject(project);

    File yellowImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            yellowImageName,
            org.catrobat.catroid.test.R.raw.yellow_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File greenImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            greenImageName,
            org.catrobat.catroid.test.R.raw.green_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File blueImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            blueImageName,
            org.catrobat.catroid.test.R.raw.blue_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File redImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            redImageName,
            org.catrobat.catroid.test.R.raw.red_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    File blackImageFile =
        UiTestUtils.saveFileToProject(
            project.getName(),
            blackImageName,
            org.catrobat.catroid.test.R.raw.black_image,
            getInstrumentation().getContext(),
            UiTestUtils.FileTypes.IMAGE);
    yellowLookData.setLookFilename(yellowImageFile.getName());
    greenLookData.setLookFilename(greenImageFile.getName());
    blueLookData.setLookFilename(blueImageFile.getName());
    redLookData.setLookFilename(redImageFile.getName());
    blackLookData.setLookFilename(blackImageFile.getName());

    StorageHandler.getInstance().saveProject(project);
    ProjectManager.getInstance().setProject(project);
  }