コード例 #1
0
  @Test
  public void testCopy() {
    engine.copy();
    Assert.assertTrue("Copy() - Buffer isn't empty", buffer.getText().equals(""));
    Assert.assertTrue("Copy() - Clipboard isn't empty", clipboard.getText().equals(""));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0);

    buffer.setText("test");
    engine.copy();
    Assert.assertTrue(
        "Copy() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue("Copy() - Clipboard isn't empty", clipboard.getText().equals(""));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0);

    selection.setStart(0);
    selection.setLength(4);
    engine.copy();
    Assert.assertTrue(
        "Copy() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue("Copy() - Clipboard is empty", clipboard.getText().equals("test"));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 4)", selection.getStart() == 0 && selection.getLength() == 4);

    selection.setLength(0);
    engine.copy();
    Assert.assertTrue(
        "Copy() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue(
        "Copy() - Clipboard is changed but copy when no text selected",
        clipboard.getText().equals("test"));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0);
  }
コード例 #2
0
  @Test
  public void testErase() {
    engine.erase();
    Assert.assertTrue("Erase() - Buffer isn't empty", buffer.getText().equals(""));
    Assert.assertTrue(
        "Erase() - Selection isn't (0, 0)",
        selection.getStart() == 0 && selection.getLength() == 0);

    buffer.setText("test");
    engine.erase();
    Assert.assertTrue(
        "Erase() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue(
        "Erase() - Selection isn't (0, 0)",
        selection.getStart() == 0 && selection.getLength() == 0);

    selection.setStart(4);
    engine.erase();
    Assert.assertTrue(
        "Erase() - Buffer content isn't the set text", buffer.getText().equals("tes"));
    Assert.assertTrue(
        "Erase() - Selection isn't (3, 0)",
        selection.getStart() == 3 && selection.getLength() == 0);

    selection.setStart(0);
    selection.setLength(3);
    engine.erase();
    Assert.assertTrue("Erase() - Buffer content isn't the set text", buffer.getText().equals(""));
    Assert.assertTrue(
        "Erase() - Selection isn't (0, 0)",
        selection.getStart() == 0 && selection.getLength() == 0);
  }
コード例 #3
0
  @Test
  public void testGetText() {
    Assert.assertTrue(
        "GetText() - Return text doesn't the buffer content", engine.getText().equals(""));

    buffer.setText("test");
    Assert.assertTrue(
        "GetText() - Return text doesn't the buffer content", engine.getText().equals("test"));
  }