1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
package jalview.gui; |
23 |
|
|
24 |
|
import java.awt.Component; |
25 |
|
import java.awt.Dimension; |
26 |
|
|
27 |
|
import javax.swing.Icon; |
28 |
|
import javax.swing.JDesktopPane; |
29 |
|
import javax.swing.JFrame; |
30 |
|
import javax.swing.JPanel; |
31 |
|
|
32 |
|
import org.testng.Assert; |
33 |
|
import org.testng.annotations.BeforeClass; |
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (50) |
Complexity: 8 |
Complexity Density: 0.19 |
|
36 |
|
public class JvOptionPaneTest |
37 |
|
{ |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
39 |
1 |
@BeforeClass(alwaysRun = true)... |
40 |
|
public void setUpJvOptionPane() |
41 |
|
{ |
42 |
1 |
JvOptionPane.setInteractiveMode(false); |
43 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
44 |
|
} |
45 |
|
|
46 |
|
Component parentComponent = null; |
47 |
|
|
48 |
|
String message = "Hello World!"; |
49 |
|
|
50 |
|
String title = "Title"; |
51 |
|
|
52 |
|
int optionType = JvOptionPane.OK_CANCEL_OPTION; |
53 |
|
|
54 |
|
int messageType = JvOptionPane.INFORMATION_MESSAGE; |
55 |
|
|
56 |
|
Icon icon = null; |
57 |
|
|
58 |
|
Object initialSelectionValue = null; |
59 |
|
|
60 |
|
Object[] selectionValues = null; |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
62 |
1 |
@Test(groups = { "Functional" })... |
63 |
|
public void showConfirmDialogFamilyTest() |
64 |
|
{ |
65 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message); |
66 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message, title, |
67 |
|
optionType); |
68 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message, title, |
69 |
|
optionType, messageType); |
70 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message, title, |
71 |
|
optionType, messageType, icon); |
72 |
1 |
Assert.assertTrue(true); |
73 |
|
} |
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
75 |
1 |
@Test(groups = { "Functional" })... |
76 |
|
public void showInputDialogFamilyTest() |
77 |
|
{ |
78 |
1 |
JvOptionPane.showInputDialog(message); |
79 |
1 |
JvOptionPane.showInputDialog(parentComponent, message); |
80 |
1 |
JvOptionPane.showInputDialog(message, initialSelectionValue); |
81 |
1 |
JvOptionPane.showInputDialog(parentComponent, message, |
82 |
|
initialSelectionValue); |
83 |
1 |
JvOptionPane.showInputDialog(parentComponent, message, title, |
84 |
|
messageType); |
85 |
1 |
JvOptionPane.showInputDialog(parentComponent, message, title, |
86 |
|
messageType, icon, selectionValues, initialSelectionValue); |
87 |
1 |
Assert.assertTrue(true); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
90 |
1 |
@Test(groups = { "Functional" })... |
91 |
|
public void showMessageDialogFamilyTest() |
92 |
|
{ |
93 |
1 |
JvOptionPane.showMessageDialog(parentComponent, message); |
94 |
1 |
JvOptionPane.showMessageDialog(parentComponent, message, title, |
95 |
|
messageType); |
96 |
1 |
JvOptionPane.showMessageDialog(parentComponent, message, title, |
97 |
|
messageType, icon); |
98 |
1 |
Assert.assertTrue(true); |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
101 |
1 |
@Test(groups = { "Functional" })... |
102 |
|
public void showInternalMessageDialogFamilyTest() |
103 |
|
{ |
104 |
1 |
JvOptionPane.showInternalMessageDialog(parentComponent, message); |
105 |
1 |
JvOptionPane.showInternalMessageDialog(parentComponent, message, title, |
106 |
|
messageType); |
107 |
1 |
JvOptionPane.showInternalMessageDialog(parentComponent, message, title, |
108 |
|
messageType, icon); |
109 |
1 |
Assert.assertTrue(true); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
112 |
1 |
@Test(groups = { "Functional" })... |
113 |
|
public void showInternalConfirmDialogFamilyTest() |
114 |
|
{ |
115 |
1 |
JvOptionPane.showInternalConfirmDialog(parentComponent, message, title, |
116 |
|
optionType); |
117 |
1 |
JvOptionPane.showInternalConfirmDialog(parentComponent, message, title, |
118 |
|
optionType, messageType); |
119 |
|
|
120 |
1 |
JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message); |
121 |
|
|
122 |
1 |
JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message, |
123 |
|
title, optionType, messageType, icon); |
124 |
1 |
JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message); |
125 |
1 |
JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message, |
126 |
|
title, messageType); |
127 |
1 |
JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message, |
128 |
|
title, messageType, icon, selectionValues, |
129 |
|
initialSelectionValue); |
130 |
1 |
Assert.assertTrue(true); |
131 |
|
|
132 |
|
} |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
134 |
5 |
private JDesktopPane getDummyDesktopPane()... |
135 |
|
{ |
136 |
5 |
JFrame frame = new JFrame("Dummy JDesktopPane"); |
137 |
5 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
138 |
5 |
@SuppressWarnings("serial") |
139 |
|
JDesktopPane jdpDesktop = new JDesktopPane() |
140 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
5 |
@Override... |
142 |
|
public Dimension getPreferredSize() |
143 |
|
{ |
144 |
5 |
return new Dimension(400, 300); |
145 |
|
} |
146 |
|
}; |
147 |
5 |
frame.setContentPane(jdpDesktop); |
148 |
5 |
JPanel panel = new JPanel(); |
149 |
5 |
panel.setBounds(0, 0, 400, 300); |
150 |
5 |
jdpDesktop.add(panel); |
151 |
5 |
frame.pack(); |
152 |
5 |
frame.setVisible(true); |
153 |
5 |
panel.setVisible(true); |
154 |
5 |
return jdpDesktop; |
155 |
|
} |
156 |
|
} |