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
110   899   62   1.77
0   260   0.56   62
62     1  
1    
3.4% of code in this file is excluded from these metrics.
 
  JListFixture       Line # 50 110 3.4% 62 2 98.8% 0.9883721
 
No Tests
 
1    /*
2    * Created on Jun 12, 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 static org.fest.swing.core.MouseButton.LEFT_BUTTON;
19   
20    import java.awt.Point;
21    import java.util.regex.Pattern;
22   
23    import javax.swing.JList;
24   
25    import org.fest.swing.cell.JListCellReader;
26    import org.fest.swing.core.*;
27    import org.fest.swing.driver.BasicJListCellReader;
28    import org.fest.swing.driver.JListDriver;
29    import org.fest.swing.exception.*;
30    import org.fest.swing.timing.Timeout;
31    import org.fest.swing.util.Range;
32   
33    /**
34    * Understands functional testing of <code>{@link JList}</code>s:
35    * <ul>
36    * <li>user input simulation</li>
37    * <li>state verification</li>
38    * <li>property value query</li>
39    * </ul>
40    * <p>
41    * The conversion between the values given in tests and the values being displayed by a <code>{@link JList}</code>
42    * renderer is performed by a <code>{@link JListCellReader}</code>. This fixture uses a
43    * <code>{@link BasicJListCellReader}</code> by default.
44    * </p>
45    *
46    * @author Alex Ruiz
47    * @author Yvonne Wang
48    * @author Fabien Barbero
49    */
 
