package org.expeditee.gui; import java.awt.event.InputEvent; import java.util.Collection; import org.expeditee.items.Item; public class DisplayIOTest extends GuiTestCase { public final void testToggleTwinFrames() { showBlankFrame(); DisplayController.toggleTwinFrames(); assertTrue(DisplayController.isTwinFramesOn()); DisplayController.toggleTwinFrames(); assertFalse(DisplayController.isTwinFramesOn()); } public final void testMouse() throws Exception{ Frame testFrame = showBlankFrame(); drawLine(); //Draw a rectangle DisplayController.setCursorPosition(250, 250); Thread.sleep(100); DisplayController.clickMouse(InputEvent.BUTTON3_MASK); Thread.sleep(100); DisplayController.setCursorPosition(500, 500); Thread.sleep(100); DisplayController.clickMouse(InputEvent.BUTTON3_MASK); Thread.sleep(1000); //Check that the line is there Collection items = testFrame.getVisibleItems(); assertTrue(items.size() == 12); //Map itemCounts = getItemCount(items); } /** * @throws InterruptedException */ public static void drawLine() throws InterruptedException { //Draw a line DisplayController.setCursorPosition(100, 100); Thread.sleep(500); DisplayController.clickMouse(InputEvent.BUTTON2_MASK); Thread.sleep(100); DisplayController.setCursorPosition(200, 200); Thread.sleep(100); DisplayController.clickMouse(InputEvent.BUTTON2_MASK); Thread.sleep(100); } // private Map getItemCount(Collection items) { // Map itemCounts = new HashMap(); // for(Item i : items){ // String className = i.getClass().toString(); // if(itemCounts.containsKey(className)){ // itemCounts.put(className, itemCounts.get(className)+1); // }else{ // itemCounts.put(className, 1); // } // // } // return itemCounts; // } // public final void testReleaseMouse() { // fail("Not yet implemented"); // } // // public final void testClickMouse() { // fail("Not yet implemented"); // } }