source: trunk/tests/org/expeditee/gui/DisplayIOTest.java@ 1102

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File size: 2.0 KB
Line 
1package org.expeditee.gui;
2
3import java.awt.event.InputEvent;
4import java.util.Collection;
5
6import org.expeditee.items.Item;
7
8public class DisplayIOTest extends GuiTestCase {
9
10 public final void testToggleTwinFrames() {
11 showBlankFrame();
12
13 DisplayController.toggleTwinFrames();
14 assertTrue(DisplayController.isTwinFramesOn());
15 DisplayController.toggleTwinFrames();
16 assertFalse(DisplayController.isTwinFramesOn());
17 }
18
19 public final void testMouse() throws Exception{
20 Frame testFrame = showBlankFrame();
21 drawLine();
22
23 //Draw a rectangle
24 DisplayController.setCursorPosition(250, 250);
25 Thread.sleep(100);
26 DisplayController.clickMouse(InputEvent.BUTTON3_MASK);
27 Thread.sleep(100);
28 DisplayController.setCursorPosition(500, 500);
29 Thread.sleep(100);
30 DisplayController.clickMouse(InputEvent.BUTTON3_MASK);
31 Thread.sleep(1000);
32 //Check that the line is there
33 Collection<Item> items = testFrame.getVisibleItems();
34 assertTrue(items.size() == 12);
35 //Map<String, Integer> itemCounts = getItemCount(items);
36
37 }
38
39 /**
40 * @throws InterruptedException
41 */
42 public static void drawLine() throws InterruptedException {
43 //Draw a line
44 DisplayController.setCursorPosition(100, 100);
45 Thread.sleep(500);
46 DisplayController.clickMouse(InputEvent.BUTTON2_MASK);
47 Thread.sleep(100);
48 DisplayController.setCursorPosition(200, 200);
49 Thread.sleep(100);
50 DisplayController.clickMouse(InputEvent.BUTTON2_MASK);
51 Thread.sleep(100);
52 }
53
54// private Map<String, Integer> getItemCount(Collection<Item> items) {
55// Map<String, Integer> itemCounts = new HashMap<String,Integer>();
56// for(Item i : items){
57// String className = i.getClass().toString();
58// if(itemCounts.containsKey(className)){
59// itemCounts.put(className, itemCounts.get(className)+1);
60// }else{
61// itemCounts.put(className, 1);
62// }
63//
64// }
65// return itemCounts;
66// }
67
68 // public final void testReleaseMouse() {
69 // fail("Not yet implemented");
70 // }
71 //
72 // public final void testClickMouse() {
73 // fail("Not yet implemented");
74 // }
75
76}
Note: See TracBrowser for help on using the repository browser.