Lines 60-65
Link Here
|
60 |
import org.netbeans.junit.MockServices; |
60 |
import org.netbeans.junit.MockServices; |
61 |
import org.netbeans.junit.NbTestCase; |
61 |
import org.netbeans.junit.NbTestCase; |
62 |
import org.openide.util.HelpCtx; |
62 |
import org.openide.util.HelpCtx; |
|
|
63 |
import org.openide.util.ImageUtilities; |
63 |
import org.openide.util.Lookup; |
64 |
import org.openide.util.Lookup; |
64 |
import org.openide.util.Utilities; |
65 |
import org.openide.util.Utilities; |
65 |
import org.openide.util.actions.SystemAction; |
66 |
import org.openide.util.actions.SystemAction; |
Lines 77-86
Link Here
|
77 |
|
78 |
|
78 |
// colors of the testing images in this order: |
79 |
// colors of the testing images in this order: |
79 |
// (test recognizes the icon by the white/black colors in specified positions :-))) |
80 |
// (test recognizes the icon by the white/black colors in specified positions :-))) |
80 |
// testIcon.gif |
81 |
// FIRST EIGHT (original) SECOND EIGHT (selected) |
81 |
// testIcon_rollover.gif |
82 |
// 0 testIcon.gif 8 testIcon_selected.gif |
82 |
// testIcon_pressed.gif |
83 |
// 1 testIcon_rollover.gif 9 testIcon_rolloverSelected.gif |
83 |
// testIcon_disabled.gif |
84 |
// 2 testIcon_pressed.gif 10 --not-used-- |
|
|
85 |
// 3 testIcon_disabled.gif 11 testIcon_disabledSelected.gif |
86 |
// 4 testIcon24.gif 12 testIcon24_selected.gif |
87 |
// 5 testIcon24_rollover.gif 13 testIcon24_rolloverSelected.gif |
88 |
// 6 testIcon24_pressed.gif 14 --not-used-- |
89 |
// 7 testIcon24_disabled.gif 15 testIcon24_disabledSelected.gif |
84 |
private static int[][] RESULT_COLORS_00 = { |
90 |
private static int[][] RESULT_COLORS_00 = { |
85 |
{255, 255, 255}, |
91 |
{255, 255, 255}, |
86 |
{0, 0, 0}, |
92 |
{0, 0, 0}, |
Lines 90-95
Link Here
|
90 |
{0, 0, 0}, |
96 |
{0, 0, 0}, |
91 |
{255, 255, 255}, |
97 |
{255, 255, 255}, |
92 |
{0, 0, 0}, |
98 |
{0, 0, 0}, |
|
|
99 |
{255, 255, 255}, |
100 |
{0, 0, 0}, |
101 |
{255, 255, 255}, |
102 |
{0, 0, 0}, |
103 |
{255, 255, 255}, |
104 |
{0, 0, 0}, |
105 |
{255, 255, 255}, |
106 |
{0, 0, 0}, |
93 |
}; |
107 |
}; |
94 |
private static int[][] RESULT_COLORS_01 = { |
108 |
private static int[][] RESULT_COLORS_01 = { |
95 |
{255, 255, 255}, |
109 |
{255, 255, 255}, |
Lines 100-105
Link Here
|
100 |
{255, 255, 255}, |
114 |
{255, 255, 255}, |
101 |
{0, 0, 0}, |
115 |
{0, 0, 0}, |
102 |
{0, 0, 0}, |
116 |
{0, 0, 0}, |
|
|
117 |
{255, 255, 255}, |
118 |
{255, 255, 255}, |
119 |
{0, 0, 0}, |
120 |
{0, 0, 0}, |
121 |
{255, 255, 255}, |
122 |
{255, 255, 255}, |
123 |
{0, 0, 0}, |
124 |
{0, 0, 0}, |
103 |
}; |
125 |
}; |
104 |
private static int[][] RESULT_COLORS_11 = { |
126 |
private static int[][] RESULT_COLORS_11 = { |
105 |
{255, 255, 255}, |
127 |
{255, 255, 255}, |
Lines 110-115
Link Here
|
110 |
{0, 0, 0}, |
132 |
{0, 0, 0}, |
111 |
{0, 0, 0}, |
133 |
{0, 0, 0}, |
112 |
{0, 0, 0}, |
134 |
{0, 0, 0}, |
|
|
135 |
{255, 255, 255}, |
136 |
{255, 255, 255}, |
137 |
{255, 255, 255}, |
138 |
{255, 255, 255}, |
139 |
{0, 0, 0}, |
140 |
{0, 0, 0}, |
141 |
{0, 0, 0}, |
142 |
{0, 0, 0}, |
143 |
}; |
144 |
private static int[][] RESULT_COLORS_10 = { |
145 |
{255, 255, 255}, |
146 |
{255, 255, 255}, |
147 |
{255, 255, 255}, |
148 |
{255, 255, 255}, |
149 |
{255, 255, 255}, |
150 |
{255, 255, 255}, |
151 |
{255, 255, 255}, |
152 |
{255, 255, 255}, |
153 |
{0, 0, 0}, |
154 |
{0, 0, 0}, |
155 |
{0, 0, 0}, |
156 |
{0, 0, 0}, |
157 |
{0, 0, 0}, |
158 |
{0, 0, 0}, |
159 |
{0, 0, 0}, |
160 |
{0, 0, 0}, |
113 |
}; |
161 |
}; |
114 |
|
162 |
|
115 |
|
163 |
|
Lines 124-145
Link Here
|
124 |
public void testIconsAction() throws Exception { |
172 |
public void testIconsAction() throws Exception { |
125 |
JButton jb = new JButton(); |
173 |
JButton jb = new JButton(); |
126 |
Actions.connect(jb, new TestAction()); |
174 |
Actions.connect(jb, new TestAction()); |
127 |
|
175 |
|
128 |
Icon icon = jb.getIcon(); |
176 |
Icon icon = jb.getIcon(); |
129 |
assertNotNull(icon); |
177 |
assertNotNull(icon); |
130 |
checkIfLoadedCorrectIcon(icon, jb, 0, "Enabled icon"); |
178 |
checkIfLoadedCorrectIcon(icon, jb, 0, "Enabled icon"); |
131 |
|
179 |
|
132 |
Icon rolloverIcon = jb.getRolloverIcon(); |
180 |
Icon rolloverIcon = jb.getRolloverIcon(); |
133 |
assertNotNull(rolloverIcon); |
181 |
assertNotNull(rolloverIcon); |
134 |
checkIfLoadedCorrectIcon(rolloverIcon, jb, 1, "Rollover icon"); |
182 |
checkIfLoadedCorrectIcon(rolloverIcon, jb, 1, "Rollover icon"); |
135 |
|
183 |
|
136 |
Icon pressedIcon = jb.getPressedIcon(); |
184 |
Icon pressedIcon = jb.getPressedIcon(); |
137 |
assertNotNull(pressedIcon); |
185 |
assertNotNull(pressedIcon); |
138 |
checkIfLoadedCorrectIcon(pressedIcon, jb, 2, "Pressed icon"); |
186 |
checkIfLoadedCorrectIcon(pressedIcon, jb, 2, "Pressed icon"); |
139 |
|
187 |
|
140 |
Icon disabledIcon = jb.getDisabledIcon(); |
188 |
Icon disabledIcon = jb.getDisabledIcon(); |
141 |
assertNotNull(disabledIcon); |
189 |
assertNotNull(disabledIcon); |
142 |
checkIfLoadedCorrectIcon(disabledIcon, jb, 3, "Disabled icon"); |
190 |
checkIfLoadedCorrectIcon(disabledIcon, jb, 3, "Disabled icon"); |
|
|
191 |
|
192 |
Icon selectedIcon = jb.getSelectedIcon(); |
193 |
assertNotNull(selectedIcon); |
194 |
checkIfLoadedCorrectIcon(selectedIcon, jb, 8, "Selected icon"); |
195 |
|
196 |
Icon rolloverSelectedIcon = jb.getRolloverSelectedIcon(); |
197 |
assertNotNull(rolloverSelectedIcon); |
198 |
checkIfLoadedCorrectIcon(rolloverSelectedIcon, jb, 9, "RolloverSelected icon"); |
199 |
|
200 |
// no pressedSelected |
201 |
|
202 |
Icon disabledSelectedIcon = jb.getDisabledSelectedIcon(); |
203 |
assertNotNull(disabledSelectedIcon); |
204 |
checkIfLoadedCorrectIcon(disabledSelectedIcon, jb, 11, "DisabledSelected icon"); |
143 |
} |
205 |
} |
144 |
|
206 |
|
145 |
/** |
207 |
/** |
Lines 180-198
Link Here
|
180 |
|
242 |
|
181 |
Icon icon = jb.getIcon(); |
243 |
Icon icon = jb.getIcon(); |
182 |
assertNotNull(icon); |
244 |
assertNotNull(icon); |
183 |
checkIfLoadedCorrectIcon(icon, jb, 4, "Enabled icon"); |
245 |
checkIfLoadedCorrectIcon(icon, jb, 4, "Enabled icon24"); |
184 |
|
246 |
|
185 |
Icon rolloverIcon = jb.getRolloverIcon(); |
247 |
Icon rolloverIcon = jb.getRolloverIcon(); |
186 |
assertNotNull(rolloverIcon); |
248 |
assertNotNull(rolloverIcon); |
187 |
checkIfLoadedCorrectIcon(rolloverIcon, jb, 5, "Rollover icon"); |
249 |
checkIfLoadedCorrectIcon(rolloverIcon, jb, 5, "Rollover icon24"); |
188 |
|
250 |
|
189 |
Icon pressedIcon = jb.getPressedIcon(); |
251 |
Icon pressedIcon = jb.getPressedIcon(); |
190 |
assertNotNull(pressedIcon); |
252 |
assertNotNull(pressedIcon); |
191 |
checkIfLoadedCorrectIcon(pressedIcon, jb, 6, "Pressed icon"); |
253 |
checkIfLoadedCorrectIcon(pressedIcon, jb, 6, "Pressed icon24"); |
192 |
|
254 |
|
193 |
Icon disabledIcon = jb.getDisabledIcon(); |
255 |
Icon disabledIcon = jb.getDisabledIcon(); |
194 |
assertNotNull(disabledIcon); |
256 |
assertNotNull(disabledIcon); |
195 |
checkIfLoadedCorrectIcon(disabledIcon, jb, 7, "Disabled icon"); |
257 |
checkIfLoadedCorrectIcon(disabledIcon, jb, 7, "Disabled icon24"); |
|
|
258 |
|
259 |
Icon selectedIcon = jb.getSelectedIcon(); |
260 |
assertNotNull(selectedIcon); |
261 |
checkIfLoadedCorrectIcon(selectedIcon, jb, 12, "Selected icon24"); |
262 |
|
263 |
Icon rolloverSelectedIcon = jb.getRolloverSelectedIcon(); |
264 |
assertNotNull(rolloverSelectedIcon); |
265 |
checkIfLoadedCorrectIcon(rolloverSelectedIcon, jb, 13, "RolloverSelected icon24"); |
266 |
|
267 |
// no pressedSelected |
268 |
|
269 |
Icon disabledSelectedIcon = jb.getDisabledSelectedIcon(); |
270 |
assertNotNull(disabledSelectedIcon); |
271 |
checkIfLoadedCorrectIcon(disabledSelectedIcon, jb, 15, "DisabledSelected icon24"); |
272 |
} |
273 |
|
274 |
/** |
275 |
* Tests that "unknownIcon" is used if no iconBase |
276 |
*/ |
277 |
public void testToggleButtonUnknownIcon() throws Exception { |
278 |
AbstractButton b = new AlwaysEnabledAction.DefaultIconToggleButton(); |
279 |
Action action = new TestAction(); |
280 |
action.putValue("iconBase", null); |
281 |
Actions.connect(b, action); |
282 |
Icon icon = b.getIcon(); |
283 |
assertNotNull("null ToggleButton icon", icon); |
284 |
Icon expectedIcon = ImageUtilities.loadImageIcon("org/openide/awt/resources/unknown.gif", false); //NOI18N |
285 |
assertEquals("unkownIcon not used", expectedIcon, icon); |
196 |
} |
286 |
} |
197 |
|
287 |
|
198 |
/** |
288 |
/** |
Lines 437-442
Link Here
|
437 |
checkIfIconOk(icon, c, 0, 0, RESULT_COLORS_00[rowToCheck], nameOfIcon); |
527 |
checkIfIconOk(icon, c, 0, 0, RESULT_COLORS_00[rowToCheck], nameOfIcon); |
438 |
checkIfIconOk(icon, c, 0, 1, RESULT_COLORS_01[rowToCheck], nameOfIcon); |
528 |
checkIfIconOk(icon, c, 0, 1, RESULT_COLORS_01[rowToCheck], nameOfIcon); |
439 |
checkIfIconOk(icon, c, 1, 1, RESULT_COLORS_11[rowToCheck], nameOfIcon); |
529 |
checkIfIconOk(icon, c, 1, 1, RESULT_COLORS_11[rowToCheck], nameOfIcon); |
|
|
530 |
checkIfIconOk(icon, c, 1, 0, RESULT_COLORS_10[rowToCheck], nameOfIcon); |
440 |
} |
531 |
} |
441 |
|
532 |
|
442 |
/** |
533 |
/** |