source: trunk/tests/org/expeditee/gui/FrameMouseActionsTest.java@ 361

Last change on this file since 361 was 361, checked in by ra33, 16 years ago
File size: 2.0 KB
Line 
1package org.expeditee.gui;
2
3import java.awt.event.InputEvent;
4
5import org.expeditee.actions.Navigation;
6import org.expeditee.items.Text;
7
8public class FrameMouseActionsTest extends GuiTestCase {
9
10 public final void testLeftHighlight() throws Exception {
11 Frame testFrame = showBlankFrame();
12
13 // LeftRange the title text for unlinked title
14 Text title = testFrame.getTitleItem();
15 title.setLink(null);
16 testLeftRanging(title);
17
18 String newFrameName = DisplayIO.getCurrentFrame().getName();
19 Navigation.Back();
20
21 // Make sure the newly created frame is not saved when the user goes
22 // back
23 assertNull(FrameIO.LoadFrame(newFrameName));
24
25 // LeftRange the linked title text
26 testLeftRanging(title);
27
28 Thread.sleep(500);
29
30 DisplayIOTest.drawLine();
31
32 newFrameName = DisplayIO.getCurrentFrame().getName();
33 Navigation.Back();
34
35 Thread.sleep(500);
36 // Make sure the newly created frame is saved when the user goes back
37 assertNotNull(FrameIO.LoadFrame(newFrameName));
38 }
39
40 /**
41 * @param title
42 * @return
43 * @throws InterruptedException
44 */
45 private void testLeftRanging(Text title) throws InterruptedException {
46 int y = title.getY() - 2;
47 DisplayIO.setCursorPosition(title.getX(), y);
48 Thread.sleep(500);
49 DisplayIO.pressMouse(InputEvent.BUTTON1_MASK);
50 Thread.sleep(100);
51 DisplayIO.setCursorPosition(title.getX() + title.getBoundsWidth() / 2,
52 y);
53 Thread.sleep(500);
54 DisplayIO.releaseMouse(InputEvent.BUTTON1_MASK);
55 Thread.sleep(100);
56
57 // Make sure TDFC was NOT performed
58 assertNull(title.getLink());
59
60 // Highlight then unhighlight
61 DisplayIO.setCursorPosition(title.getX(), y);
62 Thread.sleep(500);
63 DisplayIO.pressMouse(InputEvent.BUTTON1_MASK);
64 Thread.sleep(100);
65 DisplayIO.setCursorPosition(title.getX() + title.getBoundsWidth() / 2,
66 y);
67 Thread.sleep(500);
68 DisplayIO.setCursorPosition(title.getX(), y);
69 Thread.sleep(500);
70 DisplayIO.releaseMouse(InputEvent.BUTTON1_MASK);
71 Thread.sleep(500);
72
73 // Make sure TDFC was performed
74 assertNotNull(title.getLink());
75 }
76}
Note: See TracBrowser for help on using the repository browser.