| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 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 |
|
@link |
| 31 |
|
|
| 32 |
|
@author |
| 33 |
|
|
|
|
|
| 91.7% |
Uncovered Elements: 2 (24) |
Complexity: 7 |
Complexity Density: 0.5 |
|
| 34 |
|
class UnexpectedJOptionPaneFinder { |
| 35 |
|
|
| 36 |
|
static final ComponentMatcher OPTION_PANE_MATCHER = new TypeMatcher(JOptionPane.class, true); |
| 37 |
|
|
| 38 |
|
private final ComponentFinder finder; |
| 39 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
1592
|
UnexpectedJOptionPaneFinder(ComponentFinder finder) {... |
| 41 |
1592
|
this.finder = finder; |
| 42 |
|
} |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 44 |
4
|
@RunsInEDT... |
| 45 |
|
void requireNoJOptionPaneIsShowing() { |
| 46 |
4
|
List<Component> found = findAll(OPTION_PANE_MATCHER); |
| 47 |
2
|
if (!found.isEmpty()) throw unexpectedJOptionPanesFound(found); |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 50 |
4
|
private List<Component> findAll(ComponentMatcher m) {... |
| 51 |
4
|
return new ArrayList<Component>(finder.findAll(m)); |
| 52 |
|
} |
| 53 |
|
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 54 |
2
|
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 |
|
} |