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
25   196   14   1.79
0   63   0.56   14
14     1  
1    
 
  JTreeRowFixture       Line # 37 25 0% 14 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Dec 26, 2009
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 @2009-2010 the original author or authors.
15    */
16    package org.fest.swing.fixture;
17   
18    import javax.swing.JTree;
19   
20    import org.fest.swing.core.MouseButton;
21    import org.fest.swing.core.MouseClickInfo;
22    import org.fest.swing.exception.ActionFailedException;
23    import org.fest.swing.exception.ComponentLookupException;
24   
25    /**
26    * Understands functional testing of single nodes, referenced by their row indices, in <code>{@link JTree}</code>s:
27    * <ul>
28    * <li>user input simulation</li>
29    * <li>state verification</li>
30    * <li>property value query</li>
31    * </ul>
32    *
33    * @author Alex Ruiz
34    *
35    * @since 1.2
36    */
 
37    public class JTreeRowFixture implements JTreeNodeFixture {
38   
39    private final int index;
40    private final JTreeFixture tree;
41   
42    /**
43    * Creates a new </code>{@link JTreeRowFixture}</code>.
44    * @param tree handles the <code>JTree</code> containing the node with the given row index.
45    * @param index the given row index.
46    */
 
47  13 toggle protected JTreeRowFixture(JTreeFixture tree, int index) {
48  13 this.tree = tree;
49  13 this.index = index;
50    }
51   
52    /**
53    * Simulates a user expanding this fixture's tree node.
54    * @return this fixture.
55    * @throws IllegalStateException if the <code>JTree</code> is disabled.
56    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
57    * @throws ActionFailedException if this method fails to expand the row.
58    */
 
59  1 toggle public JTreeRowFixture expand() {
60  1 tree.expandRow(index);
61  1 return this;
62    }
63   
64    /**
65    * Simulates a user collapsing this fixture's tree node.
66    * @return this fixture.
67    * @throws IllegalStateException if the <code>JTree</code> is disabled.
68    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
69    * @throws ActionFailedException if this method fails to collapse the row.
70    */
 
71  1 toggle public JTreeRowFixture collapse() {
72  1 tree.collapseRow(index);
73  1 return this;
74    }
75   
76    /**
77    * Selects the this fixture's tree node, expanding parent nodes if necessary. This method will not click the node if
78    * it is already selected.
79    * @return this fixture.
80    * @throws IllegalStateException if this fixture's <code>JTree</code> is disabled.
81    * @throws IllegalStateException if this fixture's <code>JTree</code> is not showing on the screen.
82    */
 
83  1 toggle public JTreeRowFixture select() {
84  1 tree.selectRow(index);
85  1 return this;
86    }
87   
88    /**
89    * Simulates a user clicking this fixture's tree node.
90    * @return this fixture.
91    * @throws IllegalStateException if the <code>JTree</code> is disabled.
92    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
93    */
 
94  1 toggle public JTreeRowFixture click() {
95  1 tree.clickRow(index);
96  1 return this;
97    }
98   
99    /**
100    * Simulates a user clicking this fixture's tree node.
101    * @param button the button to click.
102    * @return this fixture.
103    * @throws NullPointerException if the given button is <code>null</code>.
104    * @throws IllegalStateException if the <code>JTree</code> is disabled.
105    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
106    */
 
107  1 toggle public JTreeRowFixture click(MouseButton button) {
108  1 tree.clickRow(index, button);
109  1 return this;
110    }
111   
112    /**
113    * Simulates a user clicking this fixture's tree node.
114    * @param mouseClickInfo specifies the button to click and the times the button should be clicked.
115    * @return this fixture.
116    * @throws NullPointerException if the given <code>MouseClickInfo</code> is <code>null</code>.
117    * @throws IllegalStateException if the <code>JTree</code> is disabled.
118    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
119    */
 
120  1 toggle public JTreeRowFixture click(MouseClickInfo mouseClickInfo) {
121  1 tree.clickRow(index, mouseClickInfo);
122  1 return this;
123    }
124   
125    /**
126    * Simulates a user double-clicking this fixture's tree node.
127    * @return this fixture.
128    * @throws IllegalStateException if the <code>JTree</code> is disabled.
129    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
130    */
 
131  1 toggle public JTreeRowFixture doubleClick() {
132  1 tree.doubleClickRow(index);
133  1 return this;
134    }
135   
136    /**
137    * Simulates a user right-clicking this fixture's tree node.
138    * @return this fixture.
139    * @throws IllegalStateException if the <code>JTree</code> is disabled.
140    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
141    */
 
142  1 toggle public JTreeRowFixture rightClick() {
143  1 tree.rightClickRow(index);
144  1 return this;
145    }
146   
147    /**
148    * Simulates a user dragging this fixture's tree node.
149    * @return this fixture.
150    * @throws IllegalStateException if the <code>JTree</code> is disabled.
151    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
152    */
 
153  1 toggle public JTreeRowFixture drag() {
154  1 tree.drag(index);
155  1 return this;
156    }
157   
158    /**
159    * Simulates a user dropping relative to this fixture's tree node.
160    * @return this fixture.
161    * @throws IllegalStateException if the <code>JTree</code> is disabled.
162    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
163    * @throws ActionFailedException if there is no drag action in effect.
164    */
 
165  1 toggle public JTreeRowFixture drop() {
166  1 tree.drop(index);
167  1 return this;
168    }
169   
170    /**
171    * Shows a pop-up menu using this fixture's tree node as the invoker of the pop-up menu.
172    * @return a fixture that handles functional testing of the displayed pop-up menu.
173    * @throws IllegalStateException if the <code>JTree</code> is disabled.
174    * @throws IllegalStateException if the <code>JTree</code> is not showing on the screen.
175    * @throws ComponentLookupException if a pop-up menu cannot be found.
176    */
 
177  1 toggle public JPopupMenuFixture showPopupMenu() {
178  1 return tree.showPopupMenuAt(index);
179    }
180   
181    /**
182    * Returns the <code>String</code> representation of this fixture's tree node.
183    * @return the <code>String</code> representation of this fixture's tree node.
184    */
 
185  1 toggle public String value() {
186  1 return tree.valueAt(index);
187    }
188   
189    /**
190    * Returns the row index of the node.
191    * @return the row index of the node.
192    */
 
193  1 toggle public int index() {
194  1 return index;
195    }
196    }