/**
   * This test tackles the issue, that if the waitbrick is at last position within a script, the
   * whole thread will not be set to "destroy" to early. So this test checks that the script is set
   * to "sleeping" until wait time has exceeded.
   */
  public void testWaitWhenBrickIsLast() {
    String customName1 = "custom1";
    LookData customData1 = createCostumeData(customName1);

    LookData customData2 = createCostumeData(customNameResult_);

    String spriteName = "sprite1";
    sprite_ = spriteManager.getSprite(spriteName, true);
    sprite_.addLookData(customData1);
    sprite_.addLookData(customData2);

    // simulate SetLookBrick
    sprite_.getLook().setLookData(customData1);

    // create BroadcastScript which executes one NextLookBrick
    String startScriptName = "broadcastScript";
    final StartScript startScript = new StartScript(sprite_, startScriptName);

    final Formula time = new Formula(1);
    WaitBrick waitBrick = new WaitBrick(spriteName, time, startScript);
    NextLookBrick nextLookBrick = new NextLookBrick(spriteName);
    startScript.addBrick(nextLookBrick);
    startScript.addBrick(waitBrick);

    final CatThread thread = new CatThread(spriteName + startScriptName, startScript);
    scheduler.schedule(thread);
    // execute nextLookBrick
    scheduler.execute();
    // execute waitBrick
    scheduler.execute();

    Timer timer =
        new Timer() {
          public void run() {
            System.out.println(thread.getStatus());
            assertTrue(thread.getStatus() == CatThread.SLEEPING);

            // tell the test system the test is now done
            finishTest();
          }
        };

    timer.schedule(900);
    // Set a delay period significantly longer than the
    // event is expected to take
    // delayTestFinish(1100);
  }
  public void testWait() {

    String costumeName1 = "costume1";
    LookData costumeData1 = createCostumeData(costumeName1);

    LookData costumeData2 = createCostumeData(customNameResult_);

    String spriteName = "sprite1";
    sprite_ = spriteManager.getSprite(spriteName, true);

    sprite_.addLookData(costumeData1);
    sprite_.addLookData(costumeData2);

    // simulate SetLookBrick
    sprite_.getLook().setLookData(costumeData1);

    // create BroadcastScript which executes one NextLookBrick
    String startScriptName = "broadcastScript";
    StartScript startScript = new StartScript(sprite_, startScriptName);

    Formula time = new Formula(0.4);
    WaitBrick waitBrick = new WaitBrick(spriteName, time, startScript);
    NextLookBrick nextLookBrick = new NextLookBrick(spriteName);
    startScript.addBrick(waitBrick);
    startScript.addBrick(nextLookBrick);

    CatThread thread = new CatThread(spriteName + startScriptName, startScript);
    scheduler.schedule(thread);

    // execute WaitBrick
    scheduler.execute();

    // should have no effect because there is no --> currentThread.getStatus() == CatThread.READY
    scheduler.execute();
    scheduler.execute();
    scheduler.execute();
    scheduler.execute();
    scheduler.execute();
    scheduler.execute();
    //

    Timer timer =
        new Timer() {
          public void run() {

            // execute NextLookBrick
            scheduler.execute();

            assertEquals(customNameResult_, sprite_.getLook().getLookData().getName());

            // tell the test system the test is now done
            finishTest();
          }
        };

    // Set a delay period significantly longer than the
    // event is expected to take
    delayTestFinish(700);

    // Schedule the event and return control to the test system
    timer.schedule(500);
  }