Beispiel #1
0
  @And("^this script has a set '(\\w+)' to '(\\w+)' brick$")
  public void script_has_set_var_to_var_brick(String a, String b) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);
    Project project = ProjectManager.getInstance().getCurrentProject();

    UserVariable varA = project.getUserVariables().getUserVariable(a, object);
    if (varA == null) {
      varA = project.getUserVariables().addSpriteUserVariableToSprite(object, a);
    }

    FormulaElement elemB = new FormulaElement(ElementType.USER_VARIABLE, b, null);

    Brick brick = new SetVariableBrick(new Formula(elemB), varA);
    script.addBrick(brick);
  }
Beispiel #2
0
  @And("^this script has a change '(\\w+)' by (\\d+.?\\d*) brick$")
  public void script_has_change_var_by_val_brick(String name, String value) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);
    Project project = ProjectManager.getInstance().getCurrentProject();

    UserVariable variable = project.getUserVariables().getUserVariable(name, object);
    if (variable == null) {
      variable = project.getUserVariables().addSpriteUserVariableToSprite(object, name);
    }

    FormulaElement elemValue = new FormulaElement(ElementType.NUMBER, value, null);

    Brick brick = new ChangeVariableBrick(new Formula(elemValue), variable);
    script.addBrick(brick);
  }
Beispiel #3
0
  public void reloadProject(Context context, StageDialog stageDialog) {
    if (reloadProject) {
      return;
    }
    this.stageDialog = stageDialog;

    project.getUserVariables().resetAllUserVariables();

    reloadProject = true;
  }
Beispiel #4
0
  @Then("^the variable '(\\w+)' should be equal (\\d+.?\\d*)$")
  public void var_should_equal_float(String name, float expected) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Project project = ProjectManager.getInstance().getCurrentProject();

    UserVariable variable = project.getUserVariables().getUserVariable(name, object);
    assertNotNull("The variable does not exist.", variable);

    float actual = variable.getValue().floatValue();
    assertThat("The variable is != the value.", actual, equalTo(expected));
  }
  private void createProject() {
    project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
    sprite = new Sprite("cat");
    Script script = new StartScript(sprite);
    ProjectManager.getInstance().setProject(project);
    ProjectManager.getInstance().setCurrentSprite(sprite);
    ProjectManager.getInstance().setCurrentScript(script);

    userVariablesContainer = project.getUserVariables();
    userVariablesContainer.addProjectUserVariable("p1");
    userVariablesContainer.addProjectUserVariable("p2");
    userVariablesContainer.addSpriteUserVariable("sprite_var1");
    userVariablesContainer.addSpriteUserVariable("sprite_var2");

    setVariableBrick = new SetVariableBrick(sprite, 0.0);
    script.addBrick(setVariableBrick);
    changeVariableBrick = new ChangeVariableBrick(sprite, 1.1);
    script.addBrick(changeVariableBrick);

    sprite.addScript(script);
    project.addSprite(sprite);
  }