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
52   372   28   1.86
0   121   0.54   28
28     1  
1    
 
  JSliderFixture       Line # 40 52 0% 28 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Jul 1, 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.Point;
19    import java.util.regex.Pattern;
20   
21    import javax.swing.JSlider;
22   
23    import org.fest.swing.core.*;
24    import org.fest.swing.driver.JSliderDriver;
25    import org.fest.swing.exception.ComponentLookupException;
26    import org.fest.swing.exception.WaitTimedOutError;
27    import org.fest.swing.timing.Timeout;
28   
29    /**
30    * Understands functional testing of <code>{@link JSlider}</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 Yvonne Wang
38    * @author Alex Ruiz
39    */
 
40    public class JSliderFixture extends ComponentFixture<JSlider> implements CommonComponentFixture,
41    JComponentFixture, JPopupMenuInvokerFixture {
42   
43    private JSliderDriver driver;
44   
45    /**
46    * Creates a new <code>{@link JSliderFixture}</code>.
47    * @param robot performs simulation of user events on the given <code>JSlider</code>.
48    * @param target the <code>JSlider</code> to be managed <code>{@link JSlider}</code> by this fixture.
49    * @throws NullPointerException if <code>robot</code> is <code>null</code>.
50    * @throws NullPointerException if <code>target</code> is <code>null</code>.
51    */
 
52  28 toggle public JSliderFixture(Robot robot, JSlider target) {
53  28 super(robot, target);
54  28 createDriver();
55    }
56   
57    /**
58    * Creates a new <code>{@link JSliderFixture}</code>.
59    * @param robot performs simulation of user events on a <code>JSlider</code>.
60    * @param sliderName the name of the <code>JSlider</code> to find using the given <code>Robot</code>.
61    * @throws NullPointerException if <code>robot</code> is <code>null</code>.
62    * @throws ComponentLookupException if a matching <code>JSlider</code> could not be found.
63    * @throws ComponentLookupException if more than one matching <code>JSlider</code> is found.
64    */
 
65  1 toggle public JSliderFixture(Robot robot, String sliderName) {
66  1 super(robot, sliderName, JSlider.class);
67  1 createDriver();
68    }
69   
 
70  29 toggle private void createDriver() {
71  29 driver(new JSliderDriver(robot));
72    }
73   
74    /**
75    * Sets the <code>{@link JSliderDriver}</code> to be used by this fixture.
76    * @param newDriver the new <code>JSliderDriver</code>.
77    * @throws NullPointerException if the given driver is <code>null</code>.
78    */
 
79  54 toggle protected final void driver(JSliderDriver newDriver) {
80  54 validateNotNull(newDriver);
81  53 driver = newDriver;
82    }
83   
84    /**
85    * Simulates a user sliding this fixture's <code>{@link JSlider}</code> to the given value.
86    * @param value the value to slide the <code>JSlider</code> to.
87    * @return this fixture.
88    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
89    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
90    * @throws IllegalArgumentException if the given position is not within the <code>JSlider</code> bounds.
91    */
 
92  1 toggle public JSliderFixture slideTo(int value) {
93  1 driver.slide(target, value);
94  1 return this;
95    }
96   
97    /**
98    * Simulates a user sliding this fixture's <code>{@link JSlider}</code> to its maximum value.
99    * @return this fixture.
100    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
101    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
102    */
 
103  1 toggle public JSliderFixture slideToMaximum() {
104  1 driver.slideToMaximum(target);
105  1 return this;
106    }
107   
108    /**
109    * Simulates a user sliding this fixture's <code>{@link JSlider}</code> to its minimum value.
110    * @return this fixture.
111    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
112    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
113    */
 
114  1 toggle public JSliderFixture slideToMinimum() {
115  1 driver.slideToMinimum(target);
116  1 return this;
117    }
118   
119    /**
120    * Simulates a user clicking this fixture's <code>{@link JSlider}</code>.
121    * @return this fixture.
122    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
123    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
124    */
 
125  1 toggle public JSliderFixture click() {
126  1 driver.click(target);
127  1 return this;
128    }
129   
130    /**
131    * Simulates a user clicking this fixture's <code>{@link JSlider}</code>.
132    * @param button the button to click.
133    * @return this fixture.
134    * @throws NullPointerException if the given <code>MouseButton</code> is <code>null</code>.
135    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
136    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
137    */
 
138  1 toggle public JSliderFixture click(MouseButton button) {
139  1 driver.click(target, button);
140  1 return this;
141    }
142   
143    /**
144    * Simulates a user clicking this fixture's <code>{@link JSlider}</code>.
145    * @param mouseClickInfo specifies the button to click and the times the button should be clicked.
146    * @return this fixture.
147    * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>.
148    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
149    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
150    */
 
151  1 toggle public JSliderFixture click(MouseClickInfo mouseClickInfo) {
152  1 driver.click(target, mouseClickInfo);
153  1 return this;
154    }
155   
156    /**
157    * Simulates a user double-clicking this fixture's <code>{@link JSlider}</code>.
158    * @return this fixture.
159    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
160    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
161    */
 
162  1 toggle public JSliderFixture doubleClick() {
163  1 driver.doubleClick(target);
164  1 return this;
165    }
166   
167    /**
168    * Simulates a user right-clicking this fixture's <code>{@link JSlider}</code>.
169    * @return this fixture.
170    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
171    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
172    */
 
173  1 toggle public JSliderFixture rightClick() {
174  1 driver.rightClick(target);
175  1 return this;
176    }
177   
178    /**
179    * Gives input focus to this fixture's <code>{@link JSlider}</code>.
180    * @return this fixture.
181    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
182    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
183    */
 
184  1 toggle public JSliderFixture focus() {
185  1 driver.focus(target);
186  1 return this;
187    }
188   
189    /**
190    * Simulates a user pressing given key with the given modifiers on this fixture's <code>{@link JSlider}</code>.
191    * Modifiers is a mask from the available <code>{@link java.awt.event.InputEvent}</code> masks.
192    * @param keyPressInfo specifies the key and modifiers to press.
193    * @return this fixture.
194    * @throws NullPointerException if the given <code>KeyPressInfo</code> is <code>null</code>.
195    * @throws IllegalArgumentException if the given code is not a valid key code.
196    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
197    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
198    * @see KeyPressInfo
199    */
 
200  1 toggle public JSliderFixture pressAndReleaseKey(KeyPressInfo keyPressInfo) {
201  1 driver.pressAndReleaseKey(target, keyPressInfo);
202  1 return this;
203    }
204   
205    /**
206    * Simulates a user pressing and releasing the given keys on this fixture's <code>{@link JSlider}</code>. This method
207    * does not affect the current focus.
208    * @param keyCodes one or more codes of the keys to press.
209    * @return this fixture.
210    * @throws NullPointerException if the given array of codes is <code>null</code>.
211    * @throws IllegalArgumentException if any of the given code is not a valid key code.
212    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
213    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
214    * @see java.awt.event.KeyEvent
215    */
 
216  1 toggle public JSliderFixture pressAndReleaseKeys(int... keyCodes) {
217  1 driver.pressAndReleaseKeys(target, keyCodes);
218  1 return this;
219    }
220   
221    /**
222    * Simulates a user pressing the given key on this fixture's <code>{@link JSlider}</code>.
223    * @param keyCode the code of the key to press.
224    * @return this fixture.
225    * @throws IllegalArgumentException if any of the given code is not a valid key code.
226    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
227    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
228    * @see java.awt.event.KeyEvent
229    */
 
230  1 toggle public JSliderFixture pressKey(int keyCode) {
231  1 driver.pressKey(target, keyCode);
232  1 return this;
233    }
234   
235    /**
236    * Simulates a user releasing the given key on this fixture's <code>{@link JSlider}</code>.
237    * @param keyCode the code of the key to release.
238    * @return this fixture.
239    * @throws IllegalArgumentException if any of the given code is not a valid key code.
240    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
241    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
242    * @see java.awt.event.KeyEvent
243    */
 
244  1 toggle public JSliderFixture releaseKey(int keyCode) {
245  1 driver.releaseKey(target, keyCode);
246  1 return this;
247    }
248   
249    /**
250    * Asserts that this fixture's <code>{@link JSlider}</code> has input focus.
251    * @return this fixture.
252    * @throws AssertionError if this fixture's <code>JSlider</code> does not have input focus.
253    */
 
254  1 toggle public JSliderFixture requireFocused() {
255  1 driver.requireFocused(target);
256  1 return this;
257    }
258   
259    /**
260    * Asserts that this fixture's <code>{@link JSlider}</code> is enabled.
261    * @return this fixture.
262    * @throws AssertionError is this fixture's <code>JSlider</code> is disabled.
263    */
 
264  1 toggle public JSliderFixture requireEnabled() {
265  1 driver.requireEnabled(target);
266  1 return this;
267    }
268   
269    /**
270    * Asserts that this fixture's <code>{@link JSlider}</code> is enabled.
271    * @param timeout the time this fixture will wait for the component to be enabled.
272    * @return this fixture.
273    * @throws WaitTimedOutError if this fixture's <code>JSlider</code> is never enabled.
274    */
 
275  1 toggle public JSliderFixture requireEnabled(Timeout timeout) {
276  1 driver.requireEnabled(target, timeout);
277  1 return this;
278    }
279   
280    /**
281    * Asserts that this fixture's <code>{@link JSlider}</code> is disabled.
282    * @return this fixture.
283    * @throws AssertionError is this fixture's <code>JSlider</code> is enabled.
284    */
 
285  1 toggle public JSliderFixture requireDisabled() {
286  1 driver.requireDisabled(target);
287  1 return this;
288    }
289   
290    /**
291    * Asserts that this fixture's <code>{@link JSlider}</code>.
292    * @return this fixture.
293    * @throws AssertionError if this fixture's <code>JSlider</code> is not visible.
294    */
 
295  1 toggle public JSliderFixture requireVisible() {
296  1 driver.requireVisible(target);
297  1 return this;
298    }
299   
300    /**
301    * Asserts that this fixture's <code>{@link JSlider}</code> is not visible.
302    * @return this fixture.
303    * @throws AssertionError if this fixture's <code>JSlider</code> is visible.
304    */
 
305  1 toggle public JSliderFixture requireNotVisible() {
306  1 driver.requireNotVisible(target);
307  1 return this;
308    }
309   
310    /**
311    * Asserts that the toolTip in this fixture's <code>{@link JSlider}</code> matches the given value.
312    * @param expected the given value. It can be a regular expression.
313    * @return this fixture.
314    * @throws AssertionError if the toolTip in this fixture's <code>JSlider</code> does not match the given value.
315    * @since 1.2
316    */
 
317  1 toggle public JSliderFixture requireToolTip(String expected) {
318  1 driver.requireToolTip(target, expected);
319  1 return this;
320    }
321   
322    /**
323    * Asserts that the toolTip in this fixture's <code>{@link JSlider}</code> matches the given regular expression
324    * pattern.
325    * @param pattern the regular expression pattern to match.
326    * @return this fixture.
327    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
328    * @throws AssertionError if the toolTip in this fixture's <code>JSlider</code> does not match the given regular
329    * expression pattern.
330    * @since 1.2
331    */
 
332  1 toggle public JSliderFixture requireToolTip(Pattern pattern) {
333  1 driver.requireToolTip(target, pattern);
334  1 return this;
335    }
336   
337    /**
338    * Returns the client property stored in this fixture's <code>{@link JSlider}</code>, under the given key.
339    * @param key the key to use to retrieve the client property.
340    * @return the value of the client property stored under the given key, or <code>null</code> if the property was
341    * not found.
342    * @throws NullPointerException if the given key is <code>null</code>.
343    * @since 1.2
344    */
 
345  1 toggle public Object clientProperty(Object key) {
346  1 return driver.clientProperty(target, key);
347    }
348   
349    /**
350    * Shows a pop-up menu using this fixture's <code>{@link JSlider}</code> as the invoker of the pop-up menu.
351    * @return a fixture that manages the displayed pop-up menu.
352    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
353    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
354    * @throws ComponentLookupException if a pop-up menu cannot be found.
355    */
 
356  1 toggle public JPopupMenuFixture showPopupMenu() {
357  1 return new JPopupMenuFixture(robot, driver.invokePopupMenu(target));
358    }
359   
360    /**
361    * Shows a pop-up menu at the given point using this fixture's <code>{@link JSlider}</code> as the invoker of the
362    * pop-up menu.
363    * @param p the given point where to show the pop-up menu.
364    * @return a fixture that manages the displayed pop-up menu.
365    * @throws IllegalStateException if this fixture's <code>JSlider</code> is disabled.
366    * @throws IllegalStateException if this fixture's <code>JSlider</code> is not showing on the screen.
367    * @throws ComponentLookupException if a pop-up menu cannot be found.
368    */
 
369  1 toggle public JPopupMenuFixture showPopupMenuAt(Point p) {
370  1 return new JPopupMenuFixture(robot, driver.invokePopupMenu(target, p));
371    }
372    }