/** Helper method use to add some textField to the edge. */ public void addTextFieldToEdge() { graphNode1 = new GraphNode(); graphNode1.setContainer(graphEdge); graphNode1.setPosition(TestHelper.getWaypoint(25, 13)); textField1 = test.addTextField(graphNode1, text, AnchorType.LeftEnding); graphNode2 = new GraphNode(); graphNode2.setContainer(graphEdge); graphNode2.setPosition(TestHelper.getWaypoint(12, 13)); // the anchorage will be set to (12, 10). textField2 = test.addTextField(graphNode2, text, AnchorType.Line); graphNode3 = new GraphNode(); graphNode3.setContainer(graphEdge); graphNode3.setPosition(TestHelper.getWaypoint(8, 6)); // the anchorage will be set to (7, 7). textField3 = test.addTextField(graphNode3, text, AnchorType.Line); graphNode4 = new GraphNode(); graphNode4.setContainer(graphEdge); graphNode4.setPosition(TestHelper.getWaypoint(5, 7)); textField4 = test.addTextField(graphNode4, text, AnchorType.RightEnding); }
/** Accuracy Test of the <code>notifyChangeWayPoint()</code> method. */ public void testNotifyChangeWayPoint() { addTextFieldToEdge(); graphEdge.setWaypoint(2, TestHelper.getWaypoint(10, 20)); test.notifyChangeWayPoint(2, new Point(20, 10)); // get the number of way point to check the method. assertEquals("The number of way point should be 4.", 4, test.getWayPoints().size()); }
/** Accuracy Test of the <code>addTextField()</code> method. */ public void testAddTextField_RightEnding() { graphNode.setPosition(TestHelper.getWaypoint(5, 7)); TextField textField = test.addTextField(graphNode, text, AnchorType.RightEnding); // get the contained graphNode to check the constructor. assertEquals("The contained graphNode should be equals.", graphNode, textField.getGraphNode()); // get the anchorage point. Point anchorage = textField.getAnchorage(); // get the position of the anchorage point to check the method. assertEquals("The anchorage point should be at (30, 0).", 30, anchorage.x); assertEquals("The anchorage point should be at (0, 0).", 0, anchorage.y); }
/** Accuracy Test of the <code>addTextField()</code> method. */ public void testAddTextField_Line() { graphNode.setPosition(TestHelper.getWaypoint(12, 13)); graphNode.setContainer(graphEdge); TextField textField = test.addTextField(graphNode, text, AnchorType.Line); // get the contained graphNode to check the constructor. assertEquals("The contained graphNode should be equals.", graphNode, textField.getGraphNode()); // get the anchorage point. Point anchorage = textField.getAnchorage(); // get the position of the anchorage point to check the method. assertEquals("The anchorage point should be at (12, 10).", 12, anchorage.x); assertEquals("The anchorage point should be at (12, 10).", 10, anchorage.y); }
/** Accuracy Test of the <code>notifyRemoveWayPoint()</code> method. */ public void testNotifyAddWayPoint() { addTextFieldToEdge(); graphEdge.addWaypoint(2, TestHelper.getWaypoint(10, 30)); test.notifyAddWayPoint(2); // get the number of way point to check the method. assertEquals("The number of way point should be 5.", 5, test.getWayPoints().size()); // get the textField1 to check the method. assertTrue( "The textField1 should be there, can not be removed.", checkTextFieldForEqual(textField1, test.getTextField(graphNode1))); // get the textField4 to check the method. assertTrue( "The textField4 should be there, can not be removed.", checkTextFieldForEqual(textField4, test.getTextField(graphNode4))); }