1 | package org.expeditee.gui;
|
---|
2 |
|
---|
3 | import java.awt.event.InputEvent;
|
---|
4 | import java.awt.event.KeyEvent;
|
---|
5 |
|
---|
6 | import org.expeditee.items.Item;
|
---|
7 |
|
---|
8 | public class FrameKeyboardsActionsTest extends GuiTestCase {
|
---|
9 |
|
---|
10 | public static int DELAY = 200;
|
---|
11 |
|
---|
12 | public final void testTypeText() throws Exception {
|
---|
13 | Frame testFrame = showBlankFrame();
|
---|
14 | DisplayIO.typeKey(KeyEvent.VK_ESCAPE);
|
---|
15 | DisplayIO.typeText("hello");
|
---|
16 | // Pick the item up in the middle
|
---|
17 | Item currentItem = FrameUtils.getCurrentItem();
|
---|
18 | assertNotNull(currentItem);
|
---|
19 | DisplayIO.setCursorPosition(currentItem.getX()
|
---|
20 | + currentItem.getBoundsWidth() / 2,
|
---|
21 | FrameMouseActions.MouseY - 2);
|
---|
22 | Thread.sleep(DELAY);
|
---|
23 | DisplayIO.clickMouse(InputEvent.BUTTON2_MASK);
|
---|
24 | Thread.sleep(DELAY);
|
---|
25 | DisplayIO.setCursorPosition(
|
---|
26 | Math.round(FrameGraphics.getMaxFrameSize().getWidth() / 2),
|
---|
27 | FrameMouseActions.MouseY);
|
---|
28 | Thread.sleep(DELAY);
|
---|
29 | DisplayIO.typeKey(KeyEvent.VK_ESCAPE);
|
---|
30 | Thread.sleep(DELAY);
|
---|
31 | DisplayIO.clickMouse(InputEvent.BUTTON2_MASK);
|
---|
32 | Thread.sleep(DELAY);
|
---|
33 |
|
---|
34 | // Check that the current position is the origin of the item
|
---|
35 | assertEquals(currentItem.getX(), FrameMouseActions.getX());
|
---|
36 |
|
---|
37 | DisplayIO.typeKey(KeyEvent.VK_ESCAPE);
|
---|
38 |
|
---|
39 | DisplayIO.typeStringDirect(0.05, "Hello Again!");
|
---|
40 |
|
---|
41 | DisplayIO.typeKey(KeyEvent.VK_ESCAPE);
|
---|
42 |
|
---|
43 | DisplayIO.typeText("Hello Again");
|
---|
44 |
|
---|
45 | assertEquals(4, testFrame.getItems(false).size());
|
---|
46 |
|
---|
47 | }
|
---|
48 | }
|
---|