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
32   248   16   2.13
2   72   0.5   15
15     1.07  
1    
 
  JTableHeaderFixture       Line # 40 32 0% 16 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Mar 16, 2008
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 @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.fixture;
17   
18    import java.util.regex.Pattern;
19   
20    import javax.swing.JPopupMenu;
21    import javax.swing.table.JTableHeader;
22   
23    import org.fest.swing.core.MouseClickInfo;
24    import org.fest.swing.core.Robot;
25    import org.fest.swing.driver.JTableHeaderDriver;
26    import org.fest.swing.exception.ComponentLookupException;
27    import org.fest.swing.exception.LocationUnavailableException;
28   
29    /**
30    * Understands functional testing of <code>{@link JTableHeader}</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 JTableHeaderFixture extends ComponentFixture<JTableHeader> implements JComponentFixture {
41   
42    private JTableHeaderDriver driver;
43   
44    /**
45    * Creates a new </code>{@link JTableHeaderFixture}</code>.
46    * @param robot performs simulation of user events on the given <code>JTableHeader</code>.
47    * @param target the <code>JTableHeader</code> to be managed by this fixture.
48    * @throws NullPointerException if <code>robot</code> is <code>null</code>.
49    * @throws NullPointerException if <code>target</code> is <code>null</code>.
50    */
 
51  20 toggle public JTableHeaderFixture(Robot robot, JTableHeader target) {
52  20 super(robot, target);
53  20 driver(new JTableHeaderDriver(robot));
54    }
55   
56    /**
57    * Sets the <code>{@link JTableHeaderDriver}</code> to be used by this fixture.
58    * @param newDriver the new <code>JTableHeaderDriver</code>.
59    * @throws NullPointerException if the given driver is <code>null</code>.
60    */
 
61  36 toggle protected final void driver(JTableHeaderDriver newDriver) {
62  36 validateNotNull(newDriver);
63  35 driver = newDriver;
64    }
65   
66    /**
67    * Simulates a user clicking the column under the given index, in this fixture's <code>{@link JTableHeader}</code>.
68    * @param index the index of the column to click.
69    * @return this fixture.
70    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
71    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
72    * @throws IndexOutOfBoundsException if the index is out of bounds.
73    */
 
74  4 toggle public JTableHeaderFixture clickColumn(int index) {
75  4 driver.clickColumn(target, index);
76  4 return this;
77    }
78   
79    /**
80    * Shows a pop-up menu using this fixture's <code>{@link JTableHeader}</code> as the invoker of the pop-up menu.
81    * @param columnIndex the index of the column where the pop-up menu will be displayed.
82    * @return a fixture that manages the displayed pop-up menu.
83    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
84    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
85    * @throws IndexOutOfBoundsException if the index is out of bounds.
86    * @throws ComponentLookupException if a pop-up menu cannot be found.
87    */
 
88  1 toggle public JPopupMenuFixture showPopupMenuAt(int columnIndex) {
89  1 JPopupMenu popupMenu = driver.showPopupMenu(target, columnIndex);
90  1 return new JPopupMenuFixture(robot, popupMenu);
91    }
92   
93    /**
94    * Shows a pop-up menu using this fixture's <code>{@link JTableHeader}</code> as the invoker of the pop-up menu.
95    * @param columnName the name of the column where the pop-up menu will be displayed. It can be a regular expression.
96    * @return a fixture that manages the displayed pop-up menu.
97    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
98    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
99    * @throws ComponentLookupException if a pop-up menu cannot be found.
100    */
 
101  1 toggle public JPopupMenuFixture showPopupMenuAt(String columnName) {
102  1 JPopupMenu popupMenu = driver.showPopupMenu(target, columnName);
103  1 return new JPopupMenuFixture(robot, popupMenu);
104    }
105   
106    /**
107    * Shows a pop-up menu using this fixture's <code>{@link JTableHeader}</code> as the invoker of the pop-up menu. The
108    * name of the column to use must match the given regular expression pattern.
109    * @param columnNamePattern the regular expression pattern to match.
110    * @return a fixture that manages the displayed pop-up menu.
111    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
112    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
113    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
114    * @throws ComponentLookupException if a pop-up menu cannot be found.
115    * @since 1.2
116    */
 
117  1 toggle public JPopupMenuFixture showPopupMenuAt(Pattern columnNamePattern) {
118  1 JPopupMenu popupMenu = driver.showPopupMenu(target, columnNamePattern);
119  1 return new JPopupMenuFixture(robot, popupMenu);
120    }
121   
122    /**
123    * Simulates a user clicking the column under the given index, in this fixture's <code>{@link JTableHeader}</code>,
124    * using the given mouse button, the given number of times.
125    * @param index the index of the column to click.
126    * @param mouseClickInfo specifies the mouse button to use and the number of times to click.
127    * @return this fixture.
128    * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>.
129    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
130    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
131    * @throws IndexOutOfBoundsException if the index is out of bounds.
132    */
 