50    public class JListFixture extends ComponentFixture<JList> implements CommonComponentFixture,
51    ItemGroupFixture, JComponentFixture, JPopupMenuInvokerFixture {
52   
53    private JListDriver driver;
54   
55    /**
56    * Creates a new <code>{@link JListFixture}</code>.
57    * @param robot performs simulation of user events on a <code>JList</code>.
58    * @param listName the name of the <code>JList</code> to find using the given <code>Robot</code>.
59    * @throws NullPointerException if <code>robot</code> is <code>null</code>.
60    * @throws ComponentLookupException if a matching <code>JList</code> could not be found.
61    * @throws ComponentLookupException if more than one matching <code>JList</code> is found.
62    */
 
63  1 toggle public JListFixture(Robot robot, String listName) {
64  1 super(robot, listName, JList.class);
65  1 createDriver();
66    }
67   
68    /**
69    * Creates a new <code>{@link JListFixture}</code>.
70    * @param robot performs simulation of user events on the given <code>JList</code>.
71    * @param target the <code>JList</code> to be managed by this fixture.
72    * @throws NullPointerException if <code>robot</code> is <code>null</code>.
73    * @throws NullPointerException if <code>target</code> is <code>null</code>.
74    */
 
75  63 toggle public JListFixture(Robot robot, JList target) {
76  63 super(robot, target);
77  63 createDriver();
78    }
79   
 
80  64 toggle private void createDriver() {
81  64 driver(new JListDriver(robot));
82    }
83   
84    /**
85    * Sets the <code>{@link JListDriver}</code> to be used by this fixture.
86    * @param newDriver the new <code>JListDriver</code>.
87    * @throws NullPointerException if the given driver is <code>null</code>.
88    */
 
89  122 toggle protected final void driver(JListDriver newDriver) {
90  122 validateNotNull(newDriver);
91  121 driver = newDriver;
92    }
93   
94    /**
95    * Returns the <code>String</code> representation of the value of an item in this fixture's
96    * <code>{@link JList}</code>, using this fixture's <code>{@link JListCellReader}</code>.
97    * @param index the index of the item to return.
98    * @return the <code>String</code> representation of the value of an item in this fixture's <code>JList</code>.
99    * @throws IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in
100    * the <code>JList</code>.
101    * @see #cellReader(JListCellReader)
102    */
 
103  1 toggle public String valueAt(int index) {
104  1 return driver.value(target, index);
105    }
106   
107    /**
108    * Returns the <code>String</code> representation of the elements in this fixture's <code>{@link JList}</code>,
109    * using this fixture's <code>{@link JListCellReader}</code>.
110    * @return the <code>String</code> representation of the elements in this fixture's <code>JList</code>.
111    * @see #cellReader(JListCellReader)
112    */
 
113  1 toggle public String[] contents() {
114  1 return driver.contentsOf(target);
115    }
116   
117    /**
118    * Returns the <code>String</code> representation of the selected elements in this fixture's
119    * <code>{@link JList}</code>, using this fixture's <code>{@link JListCellReader}</code>.
120    * @return the <code>String</code> representation of the selected elements in this fixture's <code>JList</code>.
121    * @see #cellReader(JListCellReader)
122    */
 
123  2 toggle public String[] selection() {
124  2 return driver.selectionOf(target);
125    }
126   
127    /**
128    * Returns a fixture that manages the list item specified by the given index.
129    * @param index of the item.
130    * @return a fixture that manages the list item specified by the given index.
131    * @throws IndexOutOfBoundsException if the index is out of bounds.
132    */
 
133  1 toggle public JListItemFixture item(int index) {
134  1 return new JListItemFixture(this, index);
135    }
136   
137    /**
138    * Returns a fixture that manages the list item specified by the given text.
139    * @param text the text of the item. It can be a regular expression.
140    * @return a fixture that manages the list item specified by the given text.
141    * @throws LocationUnavailableException if an element matching the given text cannot be found.
142    */
 
143  1 toggle public JListItemFixture item(String text) {
144  1 return new JListItemFixture(this, driver.indexOf(target, text));
145    }
146   
147    /**
148    * Returns a fixture that manages the list item whose text matches the given regular expression pattern.
149    * @param pattern the regular expression pattern to match.
150    * @return a fixture that manages the list item whose text matches the given regular expression pattern.
151    * @throws LocationUnavailableException if an element matching the given text cannot be found.
152    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
153    * @since 1.2
154    */
 
155  1 toggle public JListItemFixture item(Pattern pattern) {
156  1 return new JListItemFixture(this, driver.indexOf(target, pattern));
157    }
158   
159    /**
160    * Clears the selection in this fixture's <code>{@link JList}</code>. Since this method does not simulate user input,
161    * it does not verifies that this fixture's <code>JList</code> is enabled and showing.
162    * @return this fixture.
163    * @since 1.2
164    */
 
165  1 toggle public JListFixture clearSelection() {
166  1 driver.clearSelection(target);
167  1 return this;
168    }
169   
170    /**
171    * Simulates a user selecting the items (in the specified range) in this fixture's <code>{@link JList}</code>.
172    * @param from the starting point of the selection.
173    * @param to the last item to select (inclusive.)
174    * @return this fixture.
175    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
176    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
177    * @throws IndexOutOfBoundsException if the any index is negative or greater than the index of the last item in the
178    * <code>JList</code>.
179    */
 
180  1 toggle public JListFixture selectItems(Range.From from, Range.To to) {
181  1 driver.selectItems(target, from, to);
182  1 return this;
183    }
184   
185    /**
186    * Simulates a user selecting the specified items in this fixture's <code>{@link JList}</code>.
187    * @param indices the indices of the items to select.
188    * @return this fixture.
189    * @throws NullPointerException if the given array is <code>null</code>.
190    * @throws IllegalArgumentException if the given array is empty.
191    * @throws IndexOutOfBoundsException if any of the indices is negative or greater than the index of the last item in
192    * the <code>JList</code>.
193    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
194    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
195    */
 
196  1 toggle public JListFixture selectItems(int...indices) {
197  1 driver.selectItems(target, indices);
198  1 return this;
199    }
200   
201    /**
202    * Simulates a user selecting the specified items in this fixture's <code>{@link JList}</code>. The items to select
203    * should match the given values.
204    * @param items the text of the items to select. Each <code>String</code> can be a regular expression.
205    * @return this fixture.
206    * @throws NullPointerException if the given array is <code>null</code>.
207    * @throws IllegalArgumentException if the given array is empty.
208    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
209    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
210    * @throws LocationUnavailableException if an element matching the any of the given values cannot be found.
211    * @see #cellReader(JListCellReader)
212    */
 
213  1 toggle public JListFixture selectItems(String...items) {
214  1 driver.selectItems(target, items);
215  1 return this;
216    }
217   
218    /**
219    * Simulates a user selecting the specified items in this fixture's <code>{@link JList}</code>. The items to select
220    * should select the given regular expression patterns.
221    * @param patterns the regular expression patterns to match.
222    * @return this fixture.
223    * @throws NullPointerException if the given array is <code>null</code>.
224    * @throws NullPointerException if any of the regular expression patterns is <code>null</code>.
225    * @throws IllegalArgumentException if the given array is empty.
226    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
227    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
228    * @throws LocationUnavailableException if an element matching the any of the given regular expression patterns cannot
229    * be found.
230    * @see #cellReader(JListCellReader)
231    * @since 1.2
232    */
 
233  1 toggle public JListFixture selectItems(Pattern... patterns) {
234  1 driver.selectItems(target, patterns);
235  1 return this;
236    }
237   
238    /**
239    * Simulates a user selecting an item in this fixture's <code>{@link JList}</code>.
240    * @param index the index of the item to select.
241    * @return this fixture.
242    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
243    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
244    * @throws IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in the
245    * <code>JList</code>.
246    * @see #item(int)
247    * @see JListItemFixture#select()
248    */
 
249  1 toggle public JListFixture selectItem(int index) {
250  1 driver.selectItem(target, index);
251  1 return this;
252    }
253   
254    /**
255    * Simulates a user selecting an item in this fixture's <code>{@link JList}</code>.
256    * @param text the text of the item to select. It can be a regular expression.
257    * @return this fixture.
258    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
259    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
260    * @throws LocationUnavailableException if an element matching the given text cannot be found.
261    * @see #item(String)
262    * @see JListItemFixture#select()
263    * @see #cellReader(JListCellReader)
264    */
 
265  2 toggle public JListFixture selectItem(String text) {
266  2 driver.selectItem(target, text);
267  2 return this;
268    }
269   
270    /**
271    * Simulates a user selecting an item in this fixture's <code>{@link JList}</code>. The value of the item to select
272    * must match the given regular expression pattern.
273    * @param pattern the regular expression pattern to match.
274    * @return this fixture.
275    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
276    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
277    * @throws LocationUnavailableException if an element matching the given text cannot be found.
278    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
279    * @see #item(Pattern)
280    * @see JListItemFixture#select()
281    * @see #cellReader(JListCellReader)
282    * @since 1.2
283    */
 
284  1 toggle public JListFixture selectItem(Pattern pattern) {
285  1 driver.selectItem(target, pattern);
286  1 return this;
287    }
288   
289    /**
290    * Simulates a user clicking an item in this fixture's <code>{@link JList}</code>.
291    * @param index the index of the item to clicking.
292    * @return this fixture.
293    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
294    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
295    * @throws IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in the
296    * <code>JList</code>.
297    * @see #item(int)
298    * @see JListItemFixture#click()
299    * @since 1.2
300    */
 
301  1 toggle public JListFixture clickItem(int index) {
302  1 driver.clickItem(target, index, LEFT_BUTTON, 1);
303  1 return this;
304    }
305   
306    /**
307    * Simulates a user clicking an item in this fixture's <code>{@link JList}</code>.
308    * @param text the text of the item to select. It can be a regular expression.
309    * @return this fixture.
310    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
311    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
312    * @throws LocationUnavailableException if an element matching the given text cannot be found.
313    * @see #item(String)
314    * @see JListItemFixture#select()
315    * @see #cellReader(JListCellReader)
316    * @since 1.2
317    */
 
318  1 toggle public JListFixture clickItem(String text) {
319  1 driver.clickItem(target, text, LEFT_BUTTON, 1);
320  1 return this;
321    }
322   
323    /**
324    * Simulates a user clicking an item in this fixture's <code>{@link JList}</code>. The value of the item to select
325    * must match the given regular expression pattern.
326    * @param pattern the regular expression pattern to match.
327    * @return this fixture.
328    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
329    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
330    * @throws LocationUnavailableException if an element matching the given text cannot be found.
331    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
332    * @see #item(Pattern)
333    * @see JListItemFixture#select()
334    * @see #cellReader(JListCellReader)
335    * @since 1.2
336    */
 
337  1 toggle public JListFixture clickItem(Pattern pattern) {
338  1 driver.clickItem(target, pattern, LEFT_BUTTON, 1);
339  1 return this;
340    }
341   
342    /**
343    * Simulates a user double-clicking an item in this fixture's <code>{@link JList}</code>.
344    * @param index the index of the item to double-click.
345    * @return this fixture.
346    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
347    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
348    * @throws IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in
349    * the <code>JList</code>.
350    * @deprecated to be removed in version 2.0. Use <code>{@link #item(int)}</code> and
351    * <code>{@link JListItemFixture#doubleClick()}</code> instead.
352    */
 
353    toggle @Deprecated
354    public JListFixture doubleClickItem(int index) {
355    clickItem(index, LEFT_BUTTON, 2);
356    return this;
357    }
358   
359    /**
360    * Simulates a user double-clicking an item in this fixture's <code>{@link JList}</code>.
361    * @param text the text of the item to double-click.
362    * @return this fixture.
363    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
364    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
365    * @throws LocationUnavailableException if an element matching the given <code>String</code> cannot be found.
366    * @deprecated to be removed in version 2.0. Use <code>{@link #item(String)}</code> and
367    * <code>{@link JListItemFixture#doubleClick()}</code> instead.
368    */
 
369    toggle @Deprecated
370    public JListFixture doubleClickItem(String text) {
371    driver.clickItem(target, text, LEFT_BUTTON, 2);
372    return this;
373    }
374   
 
375  0 toggle void clickItem(int index, MouseButton button, int times) {
376  0 driver.clickItem(target, index, button, times);
377    }
378   
379    /**
380    * Simulates a user clicking this fixture's <code>{@link JList}</code>.
381    * @return this fixture.
382    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
383    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
384    */
 
385  1 toggle public JListFixture click() {
386  1 driver.click(target);
387  1 return this;
388    }
389   
390    /**
391    * Simulates a user clicking this fixture's <code>{@link JList}</code>.
392    * @param button the button to click.
393    * @return this fixture.
394    * @throws NullPointerException if the given <code>MouseButton</code> is <code>null</code>.
395    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
396    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
397    */
 
398  1 toggle public JListFixture click(MouseButton button) {
399  1 driver.click(target, button);
400  1 return this;
401    }
402   
403    /**
404    * Simulates a user clicking this fixture's <code>{@link JList}</code>.
405    * @param mouseClickInfo specifies the button to click and the times the button should be clicked.
406    * @return this fixture.
407    * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>.
408    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
409    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
410    */
 
411  1 toggle public JListFixture click(MouseClickInfo mouseClickInfo) {
412  1 driver.click(target, mouseClickInfo);
413  1 return this;
414    }
415   
416    /**
417    * Simulates a user double-clicking this fixture's <code>{@link JList}</code>.
418    * @return this fixture.
419    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
420    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
421    */
 
422  1 toggle public JListFixture doubleClick() {
423  1 driver.doubleClick(target);
424  1 return this;
425    }
426   
427    /**
428    * Simulates a user right-clicking this fixture's <code>{@link JList}</code>.
429    * @return this fixture.
430    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
431    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
432    */
 
433  1 toggle public JListFixture rightClick() {
434  1 driver.rightClick(target);
435  1 return this;
436    }
437   
438    /**
439    * Gives input focus to this fixture's <code>{@link JList}</code>.
440    * @return this fixture.
441    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
442    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
443    */
 
444  1 toggle public JListFixture focus() {
445  1 driver.focus(target);
446  1 return this;
447    }
448   
449    /**
450    * Simulates a user pressing given key with the given modifiers on this fixture's <code>{@link JList}</code>.
451    * Modifiers is a mask from the available <code>{@link java.awt.event.InputEvent}</code> masks.
452    * @param keyPressInfo specifies the key and modifiers to press.
453    * @return this fixture.
454    * @throws NullPointerException if the given <code>KeyPressInfo</code> is <code>null</code>.
455    * @throws IllegalArgumentException if the given code is not a valid key code.
456    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
457    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
458    * @see KeyPressInfo
459    */
 
460  1 toggle public JListFixture pressAndReleaseKey(KeyPressInfo keyPressInfo) {
461  1 driver.pressAndReleaseKey(target, keyPressInfo);
462  1 return this;
463    }
464   
465    /**
466    * Simulates a user pressing and releasing the given keys on this fixture's <code>{@link JList}</code>.
467    * @param keyCodes one or more codes of the keys to press.
468    * @return this fixture.
469    * @throws NullPointerException if the given array of codes is <code>null</code>.
470    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
471    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
472    * @see java.awt.event.KeyEvent
473    */
 
474  1 toggle public JListFixture pressAndReleaseKeys(int... keyCodes) {
475  1 driver.pressAndReleaseKeys(target, keyCodes);
476  1 return this;
477    }
478   
479    /**
480    * Simulates a user pressing the given key on this fixture's <code>{@link JList}</code>.
481    * @param keyCode the code of the key to press.
482    * @return this fixture.
483    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
484    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
485    * @see java.awt.event.KeyEvent
486    */
 
487  1 toggle public JListFixture pressKey(int keyCode) {
488  1 driver.pressKey(target, keyCode);
489  1 return this;
490    }
491   
492    /**
493    * Simulates a user releasing the given key on this fixture's <code>{@link JList}</code>.
494    * @param keyCode the code of the key to release.
495    * @return this fixture.
496    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
497    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
498    * @see java.awt.event.KeyEvent
499    */
 
500  1 toggle public JListFixture releaseKey(int keyCode) {
501  1 driver.releaseKey(target, keyCode);
502  1 return this;
503    }
504   
505    /**
506    * Simulates a drag operation at the location of the first item in this fixture's <code>{@link JList}</code> matching
507    * the given value.
508    * @param text the text of the item to drag. It can be a regular expression.
509    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
510    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
511    * @throws LocationUnavailableException if an element matching the given text cannot be found.
512    * @return this fixture.
513    * @see #cellReader(JListCellReader)
514    */
 
515  1 toggle public JListFixture drag(String text) {
516  1 driver.drag(target, text);
517  1 return this;
518    }
519   
520    /**
521    * Ends a drag operation at the location of the first item matching the given value.
522    * @param text the text of the item to drop. It can be a regular expression.
523    * @return this fixture.
524    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
525    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
526    * @throws LocationUnavailableException if an element matching the given text cannot be found.
527    * @throws ActionFailedException if there is no drag action in effect.
528    */
 
529  1 toggle public JListFixture drop(String text) {
530  1 driver.drop(target, text);
531  1 return this;
532    }
533   
534    /**
535    * Simulates a drag operation at the location of the first item in this fixture's <code>{@link JList}</code> matching
536    * the given regular expression pattern.
537    * @param pattern the regular expression pattern to match.
538    * @return this fixture.
539    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
540    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
541    * @throws NullPointerException if the given regular expression pattern in <code>null</code>.
542    * @throws LocationUnavailableException if an element matching the given regular expression pattern cannot be found.
543    * @see #cellReader(JListCellReader)
544    * @since 1.2
545    */
 
546  1 toggle public JListFixture drag(Pattern pattern) {
547  1 driver.drag(target, pattern);
548  1 return this;
549    }
550   
551    /**
552    * Ends a drag operation at the location of the first item matching the given regular expression pattern.
553    * @param pattern the regular expression pattern to match.
554    * @return this fixture.
555    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
556    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
557    * @throws NullPointerException if the given regular expression pattern in <code>null</code>.
558    * @throws LocationUnavailableException if an element matching the given text cannot be found.
559    * @throws ActionFailedException if there is no drag action in effect.
560    * @see #cellReader(JListCellReader)
561    * @since 1.2
562    */
 
563  1 toggle public JListFixture drop(Pattern pattern) {
564  1 driver.drop(target, pattern);
565  1 return this;
566    }
567   
568    /**
569    * Simulates a user dropping an item at the center of this fixture's <code>{@link JList}</code>.
570    * @return this fixture.
571    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
572    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
573    * @throws ActionFailedException if there is no drag action in effect.
574    */
 
575  1 toggle public JListFixture drop() {
576  1 driver.drop(target);
577  1 return this;
578    }
579   
580    /**
581    * Simulates a user dragging an item from this fixture's <code>{@link JList}</code>.
582    * @param index the index of the item to drag.
583    * @return this fixture.
584    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
585    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
586    * @throws IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in the
587    * <code>JList</code>.
588    */
 
589  1 toggle public JListFixture drag(int index) {
590  1 driver.drag(target, index);
591  1 return this;
592    }
593   
594    /**
595    * Simulates a user dropping an item to this fixture's <code>{@link JList}</code>.
596    * @param index the index of the item to drop.
597    * @return this fixture.
598    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
599    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
600    * @throws IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in the
601    * <code>JList</code>.
602    * @throws ActionFailedException if there is no drag action in effect.
603    */
 
604  1 toggle public JListFixture drop(int index) {
605  1 driver.drop(target, index);
606  1 return this;
607    }
608   
609    /**
610    * Shows a pop-up menu at the location of the specified item in this fixture's <code>{@link JList}</code>.
611    * @param index the index of the item.
612    * @return a fixture that manages the displayed pop-up menu.
613    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
614    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
615    * @throws ComponentLookupException if a pop-up menu cannot be found.
616    * @throws IndexOutOfBoundsException if the given index is negative or greater than the index of the last item in the
617    * <code>JList</code>.
618    */
 
619  1 toggle public JPopupMenuFixture showPopupMenuAt(int index) {
620  1 return new JPopupMenuFixture(robot, driver.showPopupMenu(target, index));
621    }
622   
623    /**
624    * Shows a pop-up menu at the location of the first item matching the given value in this fixture's
625    * <code>{@link JList}</code>.
626    * @param text the text of the item. It can be a regular expression.
627    * @return a fixture that manages the displayed pop-up menu.
628    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
629    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
630    * @throws ComponentLookupException if a pop-up menu cannot be found.
631    * @throws LocationUnavailableException if an element matching the given value cannot be found.
632    */
 
633  1 toggle public JPopupMenuFixture showPopupMenuAt(String text) {
634  1 return new JPopupMenuFixture(robot, driver.showPopupMenu(target, text));
635    }
636   
637    /**
638    * Shows a pop-up menu at the location of the first item matching the given regular expression pattern in this
639    * fixture's <code>{@link JList}</code>.
640    * @param pattern the regular expression pattern to match.
641    * @return a fixture that manages the displayed pop-up menu.
642    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
643    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
644    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
645    * @throws ComponentLookupException if a pop-up menu cannot be found.
646    * @throws LocationUnavailableException if an element matching the given value cannot be found.
647    * @since 1.2
648    */
 
649  1 toggle public JPopupMenuFixture showPopupMenuAt(Pattern pattern) {
650  1 return new JPopupMenuFixture(robot, driver.showPopupMenu(target, pattern));
651    }
652   
653    /**
654    * Asserts that this fixture's <code>{@link JList}</code> has input focus.
655    * @return this fixture.
656    * @throws AssertionError if this fixture's <code>JList</code> does not have input focus.
657    */
 
658  1 toggle public JListFixture requireFocused() {
659  1 driver.requireFocused(target);
660  1 return this;
661    }
662   
663    /**
664    * Asserts that this fixture's <code>{@link JList}</code> is enabled.
665    * @return this fixture.
666    * @throws AssertionError if this fixture's <code>JList</code> is disabled.
667    */
 
668  1 toggle public JListFixture requireEnabled() {
669  1 driver.requireEnabled(target);
670  1 return this;
671    }
672   
673    /**
674    * Asserts that this fixture's <code>{@link JList}</code> is enabled.
675    * @param timeout the time this fixture will wait for the component to be enabled.
676    * @return this fixture.
677    * @throws WaitTimedOutError if this fixture's <code>JList</code> is never enabled.
678    */
 
679  1 toggle public JListFixture requireEnabled(Timeout timeout) {
680  1 driver.requireEnabled(target, timeout);
681  1 return this;
682    }
683   
684    /**
685    * Asserts that this fixture's <code>{@link JList}</code> is not enabled.
686    * @return this fixture.
687    * @throws AssertionError if this fixture's <code>JList</code> is enabled.
688    */
 
689  1 toggle public JListFixture requireDisabled() {
690  1 driver.requireDisabled(target);
691  1 return this;
692    }
693   
694    /**
695    * Asserts that this fixture's <code>{@link JList}</code> is visible.
696    * @return this fixture.
697    * @throws AssertionError if this fixture's <code>JList</code> is not visible.
698    */
 
699  1 toggle public JListFixture requireVisible() {
700  1 driver.requireVisible(target);
701  1 return this;
702    }
703   
704    /**
705    * Asserts that this fixture's <code>{@link JList}</code> is not visible.
706    * @return this fixture.
707    * @throws AssertionError if this fixture's <code>JList</code> is visible.
708    */
 
709  1 toggle public JListFixture requireNotVisible() {
710  1 driver.requireNotVisible(target);
711  1 return this;
712    }
713   
714    /**
715    * Verifies that the <code>String</code> representation of the selected item in this fixture's
716    * <code>{@link JList}</code> matches the given text.
717    * @param text the text to match. It can be a regular expression pattern.
718    * @return this fixture.
719    * @throws AssertionError if the selected item does not match the given text.
720    * @see #cellReader(JListCellReader)
721    */
 
722  1 toggle public JListFixture requireSelection(String text) {
723  1 driver.requireSelection(target, text);
724  1 return this;
725    }
726   
727    /**
728    * Verifies that the <code>String</code> representation of the selected item in this fixture's
729    * <code>{@link JList}</code> matches the given regular expression pattern.
730    * @param pattern the regular expression pattern to match.
731    * @return this fixture.
732    * @throws AssertionError if the selected item does not match the given regular expression pattern.
733    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
734    * @see #cellReader(JListCellReader)
735    * @since 1.2
736    */
 
737  1 toggle public JListFixture requireSelection(Pattern pattern) {
738  1 driver.requireSelection(target, pattern);
739  1 return this;
740    }
741   
742    /**
743    * Verifies that the index of the selected item in this fixture's <code>{@link JList}</code> is equal to the given
744    * value.
745    * @param index the expected selection index.
746    * @return this fixture.
747    * @throws AssertionError if the selected index is not equal to the given one.
748    * @since 1.2
749    */
 
750  1 toggle public JListFixture requireSelection(int index) {
751  1 driver.requireSelection(target, index);
752  1 return this;
753    }
754   
755    /**
756    * Verifies that the <code>String</code> representations of the selected items in this fixture's
757    * <code>{@link JList}</code> match the given text items.
758    * @param items text items to match. Each <code>String</code> can be a regular expression.
759    * @return this fixture.
760    * @throws NullPointerException if the given array is <code>null</code>.
761    * @throws IllegalArgumentException if the given array is empty.
762    * @throws AssertionError if the selected items do not match the given text items.
763    * @see #cellReader(JListCellReader)
764    */
 
765  1 toggle public JListFixture requireSelectedItems(String... items) {
766  1 driver.requireSelectedItems(target, items);
767  1 return this;
768    }
769   
770    /**
771    * Verifies that the <code>String</code> representations of the selected items in this fixture's
772    * <code>{@link JList}</code> match the given regular expression patterns.
773    * @param patterns the regular expression patterns to match.
774    * @return this fixture.
775    * @throws NullPointerException if the given array is <code>null</code>.
776    * @throws IllegalArgumentException if the given array is empty.
777    * @throws NullPointerException if any of the patterns in the given array is <code>null</code>.
778    * @throws AssertionError if the selected items do not match the given regular expression patterns.
779    * @see #cellReader(JListCellReader)
780    * @since 1.2
781    */
 
782  1 toggle public JListFixture requireSelectedItems(Pattern[] patterns) {
783  1 driver.requireSelectedItems(target, patterns);
784  1 return this;
785    }
786   
787    /**
788    * Verifies that the given item indices are selected in this fixture's <code>{@link JList}</code>.
789    * @param indices the expected indices of the selected items.
790    * @return this fixture.
791    * @throws NullPointerException if the given array is <code>null</code>.
792    * @throws IllegalArgumentException if the given array is empty.
793    * @throws AssertionError if the selection in this fixture's <code>JList</code> does not match the given one.
794    * @since 1.2
795    */
 
796  1 toggle public JListFixture requireSelectedItems(int... indices) {
797  1 driver.requireSelectedItems(target, indices);
798  1 return this;
799    }
800   
801    /**
802    * Verifies that this fixture's <code>{@link JList}</code> does not have any selection.
803    * @return this fixture.
804    * @throws AssertionError if this fixture's <code>JList</code> has a selection.
805    */
 
806  1 toggle public JListFixture requireNoSelection() {
807  1 driver.requireNoSelection(target);
808  1 return this;
809    }
810   
811    /**
812    * Verifies that this fixture's <code>{@link JList}</code> has the expected number of items
813    * @param expected the expected number of items.
814    * @return this fixture.
815    * @throws AssertionError if the number of items in this fixture's <code>JList</code> is not equal to the expected
816    * one.
817    * @since 1.2
818    */
 
819  1 toggle public JListFixture requireItemCount(int expected) {
820  1 driver.requireItemCount(target, expected);
821  1 return this;
822    }
823   
824    /**
825    * Asserts that the toolTip in this fixture's <code>{@link JList}</code> matches the given value.
826    * @param expected the given value. It can be a regular expression.
827    * @return this fixture.
828    * @throws AssertionError if the toolTip in this fixture's <code>JList</code> does not match the given value.
829    * @since 1.2
830    */
 
831  1 toggle public JListFixture requireToolTip(String expected) {
832  1 driver.requireToolTip(target, expected);
833  1 return this;
834    }
835   
836    /**
837    * Asserts that the toolTip in this fixture's <code>{@link JList}</code> matches the given regular expression
838    * pattern.
839    * @param pattern the regular expression pattern to match.
840    * @return this fixture.
841    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
842    * @throws AssertionError if the toolTip in this fixture's <code>JList</code> does not match the given regular
843    * expression pattern.
844    * @since 1.2
845    */
 
846  1 toggle public JListFixture requireToolTip(Pattern pattern) {
847  1 driver.requireToolTip(target, pattern);
848  1 return this;
849    }
850   
851    /**
852    * Returns the client property stored in this fixture's <code>{@link JList}</code>, under the given key.
853    * @param key the key to use to retrieve the client property.
854    * @return the value of the client property stored under the given key, or <code>null</code> if the property was
855    * not found.
856    * @throws NullPointerException if the given key is <code>null</code>.
857    * @since 1.2
858    */
 
859  1 toggle public Object clientProperty(Object key) {
860  1 return driver.clientProperty(target, key);
861    }
862   
863    /**
864    * Shows a pop-up menu using this fixture's <code>{@link JList}</code> as the invoker of the pop-up menu.
865    * @return a fixture that manages the displayed pop-up menu.
866    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
867    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
868    * @throws ComponentLookupException if a pop-up menu cannot be found.
869    */
 
870  1 toggle public JPopupMenuFixture showPopupMenu() {
871  1 return new JPopupMenuFixture(robot, driver.invokePopupMenu(target));
872    }
873   
874    /**
875    * Shows a pop-up menu at the given point using this fixture's <code>{@link JList}</code> as the invoker of the pop-up
876    * menu.
877    * @param p the given point where to show the pop-up menu.
878    * @return a fixture that manages the displayed pop-up menu.
879    * @throws IllegalStateException if this fixture's <code>JList</code> is disabled.
880    * @throws IllegalStateException if this fixture's <code>JList</code> is not showing on the screen.
881    * @throws ComponentLookupException if a pop-up menu cannot be found.
882    */
 
883  1 toggle public JPopupMenuFixture showPopupMenuAt(Point p) {
884  1 return new JPopupMenuFixture(robot, driver.invokePopupMenu(target, p));
885    }
886   
887    /**
888    * Updates the implementation of <code>{@link JListCellReader}</code> to use when comparing internal values of
889    * this fixture's <code>{@link JList}</code> and the values expected in a test. The default implementation to use
890    * is <code>{@link BasicJListCellReader}</code>.
891    * @param cellReader the new <code>JListCellValueReader</code> to use.
892    * @return this fixture.
893    * @throws NullPointerException if <code>cellReader</code> is <code>null</code>.
894    */
 
895  1 toggle public JListFixture cellReader(JListCellReader cellReader) {
896  1 driver.cellReader(cellReader);
897  1 return this;
898    }
899    }