|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| RobotAWTModeTest.java | 50% | 94.1% | 87.5% | 86.2% |
|
||||||||||||||
| 1 |
package abbot.tester;
|
|
| 2 |
|
|
| 3 |
import java.awt.*;
|
|
| 4 |
import java.awt.event.*;
|
|
| 5 |
|
|
| 6 |
import javax.swing.*;
|
|
| 7 |
|
|
| 8 |
import junit.extensions.abbot.*;
|
|
| 9 |
import junit.framework.*;
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
public class RobotAWTModeTest extends ComponentTestFixture { |
|
| 13 |
|
|
| 14 | 1 |
public void testEmpty() { |
| 15 |
// add AWT-specific tests
|
|
| 16 |
} |
|
| 17 |
|
|
| 18 |
/** Wrap the standard robot tests in AWT mode. */
|
|
| 19 |
private static class AWTMode extends TestSuite { |
|
| 20 | 2 |
public AWTMode(Class cls) { super(cls); } |
| 21 | 32 |
public void addTest(Test test) { |
| 22 |
// ignore drag/drop tests, which won't work
|
|
| 23 | 32 |
if (test.toString().indexOf("Drag") == -1) |
| 24 | 32 |
super.addTest(test);
|
| 25 |
} |
|
| 26 | 2 |
public void run(TestResult result) { |
| 27 | 2 |
int lastMode = Robot.getEventMode();
|
| 28 | 2 |
Robot.setEventMode(Robot.EM_AWT); |
| 29 | 2 |
try {
|
| 30 | 2 |
super.run(result);
|
| 31 |
} |
|
| 32 |
finally {
|
|
| 33 | 2 |
Robot.setEventMode(lastMode); |
| 34 |
} |
|
| 35 |
} |
|
| 36 |
} |
|
| 37 |
|
|
| 38 | 1 |
public static Test suite() { |
| 39 | 1 |
TestSuite suite = new TestSuite(RobotAWTModeTest.class); |
| 40 |
// Only add in the AWT version of the basic robot tests if
|
|
| 41 |
// we're in robot mode; otherwise we're just duplicating effort.
|
|
| 42 | 1 |
if (Robot.getEventMode() == Robot.EM_ROBOT) {
|
| 43 | 1 |
suite.addTest(new AWTMode(RobotTest.class)); |
| 44 |
//suite.addTest(new AWTMode(RobotDragDropTest.class));
|
|
| 45 | 1 |
suite.addTest(new AWTMode(RobotAppletTest.class)); |
| 46 |
} |
|
| 47 | 1 |
return suite;
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
private int lastMode; |
|
| 51 |
/** All these tests run in AWT mode. */
|
|
| 52 | 1 |
protected void setUp() { |
| 53 | 1 |
lastMode = Robot.getEventMode(); |
| 54 | 1 |
Robot.setEventMode(Robot.EM_AWT); |
| 55 |
} |
|
| 56 |
|
|
| 57 |
/** Restore the robot event generation mode. */
|
|
| 58 | 1 |
protected void tearDown() { |
| 59 | 1 |
Robot.setEventMode(lastMode); |
| 60 |
} |
|
| 61 |
|
|
| 62 |
/** Provide for repetitive testing on individual tests. */
|
|
| 63 | 0 |
public static void main(String[] args) { |
| 64 | 0 |
RepeatHelper.runTests(args, RobotAWTModeTest.class);
|
| 65 |
} |
|
| 66 |
} |
|
| 67 |
|
|
||||||||||