1 | package org.expeditee.gui;
|
---|
2 |
|
---|
3 | import java.awt.event.InputEvent;
|
---|
4 |
|
---|
5 | import org.expeditee.actions.Navigation;
|
---|
6 | import org.expeditee.items.Text;
|
---|
7 |
|
---|
8 | public 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 = DisplayController.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 = DisplayController.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 | DisplayController.setCursorPosition(title.getX(), y);
|
---|
48 | Thread.sleep(500);
|
---|
49 | DisplayController.pressMouse(InputEvent.BUTTON1_MASK);
|
---|
50 | Thread.sleep(100);
|
---|
51 | DisplayController.setCursorPosition(title.getX() + title.getBoundsWidth() / 2,
|
---|
52 | y);
|
---|
53 | Thread.sleep(500);
|
---|
54 | DisplayController.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 | DisplayController.setCursorPosition(title.getX(), y);
|
---|
62 | Thread.sleep(500);
|
---|
63 | DisplayController.pressMouse(InputEvent.BUTTON1_MASK);
|
---|
64 | Thread.sleep(100);
|
---|
65 | DisplayController.setCursorPosition(title.getX() + title.getBoundsWidth() / 2,
|
---|
66 | y);
|
---|
67 | Thread.sleep(500);
|
---|
68 | DisplayController.setCursorPosition(title.getX(), y);
|
---|
69 | Thread.sleep(500);
|
---|
70 | DisplayController.releaseMouse(InputEvent.BUTTON1_MASK);
|
---|
71 | Thread.sleep(500);
|
---|
72 |
|
---|
73 | // Make sure TDFC was performed
|
---|
74 | assertNotNull(title.getLink());
|
---|
75 | }
|
---|
76 | }
|
---|