133  2 toggle public JTableHeaderFixture clickColumn(int index, MouseClickInfo mouseClickInfo) {
134  2 validateNotNull(mouseClickInfo);
135  1 driver.clickColumn(target, index, mouseClickInfo.button(), mouseClickInfo.times());
136  1 return this;
137    }
138   
139    /**
140    * Simulates a user clicking the column which name matches the given value, in this fixture's
141    * <code>{@link JTableHeader}</code>.
142    * @param columnName the column name to match. It can be a regular expression.
143    * @return this fixture.
144    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
145    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
146    * @throws LocationUnavailableException if a column with a matching name cannot be found.
147    */
 
148  1 toggle public JTableHeaderFixture clickColumn(String columnName) {
149  1 driver.clickColumn(target, columnName);
150  1 return this;
151    }
152   
153    /**
154    * Simulates a user clicking the column which name matches the given regular expression pattern, in this fixture's
155    * <code>{@link JTableHeader}</code>.
156    * @param columnNamePattern the regular expression pattern to match.
157    * @return this fixture.
158    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
159    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
160    * @throws NullPointerException if the given regular expression is <code>null</code>.
161    * @throws LocationUnavailableException if a column with a matching name cannot be found.
162    * @since 1.2
163    */
 
164  1 toggle public JTableHeaderFixture clickColumn(Pattern columnNamePattern) {
165  1 driver.clickColumn(target, columnNamePattern);
166  1 return this;
167    }
168   
169    /**
170    * Simulates a user clicking the column which name matches the given one, in this fixture's
171    * <code>{@link JTableHeader}</code>, using the given mouse button, the given number of times.
172    * @param columnName the column name to match. It can be a regular expression.
173    * @param mouseClickInfo specifies the mouse button to use and the number of times to click.
174    * @return this fixture.
175    * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>.
176    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
177    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
178    * @throws LocationUnavailableException if a column with a matching name cannot be found.
179    */
 
180  2 toggle public JTableHeaderFixture clickColumn(String columnName, MouseClickInfo mouseClickInfo) {
181  2 validateNotNull(mouseClickInfo);
182  1 driver.clickColumn(target, columnName, mouseClickInfo.button(), mouseClickInfo.times());
183  1 return this;
184    }
185   
186    /**
187    * Simulates a user clicking the column which name matches the given regular expression pattern, in this fixture's
188    * <code>{@link JTableHeader}</code>, using the given mouse button, the given number of times.
189    * @param columnNamePattern the regular expression pattern to match.
190    * @param mouseClickInfo specifies the mouse button to use and the number of times to click.
191    * @return this fixture.
192    * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>.
193    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is disabled.
194    * @throws IllegalStateException if this fixture's <code>JTableHeader</code> is not showing on the screen.
195    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
196    * @throws LocationUnavailableException if a column with a matching name cannot be found.
197    * @since 1.2
198    */
 
199  2 toggle public JTableHeaderFixture clickColumn(Pattern columnNamePattern, MouseClickInfo mouseClickInfo) {
200  2 validateNotNull(mouseClickInfo);
201  1 driver.clickColumn(target, columnNamePattern, mouseClickInfo.button(), mouseClickInfo.times());
202  1 return this;
203    }
204   
 
205  6 toggle private void validateNotNull(MouseClickInfo mouseClickInfo) {
206  3 if (mouseClickInfo == null) throw new NullPointerException("The given MouseClickInfo should not be null");
207    }
208   
209   
210    /**
211    * Asserts that the toolTip in this fixture's <code>{@link JTableHeader}</code> matches the given value.
212    * @param expected the given value. It can be a regular expression.
213    * @return this fixture.
214    * @throws AssertionError if the toolTip in this fixture's <code>JTableHeader</code> does not match the given value.
215    * @since 1.2
216    */
 
217  1 toggle public JTableHeaderFixture requireToolTip(String expected) {
218  1 driver.requireToolTip(target, expected);
219  1 return this;
220    }
221   
222    /**
223    * Asserts that the toolTip in this fixture's <code>{@link JTableHeader}</code> matches the given regular expression
224    * pattern.
225    * @param pattern the regular expression pattern to match.
226    * @return this fixture.
227    * @throws NullPointerException if the given regular expression pattern is <code>null</code>.
228    * @throws AssertionError if the toolTip in this fixture's <code>JTableHeader</code> does not match the given regular
229    * expression.
230    * @since 1.2
231    */
 
232  1 toggle public JTableHeaderFixture requireToolTip(Pattern pattern) {
233  1 driver.requireToolTip(target, pattern);
234  1 return this;
235    }
236   
237    /**
238    * Returns the client property stored in this fixture's <code>{@link JTableHeader}</code>, under the given key.
239    * @param key the key to use to retrieve the client property.
240    * @return the value of the client property stored under the given key, or <code>null</code> if the property was
241    * not found.
242    * @throws NullPointerException if the given key is <code>null</code>.
243    * @since 1.2
244    */
 
245  1 toggle public Object clientProperty(Object key) {
246  1 return driver.clientProperty(target, key);
247    }
248    }