Esempio n. 1
0
  @Test
  public void testTextArea() {
    JTextComponentFixture taFixture = new JTextComponentFixture(robot(), getTA("ta", "text"));
    taFixture.requireText("text");
    assertThat(taFixture.component().getName()).isEqualTo("ta");

    taFixture = new JTextComponentFixture(robot(), getTA("", "12"));
    taFixture.requireText("12");
    assertThat(taFixture.component().getName()).isEmpty();

    taFixture = new JTextComponentFixture(robot(), getTA(null, ""));
    taFixture.requireText("");
    assertThat(taFixture.component().getName()).isNull();

    taFixture = new JTextComponentFixture(robot(), getTA("", null));
    taFixture.requireText("");
    assertThat(taFixture.component().getName()).isEmpty();

    taFixture = new JTextComponentFixture(robot(), getTA(""));
    taFixture.requireText("");
    assertThat(taFixture.component().getName()).isEmpty();
  }
  @Test
  public void testTextArea() throws InterruptedException, InvocationTargetException {
    printlnMethodName();
    final JTextComponentFixture taFixture = new JTextComponentFixture(robot(), getTA("ta"));
    taFixture.requireNotEditable();
    taFixture.requireEmpty();
    assertThat(taFixture.component().getName()).isEqualTo("ta");

    Printer.println("not printed line ...");
    taFixture.requireEmpty();
    assertThat(out.toString()).isEqualTo("not printed line ..." + getLineSeparator());
    out.reset();

    activate(taFixture);

    Printer.println("printed line ...");
    taFixture.requireText("printed line ..." + getLineSeparator());
    assertThat(out.toString()).isEmpty();

    reset(taFixture);
    taFixture.requireEmpty();

    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            Printer.println("printed another line ...");
          }
        });
    taFixture.requireText("printed another line ..." + getLineSeparator());
    assertThat(out.toString()).isEmpty();

    Printer.println("printed line ...");
    taFixture.requireText(
        "printed another line ..." + getLineSeparator() + "printed line ..." + getLineSeparator());
    assertThat(out.toString()).isEmpty();
  }