|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DragEventDataT.java | - | 100% | 100% | 100% |
|
1 |
package junit.extensions.jfcunit.eventdata;
|
|
2 |
|
|
3 |
import junit.extensions.jfcunit.JFCTestCase;
|
|
4 |
|
|
5 |
import java.awt.Component;
|
|
6 |
|
|
7 |
import javax.swing.JButton;
|
|
8 |
|
|
9 |
/**
|
|
10 |
* Data container class that holds all the data necessary for jfcUnit to fire mouse events.
|
|
11 |
*
|
|
12 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
13 |
*/
|
|
14 |
public class DragEventDataT extends MouseEventDataBC { |
|
15 |
/**
|
|
16 |
* Event data to be validated.
|
|
17 |
*/
|
|
18 |
private DragEventData m_event1 = null; |
|
19 |
|
|
20 |
/**
|
|
21 |
* Second event data to be validated.
|
|
22 |
*/
|
|
23 |
private DragEventData m_event2 = null; |
|
24 |
|
|
25 |
/**
|
|
26 |
* Component to be tested.
|
|
27 |
*/
|
|
28 |
private static final Component COMP1 = new JButton(); |
|
29 |
|
|
30 |
/**
|
|
31 |
* Second component to be tested.
|
|
32 |
*/
|
|
33 |
private static final Component COMP2 = new JButton(); |
|
34 |
|
|
35 |
/**
|
|
36 |
* Source 1.
|
|
37 |
*/
|
|
38 |
private static final AbstractMouseEventData SRC1 = new MouseEventData(null, COMP1); |
|
39 |
|
|
40 |
/**
|
|
41 |
* Source 2.
|
|
42 |
*/
|
|
43 |
private static final AbstractMouseEventData SRC2 = new MouseEventData(null, COMP2); |
|
44 |
|
|
45 |
/**
|
|
46 |
* Destination 1.
|
|
47 |
*/
|
|
48 |
private static final AbstractMouseEventData DST1 = new MouseEventData(null, COMP2); |
|
49 |
|
|
50 |
/**
|
|
51 |
* Destination 2.
|
|
52 |
*/
|
|
53 |
private static final AbstractMouseEventData DST2 = new MouseEventData(null, COMP1); |
|
54 |
|
|
55 |
/**
|
|
56 |
* Default constructor that accepts a String.
|
|
57 |
*
|
|
58 |
* @param name The name of the test method to execute.
|
|
59 |
*/
|
|
60 | 4 |
public DragEventDataT(final String name) {
|
61 | 4 |
super(name);
|
62 |
} |
|
63 |
|
|
64 |
/**
|
|
65 |
* Overridden method that is used to remove the test fixtures.
|
|
66 |
*
|
|
67 |
* @exception Exception An instance of java.lang.Exception can be thrown.
|
|
68 |
*/
|
|
69 | 4 |
protected void tearDown() throws Exception { |
70 | 4 |
super.tearDown();
|
71 | 4 |
m_event1 = null;
|
72 | 4 |
m_event2 = null;
|
73 |
} |
|
74 |
|
|
75 |
/**
|
|
76 |
* Validate the parameters of the event match the values
|
|
77 |
* given.
|
|
78 |
*
|
|
79 |
* @param event Event to be tested.
|
|
80 |
* @param tc TestCase.
|
|
81 |
* @param src Source event data.
|
|
82 |
* @param dst Destination event data.
|
|
83 |
* @param sleepTime Sleep time.
|
|
84 |
*/
|
|
85 | 6 |
protected void validate(final DragEventData event, |
86 |
final JFCTestCase tc, |
|
87 |
final AbstractMouseEventData src, |
|
88 |
final AbstractMouseEventData dst, |
|
89 |
final long sleepTime) {
|
|
90 | 6 |
assertSameOrNull("TestCase:", tc, event.getTestCase());
|
91 | 6 |
assertSameOrNull("Source:", src, event.getSource());
|
92 | 6 |
assertSameOrNull("Destination:", dst, event.getDest());
|
93 | 6 |
assertEquals("SleepTime:", sleepTime, event.getSleepTime());
|
94 |
} |
|
95 |
|
|
96 |
/**
|
|
97 |
* Test Constructor 1.
|
|
98 |
*/
|
|
99 | 1 |
public void testDragEventData1() { |
100 | 1 |
m_event1 = new DragEventData(this, SRC1); |
101 | 1 |
validate(m_event1, this, SRC1, null, DEFAULT_SLEEPTIME); |
102 | 1 |
m_event2 = new DragEventData(this, SRC2); |
103 | 1 |
validate(m_event2, this, SRC2, null, DEFAULT_SLEEPTIME); |
104 |
} |
|
105 |
|
|
106 |
/**
|
|
107 |
* Test Constructor 2.
|
|
108 |
*/
|
|
109 | 1 |
public void testDragEventData2() { |
110 | 1 |
m_event1 = new DragEventData(this, SRC1, DST1); |
111 | 1 |
validate(m_event1, this, SRC1, DST1, DEFAULT_SLEEPTIME);
|
112 | 1 |
m_event2 = new DragEventData(this, SRC2, DST2); |
113 | 1 |
validate(m_event2, this, SRC2, DST2, DEFAULT_SLEEPTIME);
|
114 |
} |
|
115 |
|
|
116 |
/**
|
|
117 |
* Test Constructor 3.
|
|
118 |
*/
|
|
119 | 1 |
public void testDragEventData3() { |
120 | 1 |
m_event1 = new DragEventData(this, SRC1, DST1, 1500); |
121 | 1 |
validate(m_event1, this, SRC1, DST1, 1500);
|
122 | 1 |
m_event2 = new DragEventData(this, SRC2, DST2, 2500); |
123 | 1 |
validate(m_event2, this, SRC2, DST2, 2500);
|
124 |
} |
|
125 |
|
|
126 |
/**
|
|
127 |
* Test the equals.
|
|
128 |
*/
|
|
129 | 1 |
public void testEquals() { |
130 | 1 |
m_event1 = new DragEventData(this, SRC1, DST1, 1500); |
131 | 1 |
m_event2 = new DragEventData(this, SRC1, DST1, 1500); |
132 | 1 |
assertTrue("Not equals:", m_event1.equals(m_event2));
|
133 | 1 |
assertTrue("Null equals:", !m_event1.equals(null)); |
134 | 1 |
assertTrue("Invalid class:", !m_event1.equals("")); |
135 | 1 |
m_event2 = new DragEventData(this, SRC2, DST1, 1500); |
136 | 1 |
assertTrue("Equals but Source different:", !m_event1.equals(m_event2));
|
137 | 1 |
m_event2 = new DragEventData(this, SRC1, DST2, 1500); |
138 | 1 |
assertTrue("Equals but Destination different:", !m_event1.equals(m_event2));
|
139 | 1 |
m_event2 = new DragEventData(this, SRC2, DST2, 2500); |
140 | 1 |
assertTrue("Equals but All different:", !m_event1.equals(m_event2));
|
141 |
} |
|
142 |
} |
|
143 |
|
|