Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
69   436   37   1.86
0   156   0.54   37
37     1  
1    
 
  JInternalFrameFixture       Line # 39 69 0% 37 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Dec 8, 2007
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2007-2010 the original author or authors.
15    */
16    package org.fest.swing.fixture;
17   
18    import java.awt.Dimension;
19    import java.awt.Point;
20    import java.util.regex.Pattern;
21   
22    import javax.swing.JInternalFrame;
23   
24    import org.fest.swing.core.*;
25    import org.fest.swing.driver.JInternalFrameDriver;
26    import org.fest.swing.exception.*;
27    import org.fest.swing.timing.Timeout;
28   
29    /**
30    * Understands functional testing of <code>{@link JInternalFrame}</code>s:
31    * <ul>
32    * <li>user input simulation</li>
33    * <li>state verification</li>
34    * <li>property value query</li>
35    * </ul>
36    *
37    * @author Alex Ruiz
38    */
 
39    public class JInternalFrameFixture extends ContainerFixture<JInternalFrame> implements CommonComponentFixture,
40    FrameLikeFixture, JComponentFixture, JPopupMenuInvokerFixture {
41   
42    private JInternalFrameDriver driver;
43   
44    /**
45    * Creates a new <code>{@link JInternalFrameFixture}</code>.
46    * @param robot performs simulation of user events on a <code>JInternalFrame</code>.
47    * @param internalFrameName the name of the <code>JInternalFrame</code> to find using the given <code>Robot</code>.
48    * @throws NullPointerException if <code>robot</code> is <code>null</code>.
49    * @throws ComponentLookupException if a matching <code>JInternalFrame</code> could not be found.
50    * @throws ComponentLookupException if more than one matching <code>JInternalFrame</code> is found.
51    */
 
52  2 toggle public JInternalFrameFixture(Robot robot, String internalFrameName) {
53  2 super(robot, internalFrameName, JInternalFrame.class);
54  2 createDriver();
55    }
56   
57    /**
58    * Creates a new <code>{@link JInternalFrameFixture}</code>.
59    * @param robot performs simulation of user events on the given <code>JInternalFrame</code>.
60    * @param target the <code>JInternalFrame</code> to be managed by this fixture.
61    * @throws NullPointerException if <code>robot</code> is <code>null</code>.
62    * @throws NullPointerException if <code>target</code> is <code>null</code>.
63    */
 
64  35 toggle public JInternalFrameFixture(Robot robot, JInternalFrame target) {
65  35 super(robot, target);
66  35 createDriver();
67    }
68   
 
69  37 toggle private void createDriver() {
70  37 driver(new JInternalFrameDriver(robot));
71    }
72   
73    /**
74    * Sets the <code>{@link JInternalFrameDriver}</code> to be used by this fixture.
75    * @param newDriver the new <code>JInternalFrameDriver</code>.
76    * @throws NullPointerException if the given driver is <code>null</code>.
77    */
 
78  72 toggle protected final void driver(JInternalFrameDriver newDriver) {
79  72 validateNotNull(newDriver);
80  71 driver = newDriver;
81    }
82   
83    /**
84    * Brings this fixture's <code>{@link JInternalFrame}</code> to the front.
85    * @return this fixture.
86    */
 
87  1 toggle public JInternalFrameFixture moveToFront() {
88  1 driver.moveToFront(target);
89  1 return this;
90    }
91   
92    /**
93    * Brings this fixture's <code>{@link JInternalFrame}</code> to the back.
94    * @return this fixture.
95    */
 
96  1 toggle public JInternalFrameFixture moveToBack() {
97  1 driver.moveToBack(target);
98  1 return this;
99    }
100   
101    /**
102    * Simulates a user deiconifying this fixture's <code>{@link JInternalFrame}</code>.
103    * @return this fixture.
104    * @throws ActionFailedException if the <code>JInternalFrame</code> vetoes the action.
105    */
 
106  1 toggle public JInternalFrameFixture deiconify() {
107  1 driver.deiconify(target);
108  1 return this;
109    }
110   
111    /**
112    * Simulates a user iconifying this fixture's <code>{@link JInternalFrame}</code>.
113    * @return this fixture.
114    * @throws ActionFailedException if the given <code>JInternalFrame</code> is not iconifiable.
115    * @throws ActionFailedException if the <code>JInternalFrame</code> vetoes the action.
116    */
 
117  1 toggle public JInternalFrameFixture iconify() {
118  1 driver.iconify(target);
119  1 return this;
120    }
121   
122    /**
123    * Simulates a user maximizing this fixture's <code>{@link JInternalFrame}</code>, deconifying it first if it is
124    * iconified.
125    * @return this fixture.
126    * @throws ActionFailedException if the given <code>JInternalFrame</code> is not maximizable.
127    * @throws ActionFailedException if the <code>JInternalFrame</code> vetoes the action.
128    */
 
129  1 toggle public JInternalFrameFixture maximize() {
130  1 driver.maximize(target);
131  1 return this;
132    }
133   
134    /**
135    * Simulates a user normalizing this fixture's <code>{@link JInternalFrame}</code>, deconifying it first if it is
136    * iconified.
137    * @return this fixture.
138    * @throws ActionFailedException if the <code>JInternalFrame</code> vetoes the action.
139    */
 
140  1 toggle public JInternalFrameFixture normalize() {
141  1 driver.normalize(target);
142  1 return this;
143    }
144   
145    /**
146    * Simulates a user closing this fixture's <code>{@link JInternalFrame}</code>.
147    * @throws ActionFailedException if the <code>JInternalFrame</code> is not closable.
148    */
 
149  1 toggle public void close() {
150  1 driver.close(target);
151    }
152   
153    /**
154    * Asserts that the size of this fixture's <code>{@link JInternalFrame}</code> is equal to given one.
155    * @param size the given size to match.
156    * @return this fixture.
157    * @throws AssertionError if the size of this fixture's <code>JInternalFrame</code> is not equal to the given size.
158    */
 
159  1 toggle public JInternalFrameFixture requireSize(Dimension size) {
160  1 driver.requireSize(target, size);
161  1 return this;
162    }
163   
164    /**
165    * Simulates a user resizing horizontally this fixture's <code>{@link JInternalFrame}</code>.
166    * @param width the width that this fixture's <code>JInternalFrame</code> should have after being resized.
167    * @return this fixture.
168    */
 
169  1 toggle public JInternalFrameFixture resizeWidthTo(int width) {
170  1 driver.resizeWidthTo(target, width);
171  1 return this;
172    }
173   
174    /**
175    * Simulates a user resizing vertically this fixture's <code>{@link JInternalFrame}</code>.
176    * @param height the height that this fixture's <code>JInternalFrame</code> should have after being resized.
177    * @return this fixture.
178    */
 
179  1 toggle public JInternalFrameFixture resizeHeightTo(int height) {
180  1 driver.resizeHeightTo(target, height);
181  1 return this;
182    }
183   
184    /**
185    * Simulates a user resizing this fixture's <code>{@link JInternalFrame}</code>.
186    * @param size the size that the target <code>JInternalFrame</code> should have after being resized.
187    * @return this fixture.
188    */
 
189  1 toggle public JInternalFrameFixture resizeTo(Dimension size) {
190  1 driver.resizeTo(target, size);
191  1 return this;
192    }
193   
194    /**
195    * Simulates a user moving this fixture's <code>{@link JInternalFrame}</code> to the given point.
196    * @param p the point to move this fixture's <code>JInternalFrame</code> to.
197    * @return this fixture.
198    */
 
199  1 toggle public JInternalFrameFixture moveTo(Point p) {
200  1 driver.moveTo(target, p);
201  1 return this;
202    }
203   
204    /**
205    * Simulates a user clicking this fixture's <code>{@link JInternalFrame}</code>.
206    * @return this fixture.
207    */
 
208  1 toggle public JInternalFrameFixture click() {
209  1 driver.click(target);
210  1 return this;
211    }
212   
213    /**
214    * Simulates a user clicking this fixture's <code>{@link JInternalFrame}</code>.
215    * @param button the button to click.
216    * @return this fixture.
217    */
 
218  1 toggle public JInternalFrameFixture click(MouseButton button) {
219  1 driver.click(target, button);
220  1 return this;
221    }
222   
223    /**
224    * Simulates a user clicking this fixture's <code>{@link JInternalFrame}</code>.
225    * @param mouseClickInfo specifies the button to click and the times the button should be clicked.
226    * @return this fixture.
227    * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>.
228    */
 
229  1 toggle public JInternalFrameFixture click(MouseClickInfo mouseClickInfo) {
230  1 driver.click(target, mouseClickInfo);
231  1 return this;
232    }
233   
234    /**
235    * Simulates a user right-clicking this fixture's <code>{@link JInternalFrame}</code>.
236    * @return this fixture.
237    */
 
238  1 toggle public JInternalFrameFixture rightClick() {
239  1 driver.rightClick(target);
240  1 return this;
241    }
242   
243    /**
244    * Simulates a user double-clicking this fixture's <code>{@link JInternalFrame}</code>.
245    * @return this fixture.
246    */
 
247  1 toggle public JInternalFrameFixture doubleClick() {
248  1 driver.doubleClick(target);
249  1 return this;
250    }
251   
252    /**
253    * Gives input focus to this fixture's <code>{@link JInternalFrame}</code>.
254    * @return this fixture.
255    */
 
256  1 toggle public JInternalFrameFixture focus() {
257  1 driver.focus(target);
258  1 return this;
259    }
260   
261    /**
262    * Simulates a user pressing given key with the given modifiers on this fixture's <code>{@link JInternalFrame}</code>.
263    * Modifiers is a mask from the available <code>{@link java.awt.event.InputEvent}</code> masks.
264    * @param keyPressInfo specifies the key and modifiers to press.
265    * @return this fixture.
266    * @throws NullPointerException if the given <code>KeyPressInfo</code> is <code>null</code>.
267    * @throws IllegalArgumentException if the given code is not a valid key code.
268    * @see KeyPressInfo
269    */
 
270  1 toggle public JInternalFrameFixture pressAndReleaseKey(KeyPressInfo keyPressInfo) {
271  1 driver.pressAndReleaseKey(target, keyPressInfo);
272  1 return this;
273    }
274   
275    /**
276    * Simulates a user pressing and releasing the given keys on this fixture's <code>{@link JInternalFrame}</code> .
277    * @param keyCodes one or more codes of the keys to press.
278    * @return this fixture.
279    * @throws NullPointerException if the given array of codes is <code>null</code>.
280    * @throws IllegalArgumentException if any of the given code is not a valid key code.
281    * @see java.awt.event.KeyEvent
282    */
 
283  1 toggle public JInternalFrameFixture pressAndReleaseKeys(int... keyCodes) {
284  1 driver.pressAndReleaseKeys(target, keyCodes);
285  1 return this;
286    }
287   
288    /**
289    * Simulates a user pressing given key on this fixture's <code>{@link JInternalFrame}</code>.
290    * @param keyCode the code of the key to press.
291    * @return this fixture.
292    * @throws IllegalArgumentException if any of the given code is not a valid key code.
293    * @see java.awt.event.KeyEvent
294    */
 
295  1 toggle public JInternalFrameFixture pressKey(int keyCode) {
296  1 driver.pressKey(target, keyCode);
297  1 return this;
298    }
299   
300    /**
301    * Simulates a user releasing the given key on this fixture's <code>{@link JInternalFrame}</code>.
302    * @param keyCode the code of the key to release.
303    * @return this fixture.
304    * @throws IllegalArgumentException if any of the given code is not a valid key code.
305    * @see java.awt.event.KeyEvent
306    */
 
307  1 toggle public JInternalFrameFixture releaseKey(int keyCode) {
308  1 driver.releaseKey(target, keyCode);
309  1 return this;
310    }
311   
312    /**
313    * Asserts that this fixture's <code>{@link JInternalFrame}</code> has input focus.
314    * @return this fixture.
315    * @throws AssertionError if this fixture's <code>JInternalFrame</code> does not have input focus.
316    */
 
317  1 toggle public JInternalFrameFixture requireFocused() {
318  1 driver.requireFocused(target);
319  1 return this;
320    }
321   
322    /**
323    * Asserts that this fixture's <code>{@link JInternalFrame}</code> is enabled.
324    * @return this fixture.
325    * @throws AssertionError if the managed <code>JInternalFrame</code> is disabled.
326    */
 
327  1 toggle public JInternalFrameFixture requireEnabled() {
328  1 driver.requireEnabled(target);
329  1 return this;
330    }
331   
332    /**
333    * Asserts that this fixture's <code>{@link JInternalFrame}</code> is enabled.
334    * @param timeout the time this fixture will wait for the component to be enabled.
335    * @return this fixture.
336    * @throws WaitTimedOutError if the managed <code>JInternalFrame</code> is never enabled.
337    */
 
338  1 toggle public JInternalFrameFixture requireEnabled(Timeout timeout) {
339  1 driver.requireEnabled(target, timeout);
340  1 return this;
341    }
342   
343    /**
344    * Asserts that this fixture's <code>{@link JInternalFrame}</code> is disabled.
345    * @return this fixture.
346    * @throws AssertionError if the managed <code>JInternalFrame</code> is enabled.
347    */
 
348  1 toggle public JInternalFrameFixture requireDisabled() {
349  1 driver.requireDisabled(target);
350  1 return this;
351    }
352   
353    /**
354    * Asserts that this fixture's <code>{@link JInternalFrame}</code> is visible.
355    * @return this fixture.
356    * @throws AssertionError if the managed <code>JInternalFrame</code> is not visible.
357    */
 
358  1 toggle public JInternalFrameFixture requireVisible() {
359  1 driver.requireVisible(target);
360  1 return this;
361    }
362   
363    /**
364    * Asserts that this fixture's <code>{@link JInternalFrame}</code> is not visible.
365    * @return this fixture.
366    * @throws AssertionError if the managed <code>JInternalFrame</code> is visible.
367    */
 
368  1 toggle public JInternalFrameFixture requireNotVisible() {
369  1 driver.requireNotVisible(target);
370  1 return this;
371    }
372   
373   
374    /**
375    * Asserts that the toolTip in this fixture's <code>{@link JInternalFrame}</code> matches the given value.
376    * @param expected the given value. It can be a regular expression.
377    * @return this fixture.
378    * @throws AssertionError if the toolTip in this fixture's <code>JInternalFrame</code> does not match the given value.
379    * @since 1.2
380    */
 
381  1 toggle public JInternalFrameFixture requireToolTip(String expected) {
382  1 driver.requireToolTip(target, expected);
383  1 return this;
384    }
385   
386    /**
387    * Asserts that the toolTip in this fixture's <code>{@link JInternalFrame}</code> matches the given regular expression
388    * pattern.
389    * @param pattern the regular expression pattern to match.
390    * @return this fixture.
391    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
392    * @throws AssertionError if the toolTip in this fixture's <code>JInternalFrame</code> does not match the given
393    * regular expression.
394    * @since 1.2
395    */
 
396  1 toggle public JInternalFrameFixture requireToolTip(Pattern pattern) {
397  1 driver.requireToolTip(target, pattern);
398  1 return this;
399    }
400   
401    /**
402    * Returns the client property stored in this fixture's <code>{@link JInternalFrame}</code>, under the given key.
403    * @param key the key to use to retrieve the client property.
404    * @return the value of the client property stored under the given key, or <code>null</code> if the property was
405    * not found.
406    * @throws NullPointerException if the given key is <code>null</code>.
407    * @since 1.2
408    */
 
409  1 toggle public Object clientProperty(Object key) {
410  1 return driver.clientProperty(target, key);
411    }
412   
413    /**
414    * Shows a pop-up menu using this fixture's <code>{@link JInternalFrame}</code> as the invoker of the pop-up menu.
415    * @return a fixture that manages the displayed pop-up menu.
416    * @throws IllegalStateException if this fixture's <code>JInternalFrame</code> is disabled.
417    * @throws IllegalStateException if this fixture's <code>JInternalFrame</code> is not showing on the screen.
418    * @throws ComponentLookupException if a pop-up menu cannot be found.
419    */
 
420  1 toggle public JPopupMenuFixture showPopupMenu() {
421  1 return new JPopupMenuFixture(robot, driver.invokePopupMenu(target));
422    }
423   
424    /**
425    * Shows a pop-up menu at the given point using this fixture's <code>{@link JInternalFrame}</code> as the invoker of
426    * the pop-up menu.
427    * @param p the given point where to show the pop-up menu.
428    * @return a fixture that manages the displayed pop-up menu.
429    * @throws IllegalStateException if this fixture's <code>JInternalFrame</code> is disabled.
430    * @throws IllegalStateException if this fixture's <code>JInternalFrame</code> is not showing on the screen.
431    * @throws ComponentLookupException if a pop-up menu cannot be found.
432    */
 
433  1 toggle public JPopupMenuFixture showPopupMenuAt(Point p) {
434  1 return new JPopupMenuFixture(robot, driver.invokePopupMenu(target, p));
435    }
436    }