1 | package org.expeditee.gui;
|
---|
2 |
|
---|
3 | import java.awt.event.InputEvent;
|
---|
4 | import java.util.Collection;
|
---|
5 |
|
---|
6 | import junit.framework.TestCase;
|
---|
7 |
|
---|
8 | import org.expeditee.items.Item;
|
---|
9 |
|
---|
10 | public class DisplayIOTest extends TestCase {
|
---|
11 | static Browser b;
|
---|
12 |
|
---|
13 | protected void setUp() throws Exception {
|
---|
14 | b = Browser.initializeForTesting();
|
---|
15 | super.setUp();
|
---|
16 | }
|
---|
17 |
|
---|
18 | public final void testToggleTwinFrames() {
|
---|
19 | DisplayIO.setCurrentFrame(FrameIO.LoadFrame("ExpediteeTest1"), true);
|
---|
20 | DisplayIO.ToggleTwinFrames();
|
---|
21 | assertTrue(DisplayIO.isTwinFramesOn());
|
---|
22 | DisplayIO.ToggleTwinFrames();
|
---|
23 | assertFalse(DisplayIO.isTwinFramesOn());
|
---|
24 | }
|
---|
25 |
|
---|
26 | public final void testMouse() throws Exception{
|
---|
27 | Frame testFrame = FrameIO.LoadFrame("ExpediteeTest1");
|
---|
28 | testFrame.clear(false);
|
---|
29 | DisplayIO.setCurrentFrame(testFrame, true);
|
---|
30 | drawLine();
|
---|
31 | //Draw a rectangle
|
---|
32 | DisplayIO.setCursorPosition(250, 250);
|
---|
33 | Thread.sleep(100);
|
---|
34 | DisplayIO.clickMouse(InputEvent.BUTTON3_MASK);
|
---|
35 | Thread.sleep(100);
|
---|
36 | DisplayIO.setCursorPosition(500, 500);
|
---|
37 | Thread.sleep(100);
|
---|
38 | DisplayIO.clickMouse(InputEvent.BUTTON3_MASK);
|
---|
39 | Thread.sleep(1000);
|
---|
40 | //Check that the line is there
|
---|
41 | Collection<Item> items = testFrame.getVisibleItems();
|
---|
42 | assertTrue(items.size() == 12);
|
---|
43 | //Map<String, Integer> itemCounts = getItemCount(items);
|
---|
44 |
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * @throws InterruptedException
|
---|
49 | */
|
---|
50 | public static void drawLine() throws InterruptedException {
|
---|
51 | //Draw a line
|
---|
52 | DisplayIO.setCursorPosition(100, 100);
|
---|
53 | Thread.sleep(1000);
|
---|
54 | DisplayIO.clickMouse(InputEvent.BUTTON2_MASK);
|
---|
55 | Thread.sleep(100);
|
---|
56 | DisplayIO.setCursorPosition(200, 200);
|
---|
57 | Thread.sleep(100);
|
---|
58 | DisplayIO.clickMouse(InputEvent.BUTTON2_MASK);
|
---|
59 | Thread.sleep(100);
|
---|
60 | }
|
---|
61 |
|
---|
62 | // private Map<String, Integer> getItemCount(Collection<Item> items) {
|
---|
63 | // Map<String, Integer> itemCounts = new HashMap<String,Integer>();
|
---|
64 | // for(Item i : items){
|
---|
65 | // String className = i.getClass().toString();
|
---|
66 | // if(itemCounts.containsKey(className)){
|
---|
67 | // itemCounts.put(className, itemCounts.get(className)+1);
|
---|
68 | // }else{
|
---|
69 | // itemCounts.put(className, 1);
|
---|
70 | // }
|
---|
71 | //
|
---|
72 | // }
|
---|
73 | // return itemCounts;
|
---|
74 | // }
|
---|
75 |
|
---|
76 | // public final void testReleaseMouse() {
|
---|
77 | // fail("Not yet implemented");
|
---|
78 | // }
|
---|
79 | //
|
---|
80 | // public final void testClickMouse() {
|
---|
81 | // fail("Not yet implemented");
|
---|
82 | // }
|
---|
83 |
|
---|
84 | }
|
---|