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
4   90   4   1
0   25   1   4
4     1  
1    
 
  JPopupMenuDriver       Line # 42 4 0% 4 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Jan 31, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5    * 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 is distributed on
10    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11    * specific language governing permissions and limitations under the License.
12    *
13    * Copyright @2008-2010 the original author or authors.
14    */
15    package org.fest.swing.driver;
16   
17    import static org.fest.swing.driver.JPopupMenuElementsAsTextQuery.menuElementsAsText;
18   
19    import java.awt.Container;
20   
21    import javax.swing.JMenuItem;
22    import javax.swing.JPopupMenu;
23   
24    import org.fest.swing.annotation.RunsInEDT;
25    import org.fest.swing.core.GenericTypeMatcher;
26    import org.fest.swing.core.Robot;
27    import org.fest.swing.exception.ComponentLookupException;
28   
29    /**
30    * Understands functional testing of <code>{@link JPopupMenu}</code>s:
31    * <ul>
32    * <li>user input simulation</li>
33    * <li>state verification</li>
34    * <li>property value query</li>
35    * </ul>
36    * This class is intended for internal use only. Please use the classes in the package
37    * <code>{@link org.fest.swing.fixture}</code> in your tests.
38    *
39    * @author Yvonne Wang
40    * @author Alex Ruiz
41    */
 
42    public class JPopupMenuDriver extends JComponentDriver {
43   
44    /**
45    * Creates a new </code>{@link JPopupMenuDriver}</code>.
46    * @param robot the robot to use to simulate user input.
47    */
 
48  77 toggle public JPopupMenuDriver(Robot robot) {
49  77 super(robot);
50    }
51   
52    /**
53    * Returns the contents of the pop-up menu as a <code>String</code> array.
54    * @param popupMenu the target <code>JPopupMenu</code>.
55    * @return the contents of the pop-up menu as a <code>String</code> array.
56    */
 
57  1 toggle @RunsInEDT
58    public String[] menuLabelsOf(JPopupMenu popupMenu) {
59  1 return menuElementsAsText(popupMenu);
60    }
61   
62    /**
63    * Finds a <code>{@link JMenuItem}</code>, contained in the <code>{@link Container}</code>, which name matches
64    * the specified one.
65    * @param popupMenu the target <code>JPopupMenu</code>.
66    * @param name the name to match.
67    * @return the <code>JMenuItem</code> found.
68    * @throws ComponentLookupException if a <code>JMenuItem</code> having a matching name could not be found.
69    * @throws ComponentLookupException if more than one <code>JMenuItem</code> having a matching name is found.
70    */
 
71  1 toggle @RunsInEDT
72    public JMenuItem menuItem(JPopupMenu popupMenu, String name) {
73  1 return robot.finder().findByName(popupMenu, name, JMenuItem.class, false);
74    }
75   
76    /**
77    * Finds a <code>{@link JMenuItem}</code>, contained in the <code>{@link Container}</code>, that matches the
78    * specified search criteria.
79    * @param popupMenu the target <code>JPopupMenu</code>.
80    * @param matcher contains the search criteria for finding a <code>JMenuItem</code>.
81    * @return the <code>JMenuItem</code> found.
82    * @throws ComponentLookupException if a <code>JMenuItem</code> that matches the given search criteria could not be
83    * found.
84    * @throws ComponentLookupException if more than one <code>JMenuItem</code> that matches the given search criteria
85    * is found.
86    */
 
87  1 toggle public JMenuItem menuItem(JPopupMenu popupMenu, GenericTypeMatcher<? extends JMenuItem> matcher) {
88  1 return robot.finder().find(popupMenu, matcher);
89    }
90    }