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
14   65   7   3.5
6   34   0.5   4
4     1.75  
1    
 
  UnexpectedJOptionPaneFinder       Line # 34 14 0% 7 2 91.7% 0.9166667
 
No Tests
 
1    /*
2    * Created on Jun 2, 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.core;
17   
18    import static org.fest.assertions.Fail.fail;
19    import static org.fest.swing.format.Formatting.format;
20   
21    import java.awt.Component;
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import javax.swing.JOptionPane;
26   
27    import org.fest.swing.annotation.RunsInEDT;
28   
29    /**
30    * Understands how to find unexpected <code>{@link JOptionPane}</code>s.
31    *
32    * @author Alex Ruiz
33    */
 
34    class UnexpectedJOptionPaneFinder {
35   
36    static final ComponentMatcher OPTION_PANE_MATCHER = new TypeMatcher(JOptionPane.class, true);
37   
38    private final ComponentFinder finder;
39   
 
40  1592 toggle UnexpectedJOptionPaneFinder(ComponentFinder finder) {
41  1592 this.finder = finder;
42    }
43   
 
44  4 toggle @RunsInEDT
45    void requireNoJOptionPaneIsShowing() {
46  4 List<Component> found = findAll(OPTION_PANE_MATCHER);
47  2 if (!found.isEmpty()) throw unexpectedJOptionPanesFound(found);
48    }
49   
 
50  4 toggle private List<Component> findAll(ComponentMatcher m) {
51  4 return new ArrayList<Component>(finder.findAll(m));
52    }
53   
 
54  2 toggle private AssertionError unexpectedJOptionPanesFound(List<Component> found) {
55  2 StringBuilder message = new StringBuilder();
56  2 message.append("Expecting no JOptionPane to be showing, but found:<[");
57  2 int size = found.size();
58  4 for (int i = 0; i < size; i++) {
59  2 message.append(format(found.get(i)));
60  2 if (i != size - 1) message.append(", ");
61    }
62  2 message.append("]>");
63  2 throw fail(message.toString());
64    }
65    }