source: trunk/tests/org/expeditee/gui/FrameMouseActionsTest.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.1 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 = 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}
Note: See TracBrowser for help on using the repository browser.