예제 #1
0
  public void testBroadcastWait() {
    Sprite sprite = new Sprite("spriteOne");
    Script scriptWait = new StartScript(sprite);
    BroadcastWaitBrick broadcastWaitBrick = new BroadcastWaitBrick(sprite);
    String message = "waitTest";
    broadcastWaitBrick.setSelectedMessage(message);
    int testPosition = 100;
    SetXBrick setXBrick = new SetXBrick(sprite, testPosition);
    scriptWait.addBrick(broadcastWaitBrick);
    scriptWait.addBrick(setXBrick);
    sprite.addScript(scriptWait);

    BroadcastScript broadcastScript = new BroadcastScript(sprite);
    WaitBrick waitBrick = new WaitBrick(sprite, 500);
    int setTestPosition = 20;
    SetXBrick setXBrick2 = new SetXBrick(sprite, setTestPosition);
    broadcastScript.setBroadcastMessage(message);
    broadcastScript.addBrick(waitBrick);
    broadcastScript.addBrick(setXBrick2);
    sprite.addScript(broadcastScript);

    sprite.startStartScripts();

    try {
      Thread.sleep(1000);
    } catch (InterruptedException ignored) {
    }

    assertEquals("Broadcast and wait failed", testPosition, (int) sprite.costume.getXPosition());
  }
예제 #2
0
  public void testBroadcast() {
    Sprite sprite = new Sprite("testSprite");
    Script script = new StartScript(sprite);
    BroadcastBrick broadcastBrick = new BroadcastBrick(sprite);
    String message = "simpleTest";
    broadcastBrick.setSelectedMessage(message);
    script.addBrick(broadcastBrick);
    sprite.addScript(script);

    BroadcastScript broadcastScript = new BroadcastScript(sprite);
    int testPosition = 100;
    SetXBrick testBrick = new SetXBrick(sprite, testPosition);
    broadcastScript.setBroadcastMessage(message);
    broadcastScript.addBrick(testBrick);
    sprite.addScript(broadcastScript);

    sprite.startStartScripts();
    try {
      Thread.sleep(1000);
    } catch (InterruptedException ignored) {
    }

    assertEquals("Simple broadcast failed", testPosition, (int) sprite.costume.getXPosition());
  }