Teh-Hai Julian Zheng 8 years ago
parent
commit
173b2e2e3d

+ 0 - 1
src/tests/PraktikumHolonsTestAutoSaveController.java

@@ -14,7 +14,6 @@ import ui.controller.MultiPurposeController;
 import ui.controller.ObjectController;
 import ui.controller.StoreController;
 import ui.model.Model;
-import ui.model.IdCounter;
 
 public class PraktikumHolonsTestAutoSaveController {
 	protected Model model;

+ 44 - 0
src/tests/PraktikumHolonsTestCanvasController.java

@@ -14,6 +14,8 @@ import org.junit.Test;
 import org.junit.Before;
 import static org.junit.Assert.assertTrue;
 
+import java.awt.Point;
+
 public class PraktikumHolonsTestCanvasController {
 
 	protected PraktikumHolonsAdapter adapter;
@@ -155,4 +157,46 @@ public class PraktikumHolonsTestCanvasController {
 		assertTrue("Edge-M-R was not deleted", mp.searchEdge(13, 19) == null);
 		assertTrue("Edge-M-S was not deleted", mp.searchEdge(13, 20) == null);
 	}
+	
+	/**
+	 * Test copying Objects.
+	 */
+	@Test
+	public void testCutCopyPasteObjects() {
+		HolonObject a = new HolonObject("A");
+		HolonObject b = new HolonObject("B"); 
+		HolonObject c = new HolonObject("C"); 
+		
+		a = new HolonObject(a);
+		a.setPosition(1, 1);
+		b = new HolonObject(b);
+		b.setPosition(2, 2);
+		c = new HolonObject(c);
+		c.setPosition(3, 3);
+		CpsEdge edge1 = new CpsEdge(a, b);
+		CpsEdge edge2 = new CpsEdge(b, c);
+		CpsEdge edge3 = new CpsEdge(c, a);
+		controller.addNewObject(a);
+		controller.addEdgeOnCanvas(edge1);
+		controller.addEdgeOnCanvas(edge2);
+		controller.addEdgeOnCanvas(edge3);
+
+		
+		assertTrue("Clipboard not empty", model.getClipboradObjects().isEmpty());
+		model.getSelectedCpsObjects().add(a);
+		model.getSelectedCpsObjects().add(b);
+		model.getSelectedCpsObjects().add(c);
+		controller.copyObjects();
+		assertTrue("Clipboard empty", !model.getClipboradObjects().isEmpty());
+	
+		assertTrue("Clipboard empty", !model.getClipboradObjects().isEmpty());
+		
+		controller.pasteObjects(new Point(1, 1));
+		
+		controller.addNewObject(a);
+		controller.addNewObject(b);
+		controller.addNewObject(c);
+		controller.cutObjects();
+		
+	}
 }