Exemplo n.º 1
0
  @And("^this script has a Wait (\\d+) milliseconds brick$")
  public void script_has_wait_ms_brick(int millis) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);

    WaitBrick brick = new WaitBrick(millis);
    script.addBrick(brick);
  }
Exemplo n.º 2
0
  @And("^this script has a Wait (\\d+.?\\d*) seconds? brick$")
  public void script_has_wait_s_brick(int seconds) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);

    WaitBrick brick = new WaitBrick(seconds * 1000);
    script.addBrick(brick);
  }
Exemplo n.º 3
0
  @And("^this script has a BroadcastWait '(\\w+)' brick$")
  public void script_has_broadcast_wait_brick(String message) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);

    BroadcastWaitBrick brick = new BroadcastWaitBrick(message);
    script.addBrick(brick);
  }
Exemplo n.º 4
0
  @And("^this script has a Repeat end brick$")
  public void script_has_repeat_end_brick() {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);

    LoopBeginBrick loopBeginBrick = (LoopBeginBrick) Cucumber.get(Cucumber.KEY_LOOP_BEGIN_BRICK);
    Brick brick = new LoopEndBrick(loopBeginBrick);
    script.addBrick(brick);
  }
Exemplo n.º 5
0
  @And("^this script has a Repeat (\\d+) times brick$")
  public void script_has_repeat_times_brick(int iterations) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);

    Brick brick = new RepeatBrick(new Formula(iterations));
    Cucumber.put(Cucumber.KEY_LOOP_BEGIN_BRICK, brick);
    script.addBrick(brick);
  }
Exemplo n.º 6
0
  @And("^this script has a Print brick with$")
  public void script_has_a_print_brick(String text) {
    Sprite object = (Sprite) Cucumber.get(Cucumber.KEY_CURRENT_OBJECT);
    Script script = (Script) Cucumber.get(Cucumber.KEY_CURRENT_SCRIPT);

    if (outputStream == null) {
      outputStream = new ByteArrayOutputStream();
    }
    PrintBrick brick = new PrintBrick(object, text);
    brick.setOutputStream(outputStream);
    script.addBrick(brick);
  }
Exemplo n.º 7
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);
  }
Exemplo n.º 8
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);
  }