/**
   * Types characters and check that output will not change for defined time (queue delay) and when
   * it actually change, check that it have value of input and that counters are printed right.
   */
  @Test
  public void testRequestDelay() {
    Integer[] delays = stringsToInteger.transform(MSG_DELAY_LIST);

    for (final int delay : delays) {
      setQueue(delay, false, false);

      // initiate time borders for the test
      final long start = currentTime();
      final long end = start + 10000;
      // create a buffer for whole text in input
      final StringBuffer typedText = new StringBuffer();

      // type at least 3 and at most 100 characters and don't exhause
      // border of 10 sec. for this tests
      while (typedText.length() <= 3 || (typedText.length() <= 100 && currentTime() < end)) {
        final String lastText = typedText.toString();

        // type char '1-9' like last decimal char of buffer's length
        typedText.append(Integer.toString(typedText.length() % 10));
        selenium.type(LOC_INPUT_TYPED_TEXT, typedText.toString());

        final long eventTime = currentTime();
        selenium.fireEvent(LOC_INPUT_TYPED_TEXT, Event.KEYUP);

        // check that text will not change for defined time (delay)
        Wait.dontFail()
            .interval(delay / 4)
            .timeout(delay)
            .until(
                new Condition() {
                  public boolean isTrue() {
                    final String actualText = selenium.getText(LOC_OUTPUT_TYPED_TEXT);
                    long currentTime = currentTime();
                    assertTrue(currentTime >= eventTime + delay || lastText.equals(actualText));
                    return currentTime >= eventTime + delay;
                  }
                });

        // wait for output actually changes to value of input
        waitForTextEquals(LOC_OUTPUT_TYPED_TEXT, typedText.toString());

        // check that all output counts are right
        String actualCount = Integer.toString(typedText.length());
        assertEquals(actualCount, selenium.getText(LOC_OUTPUT_EVENTS_COUNT));
        assertEquals(actualCount, selenium.getText(LOC_OUTPUT_REQUESTS_COUNT));
        assertEquals(actualCount, selenium.getText(LOC_OUTPUT_DOM_UPDATES_COUNT));
      }
    }
  }
  private void fastTyping() {
    StringBuffer text = new StringBuffer();

    for (int i = 1; i <= 75; i++) {
      text.append(MSG_CHAR_FAST_TYPING);

      selenium.type(LOC_INPUT_TYPED_TEXT, text.toString());
      selenium.fireEvent(LOC_INPUT_TYPED_TEXT, Event.KEYUP);
    }

    waitModelUpdate.waitForTimeout();
  }