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 |
|
|
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
63 |
1 |
@Test(groups = { "Functional" })... |
64 |
|
public void showConfirmDialogFamilyTest() |
65 |
|
{ |
66 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message); |
67 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message, title, |
68 |
|
optionType); |
69 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message, title, |
70 |
|
optionType, messageType); |
71 |
1 |
JvOptionPane.showConfirmDialog(parentComponent, message, title, |
72 |
|
optionType, messageType, icon); |
73 |
1 |
Assert.assertTrue(true); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
76 |
1 |
@Test(groups = { "Functional" })... |
77 |
|
public void showInputDialogFamilyTest() |
78 |
|
{ |
79 |
1 |
JvOptionPane.showInputDialog(message); |
80 |
1 |
JvOptionPane.showInputDialog(parentComponent, message); |
81 |
1 |
JvOptionPane.showInputDialog(message, initialSelectionValue); |
82 |
1 |
JvOptionPane.showInputDialog(parentComponent, message, |
83 |
|
initialSelectionValue); |
84 |
1 |
JvOptionPane.showInputDialog(parentComponent, message, title, |
85 |
|
messageType); |
86 |
1 |
JvOptionPane.showInputDialog(parentComponent, message, title, |
87 |
|
messageType, icon, selectionValues, initialSelectionValue); |
88 |
1 |
Assert.assertTrue(true); |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
91 |
1 |
@Test(groups = { "Functional" })... |
92 |
|
public void showMessageDialogFamilyTest() |
93 |
|
{ |
94 |
1 |
JvOptionPane.showMessageDialog(parentComponent, message); |
95 |
1 |
JvOptionPane.showMessageDialog(parentComponent, message, title, |
96 |
|
messageType); |
97 |
1 |
JvOptionPane.showMessageDialog(parentComponent, message, title, |
98 |
|
messageType, icon); |
99 |
1 |
Assert.assertTrue(true); |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
102 |
1 |
@Test(groups = { "Functional" })... |
103 |
|
public void showInternalMessageDialogFamilyTest() |
104 |
|
{ |
105 |
1 |
JvOptionPane.showInternalMessageDialog(parentComponent, message); |
106 |
1 |
JvOptionPane.showInternalMessageDialog(parentComponent, message, title, |
107 |
|
messageType); |
108 |
1 |
JvOptionPane.showInternalMessageDialog(parentComponent, message, title, |
109 |
|
messageType, icon); |
110 |
1 |
Assert.assertTrue(true); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
113 |
1 |
@Test(groups = { "Functional" })... |
114 |
|
public void showInternalConfirmDialogFamilyTest() |
115 |
|
{ |
116 |
1 |
JvOptionPane.showInternalConfirmDialog(parentComponent, message, title, |
117 |
|
optionType); |
118 |
1 |
JvOptionPane.showInternalConfirmDialog(parentComponent, message, title, |
119 |
|
optionType, messageType); |
120 |
|
|
121 |
1 |
JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message); |
122 |
|
|
123 |
1 |
JvOptionPane.showInternalConfirmDialog(getDummyDesktopPane(), message, |
124 |
|
title, optionType, messageType, icon); |
125 |
1 |
JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message); |
126 |
1 |
JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message, |
127 |
|
title, messageType); |
128 |
1 |
JvOptionPane.showInternalInputDialog(getDummyDesktopPane(), message, |
129 |
|
title, messageType, icon, selectionValues, |
130 |
|
initialSelectionValue); |
131 |
1 |
Assert.assertTrue(true); |
132 |
|
|
133 |
|
} |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
135 |
5 |
private JDesktopPane getDummyDesktopPane()... |
136 |
|
{ |
137 |
5 |
JFrame frame = new JFrame("Dummy JDesktopPane"); |
138 |
5 |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
139 |
5 |
@SuppressWarnings("serial") |
140 |
|
JDesktopPane jdpDesktop = new JDesktopPane() |
141 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
5 |
@Override... |
143 |
|
public Dimension getPreferredSize() |
144 |
|
{ |
145 |
5 |
return new Dimension(400, 300); |
146 |
|
} |
147 |
|
}; |
148 |
5 |
frame.setContentPane(jdpDesktop); |
149 |
5 |
JPanel panel = new JPanel(); |
150 |
5 |
panel.setBounds(0, 0, 400, 300); |
151 |
5 |
jdpDesktop.add(panel); |
152 |
5 |
frame.pack(); |
153 |
5 |
frame.setVisible(true); |
154 |
5 |
panel.setVisible(true); |
155 |
5 |
return jdpDesktop; |
156 |
|
} |
157 |
|
} |