@Test public void testCut() { engine.cut(); Assert.assertTrue("Cut() - Buffer isn't empty", buffer.getText().equals("")); Assert.assertTrue("Cut() - Clipboard isn't empty", clipboard.getText().equals("")); Assert.assertTrue( "Cut() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); buffer.setText("test"); engine.cut(); Assert.assertTrue("Cut() - Buffer content isn't the set text", buffer.getText().equals("test")); Assert.assertTrue("Cut() - Clipboard is empty", clipboard.getText().equals("")); Assert.assertTrue( "Cut() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); selection.setStart(0); selection.setLength(4); engine.cut(); Assert.assertTrue("Cut() - Buffer content isn't the set text", buffer.getText().equals("")); Assert.assertTrue("Cut() - Clipboard is empty", clipboard.getText().equals("test")); Assert.assertTrue( "Cut() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); engine.cut(); Assert.assertTrue("Cut() - Buffer content isn't the set text", buffer.getText().equals("")); Assert.assertTrue("Cut() - Clipboard is empty", clipboard.getText().equals("test")); Assert.assertTrue( "Cut() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); }
@Test public void testSelect() { engine.select(0, 0); Assert.assertTrue( "Type() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); engine.select(1, 1); Assert.assertTrue( "Type() - Selection isn't (1, 1)", selection.getStart() == 1 && selection.getLength() == 1); }
@Test public void testGetSelectionLength() { Assert.assertTrue( "GetSelectionLength() - Return start doesn't the selection start", engine.getSelectionLength() == 0); selection.setLength(1); Assert.assertTrue( "GetSelectionLength() - Return start doesn't the selection start", engine.getSelectionLength() == 1); }
@Test public void testEmpty() { AlgebraicField field = new PentagonField(); Selection selection = new Selection(); RealizedModel realized = new RealizedModel(field, new Projection.Default(field)); assertEquals(0, realized.size()); assertTrue(selection.isEmpty()); AlgebraicVector loc = field.basisVector(3, 2); Connector ball = new Connector(loc); realized.add(ball); assertEquals(1, realized.size()); assertTrue(selection.isEmpty()); Delete cmd = new Delete(selection, realized); try { cmd.perform(); } catch (Failure e) { fail("Delete perform failed"); } assertEquals(1, realized.size()); assertTrue(selection.isEmpty()); }
@Test public void testType() { engine.type('c'); Assert.assertTrue("Type() - Buffer isn't empty", buffer.getText().equals("c")); Assert.assertTrue( "Type() - Selection isn't (0, 0)", selection.getStart() == 1 && selection.getLength() == 0); selection.setStart(0); selection.setLength(1); engine.type('a'); Assert.assertTrue("Type() - Buffer content isn't the set text", buffer.getText().equals("a")); Assert.assertTrue( "Type() - Selection isn't (0, 0)", selection.getStart() == 1 && selection.getLength() == 0); }
@Test public void testPaste() { engine.paste(); Assert.assertTrue("Paste() - Buffer isn't empty", buffer.getText().equals("")); Assert.assertTrue("Paste() - Clipboard isn't empty", clipboard.getText().equals("")); Assert.assertTrue( "Paste() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); clipboard.setText("test"); engine.paste(); Assert.assertTrue( "Paste() - Buffer content isn't the set text", buffer.getText().equals("test")); Assert.assertTrue("Paste() - Clipboard is empty", clipboard.getText().equals("test")); Assert.assertTrue( "Paste() - Selection isn't (4, 0)", selection.getStart() == 4 && selection.getLength() == 0); selection.setStart(1); engine.paste(); Assert.assertTrue( "Paste() - Buffer content isn't the set text", buffer.getText().equals("ttestest")); Assert.assertTrue("Paste() - Clipboard is empty", clipboard.getText().equals("test")); Assert.assertTrue( "Paste() - Selection isn't (5, 0)", selection.getStart() == 5 && selection.getLength() == 0); selection.setStart(0); selection.setLength(8); engine.paste(); Assert.assertTrue( "Paste() - Buffer content isn't the set text", buffer.getText().equals("test")); Assert.assertTrue("Paste() - Clipboard is empty", clipboard.getText().equals("test")); Assert.assertTrue( "Paste() - Selection isn't (4, 0)", selection.getStart() == 4 && selection.getLength() == 0); }
@Test public void testDelete() { engine.delete(); Assert.assertTrue("Delete() - Buffer isn't empty", buffer.getText().equals("")); Assert.assertTrue( "Delete() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); buffer.setText("test"); engine.delete(); Assert.assertTrue( "Delete() - Buffer content isn't the set text", buffer.getText().equals("est")); Assert.assertTrue( "Delete() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); buffer.setText("test"); selection.setStart(4); engine.delete(); Assert.assertTrue( "Delete() - Buffer content isn't the set text", buffer.getText().equals("test")); Assert.assertTrue( "Delete() - Selection isn't (4, 0)", selection.getStart() == 4 && selection.getLength() == 0); selection.setStart(0); selection.setLength(3); engine.delete(); Assert.assertTrue("Delete() - Buffer content isn't the set text", buffer.getText().equals("t")); Assert.assertTrue( "Delete() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); engine.delete(); Assert.assertTrue("Delete() - Buffer content isn't the set text", buffer.getText().equals("")); Assert.assertTrue( "Delete() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0); }