|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| RobotTest.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
package junit.extensions.jfcunit.javatest;
|
|
| 2 |
|
|
| 3 |
import junit.extensions.jfcunit.JFCTestCase;
|
|
| 4 |
|
|
| 5 |
import java.awt.AWTEvent;
|
|
| 6 |
import java.awt.Robot;
|
|
| 7 |
import java.awt.event.AWTEventListener;
|
|
| 8 |
import java.awt.event.MouseEvent;
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
/**
|
|
| 12 |
* <p>Title: Test The robot.</p>
|
|
| 13 |
* <p>Description: </p>
|
|
| 14 |
* <p>Copyright: Copyright (c) 2003</p>
|
|
| 15 |
* <p>Company: JFCUnit </p>
|
|
| 16 |
* @author Kevin Wilson
|
|
| 17 |
* @version 1.0
|
|
| 18 |
*/
|
|
| 19 |
public class RobotTest extends JFCTestCase { |
|
| 20 |
/** Robot to be used for test. */
|
|
| 21 |
private Robot m_robot = null; |
|
| 22 |
|
|
| 23 |
/** lastx location of mouse. */
|
|
| 24 |
private int m_lastx = -1; |
|
| 25 |
|
|
| 26 |
/** lasty location of mouse. */
|
|
| 27 |
private int m_lasty = -1; |
|
| 28 |
|
|
| 29 |
/** Constructor. */
|
|
| 30 | 0 |
public RobotTest() {
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
/**
|
|
| 34 |
* Constructor.
|
|
| 35 |
* @param name Name of the test case.
|
|
| 36 |
*/
|
|
| 37 | 0 |
public RobotTest(final String name) {
|
| 38 | 0 |
super(name);
|
| 39 |
} |
|
| 40 |
|
|
| 41 |
/**
|
|
| 42 |
* Setup the test case.
|
|
| 43 |
* @throws Exception may be thrown.
|
|
| 44 |
*/
|
|
| 45 | 0 |
public void setUp() throws Exception { |
| 46 | 0 |
super.setUp();
|
| 47 | 0 |
m_robot = new Robot();
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
/**
|
|
| 51 |
* Run the test.
|
|
| 52 |
* @param args arguments to the main method.
|
|
| 53 |
*/
|
|
| 54 | 0 |
public static void main(final String[] args) { |
| 55 | 0 |
RobotTest robotTest1 = new RobotTest();
|
| 56 |
} |
|
| 57 |
|
|
| 58 |
/**
|
|
| 59 |
* Test the mouse click. Not implemented.
|
|
| 60 |
* @throws Throwable may be thrown.
|
|
| 61 |
*/
|
|
| 62 | 0 |
public void testRobotClick() throws Throwable { |
| 63 |
} |
|
| 64 |
|
|
| 65 |
/**
|
|
| 66 |
* Test sending in keys to the robot. Not implemented.
|
|
| 67 |
* @throws Throwable may be thrown.
|
|
| 68 |
*/
|
|
| 69 | 0 |
public void testRobotKey() throws Throwable { |
| 70 |
} |
|
| 71 |
|
|
| 72 |
/**
|
|
| 73 |
* Test the mouse move of the robot.
|
|
| 74 |
* @throws Throwable may be thrown.
|
|
| 75 |
*/
|
|
| 76 | 0 |
public void testRobotMove() throws Throwable { |
| 77 | 0 |
java.awt.Frame frame = new java.awt.Frame();
|
| 78 | 0 |
frame.setSize(600, 600); |
| 79 | 0 |
frame.setLocation(0, 0); |
| 80 | 0 |
frame.setVisible(true);
|
| 81 | 0 |
frame.requestFocus(); |
| 82 | 0 |
java.awt.Toolkit.getDefaultToolkit().addAWTEventListener( |
| 83 |
new AWTEventListener() {
|
|
| 84 | 0 |
public void eventDispatched(final AWTEvent e) { |
| 85 | 0 |
if (!(e instanceof MouseEvent)) { |
| 86 | 0 |
return;
|
| 87 |
} |
|
| 88 |
|
|
| 89 | 0 |
MouseEvent me = (MouseEvent) e; |
| 90 | 0 |
m_lastx = me.getPoint().x; |
| 91 | 0 |
m_lasty = me.getPoint().y; |
| 92 |
} |
|
| 93 |
}, |
|
| 94 |
java.awt.event.MouseEvent.MOUSE_MOVED); |
|
| 95 |
|
|
| 96 | 0 |
for (int x = 0; x < 600; x += 5) { |
| 97 | 0 |
for (int y = 0; y < 600; y += 5) { |
| 98 | 0 |
m_lastx = -1; |
| 99 | 0 |
m_lasty = -1; |
| 100 | 0 |
m_robot.mouseMove(x, y); |
| 101 |
|
|
| 102 | 0 |
if (m_lastx != -1) {
|
| 103 | 0 |
assertEquals("X location:", x, m_lastx);
|
| 104 | 0 |
assertEquals("Y location:", y, m_lasty);
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
} |
|
| 108 |
} |
|
| 109 |
} |
|
| 110 |
|
|
||||||||||