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
15   72   7   5
8   37   0.47   3
3     2.33  
1    
 
  JComboBoxDropDownListFinder       Line # 37 15 0% 7 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Oct 22, 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.timing.Pause.pause;
18    import static org.fest.swing.util.TimeoutWatch.startWatchWithTimeoutOf;
19   
20    import java.awt.Component;
21    import java.awt.Container;
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import javax.swing.*;
26   
27    import org.fest.swing.annotation.RunsInEDT;
28    import org.fest.swing.core.*;
29    import org.fest.swing.util.TimeoutWatch;
30   
31    /**
32    * Understands look up of the <code>{@link JList}</code> in the pop-up raised by a <code>{@link JComboBox}</code>, if
33    * the LAF actually uses one.
34    *
35    * @author Alex Ruiz
36    */
 
37    final class JComboBoxDropDownListFinder {
38   
39    static final ComponentMatcher LIST_MATCHER = new TypeMatcher(JList.class);
40   
41    private final Robot robot;
42   
 
43  294 toggle JComboBoxDropDownListFinder(Robot robot) {
44  294 this.robot = robot;
45    }
46   
47    /**
48    * Finds the <code>{@link JList}</code> in the pop-up raised by a <code>{@link JComboBox}</code>, if the LAF actually
49    * uses one.
50    * @return the found <code>JList</code>, or <code>null</code> if a drop-down list cannot be found.
51    */
 
52  16 toggle @RunsInEDT
53    JList findDropDownList() {
54  16 JPopupMenu popup = robot.findActivePopupMenu();
55  16 if (popup == null) {
56  2 TimeoutWatch watch = startWatchWithTimeoutOf(robot.settings().timeoutToFindPopup());
57  2 popup = robot.findActivePopupMenu();
58  9 while (popup == null) {
59  1 if (watch.isTimeOut()) return null;
60  7 pause();
61  7 popup = robot.findActivePopupMenu();
62    }
63    }
64  15 return findListIn(popup);
65    }
66   
 
67  15 toggle private JList findListIn(Container parent) {
68  15 List<Component> found = new ArrayList<Component>(robot.finder().findAll(parent, LIST_MATCHER));
69  1 if (found.size() != 1) return null;
70  14 return (JList)found.get(0);
71    }
72    }