|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MouseEventDataBC.java | 100% | 100% | 100% | 100% |
|
1 |
package junit.extensions.jfcunit.eventdata;
|
|
2 |
|
|
3 |
import junit.extensions.jfcunit.JFCTestCase;
|
|
4 |
import junit.extensions.jfcunit.AbstractTestCase;
|
|
5 |
|
|
6 |
import java.awt.Component;
|
|
7 |
import java.awt.Point;
|
|
8 |
import java.awt.event.MouseEvent;
|
|
9 |
|
|
10 |
/**
|
|
11 |
* Data container class that holds all the data necessary for jfcUnit to fire mouse events.
|
|
12 |
*
|
|
13 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
14 |
*/
|
|
15 |
public class MouseEventDataBC extends AbstractTestCase implements EventDataConstants { |
|
16 |
/**
|
|
17 |
* Modifier to be tested.
|
|
18 |
*/
|
|
19 |
protected static final int MODIFIERS1 = MouseEvent.BUTTON3_MASK + MouseEvent.SHIFT_MASK; |
|
20 |
|
|
21 |
/**
|
|
22 |
* Second modifier to be tested.
|
|
23 |
*/
|
|
24 |
protected static final int MODIFIERS2 = MouseEvent.BUTTON2_MASK; |
|
25 |
|
|
26 |
/**
|
|
27 |
* Reference point to be tested.
|
|
28 |
*/
|
|
29 |
protected static final Point P1 = new Point(5, 5); |
|
30 |
|
|
31 |
/**
|
|
32 |
* Second reference point to be tested.
|
|
33 |
*/
|
|
34 |
protected static final Point P2 = new Point(10, 10); |
|
35 |
|
|
36 |
/**
|
|
37 |
* Default constructor that accepts a String.
|
|
38 |
*
|
|
39 |
* @param name The name of the test method to execute.
|
|
40 |
*/
|
|
41 | 136 |
public MouseEventDataBC(final String name) {
|
42 | 136 |
super(name);
|
43 |
} |
|
44 |
|
|
45 |
/**
|
|
46 |
* Validate that the objects are the same or the objects passed are both null.
|
|
47 |
*
|
|
48 |
* @param desc description of test.
|
|
49 |
* @param a Object to be tested.
|
|
50 |
* @param b Object to be tested.
|
|
51 |
*
|
|
52 |
* Will assert on failure.
|
|
53 |
*/
|
|
54 | 834 |
protected void assertSameOrNull(final String desc, final Object a, final Object b) { |
55 | 834 |
if (a == null) { |
56 | 192 |
assertEquals(desc, a, b); |
57 |
} else {
|
|
58 | 642 |
assertSame(desc, a, b); |
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
/**
|
|
63 |
* Validate the parameters of the event match the values
|
|
64 |
* given.
|
|
65 |
*
|
|
66 |
* @param event Event to be tested.
|
|
67 |
* @param tc TestCase
|
|
68 |
* @param cb component
|
|
69 |
* @param clicks mouse clicks.
|
|
70 |
* @param modifiers Modifiers to be used.
|
|
71 |
* @param popup Popup
|
|
72 |
* @param sleepTime sleep duration.
|
|
73 |
* @param position locatio of mouse.
|
|
74 |
* @param ref Reference location.
|
|
75 |
*/
|
|
76 | 210 |
protected void validateEvent( |
77 |
final AbstractMouseEventData event, |
|
78 |
final JFCTestCase tc, |
|
79 |
final Component cb, |
|
80 |
final int clicks,
|
|
81 |
final int modifiers,
|
|
82 |
final boolean popup,
|
|
83 |
final long sleepTime,
|
|
84 |
final int position,
|
|
85 |
final Point ref) { |
|
86 | 210 |
assertSameOrNull("TestCase:", tc, event.getTestCase());
|
87 | 210 |
assertSameOrNull("Component:", cb, event.getComponent());
|
88 | 210 |
assertEquals("Clicks:", clicks, event.getNumberOfClicks());
|
89 | 210 |
assertEquals("Modifiers:", modifiers, event.getModifiers());
|
90 | 210 |
assertEquals("Popup:", popup, event.getPopupTrigger());
|
91 | 210 |
assertEquals("Sleep:", sleepTime, event.getSleepTime());
|
92 | 210 |
assertEquals("Position:", position, event.getPosition());
|
93 | 210 |
assertSameOrNull("Reference:", ref, event.getReferencePoint());
|
94 | 210 |
assertTrue("Valid Event:", event.isValid());
|
95 |
} |
|
96 |
} |
|
97 |
|
|