Pārlūkot izejas kodu

Unit test changes

Update FEST
Move UI test harness classes to plugins module
Fix a couple of broken ui unit tests

Change-Id: I12624ecd8c568294e06c304faf522bdc1da366c2
Reviewed-on: http://gerrit.dmdirc.com/454
Reviewed-by: Shane Mc Cormack <shane@dmdirc.com>
Tested-by: Shane Mc Cormack <shane@dmdirc.com>
tags/0.6.3
Chris Smith 14 gadus atpakaļ
vecāks
revīzija
2e7a2478e6

Binārs
lib/fest-assert-1.0a1.jar Parādīt failu


Binārs
lib/fest-assert-1.1.jar Parādīt failu


Binārs
lib/fest-reflect-0.4.jar Parādīt failu


Binārs
lib/fest-reflect-1.1.jar Parādīt failu


Binārs
lib/fest-swing-1.0b1.jar Parādīt failu


Binārs
lib/fest-swing-1.2a3.jar Parādīt failu


Binārs
lib/fest-swing-junit-1.0b1.jar Parādīt failu


Binārs
lib/fest-swing-junit-1.2a3.jar Parādīt failu


Binārs
lib/fest-util-0.4.jar Parādīt failu


Binārs
lib/fest-util-1.1.jar Parādīt failu


+ 2
- 0
test/com/dmdirc/addons/ui_swing/MainFrameTest.java Parādīt failu

@@ -51,7 +51,9 @@ public class MainFrameTest {
51 51
     @BeforeClass
52 52
     public static void setUpClass() throws InvalidIdentityFileException {
53 53
         IdentityManager.load();
54
+        IdentityManager.getAddonIdentity().setOption("test", "debugEDT", "false");
54 55
         controller = new SwingController();
56
+        controller.setDomain("test");
55 57
         controller.onLoad();
56 58
 
57 59
         Main.setUI(controller);

+ 16
- 16
test/com/dmdirc/addons/ui_swing/components/frames/InputTextFrameTest.java Parādīt failu

@@ -38,10 +38,9 @@ import com.dmdirc.plugins.PluginManager;
38 38
 
39 39
 import java.awt.event.KeyEvent;
40 40
 
41
-import org.fest.swing.core.EventMode;
42 41
 import org.fest.swing.core.KeyPressInfo;
43
-import org.fest.swing.core.matcher.DialogByTitleMatcher;
44
-import org.fest.swing.core.matcher.JButtonByTextMatcher;
42
+import org.fest.swing.core.matcher.DialogMatcher;
43
+import org.fest.swing.core.matcher.JButtonMatcher;
45 44
 import org.fest.swing.fixture.DialogFixture;
46 45
 import org.fest.swing.fixture.FrameFixture;
47 46
 import org.fest.swing.fixture.JInternalFrameFixture;
@@ -62,7 +61,9 @@ public class InputTextFrameTest {
62 61
     @BeforeClass
63 62
     public static void setUpClass() throws InvalidIdentityFileException {
64 63
         IdentityManager.load();
64
+        IdentityManager.getAddonIdentity().setOption("test", "debugEDT", "false");
65 65
         controller = new SwingController();
66
+        controller.setDomain("test");
66 67
         controller.onLoad();
67 68
         Main.setUI(controller);
68 69
         Main.ensureExists(PluginManager.getPluginManager(), "tabcompletion");
@@ -89,10 +90,10 @@ public class InputTextFrameTest {
89 90
     public void testPasteDialogContents() throws InterruptedException {
90 91
         ((InputTextFrame) window.target).doPaste("line1\nline2");
91 92
 
92
-        final DialogFixture dlg = mainframe.dialog(DialogByTitleMatcher
93
-                .withTitleAndShowing("Multi-line paste"));
93
+        final DialogFixture dlg = mainframe.dialog(DialogMatcher
94
+                .withTitle("Multi-line paste").andShowing());
94 95
 
95
-        dlg.requireVisible().button(JButtonByTextMatcher.withText("Edit")).click();
96
+        dlg.requireVisible().button(JButtonMatcher.withText("Edit")).click();
96 97
         dlg.textBox(new ClassFinder<TextAreaInputField>(TextAreaInputField.class, null))
97 98
                 .requireText("line1\nline2");
98 99
         dlg.target.dispose();
@@ -103,10 +104,10 @@ public class InputTextFrameTest {
103 104
         window.textBox().enterText("testing:");
104 105
         ((InputTextFrame) window.target).doPaste("line1\nline2");
105 106
 
106
-        final DialogFixture dlg = mainframe.dialog(DialogByTitleMatcher
107
-                .withTitleAndShowing("Multi-line paste"));
107
+        final DialogFixture dlg = mainframe.dialog(DialogMatcher
108
+                .withTitle("Multi-line paste").andShowing());
108 109
 
109
-        dlg.requireVisible().button(JButtonByTextMatcher.withText("Edit")).click();
110
+        dlg.requireVisible().button(JButtonMatcher.withText("Edit")).click();
110 111
         dlg.textBox(new ClassFinder<TextAreaInputField>(TextAreaInputField.class, null))
111 112
                 .requireText("testing:line1\nline2");
112 113
         dlg.target.dispose();
@@ -118,10 +119,10 @@ public class InputTextFrameTest {
118 119
                 KeyPressInfo.keyCode(KeyEvent.VK_HOME));
119 120
         ((InputTextFrame) window.target).doPaste("line1\nline2");
120 121
 
121
-        final DialogFixture dlg = mainframe.dialog(DialogByTitleMatcher
122
-                .withTitleAndShowing("Multi-line paste"));
122
+        final DialogFixture dlg = mainframe.dialog(DialogMatcher
123
+                .withTitle("Multi-line paste").andShowing());
123 124
 
124
-        dlg.requireVisible().button(JButtonByTextMatcher.withText("Edit")).click();
125
+        dlg.requireVisible().button(JButtonMatcher.withText("Edit")).click();
125 126
         dlg.textBox(new ClassFinder<TextAreaInputField>(TextAreaInputField.class, null))
126 127
                 .requireText("line1\nline2<- testing");
127 128
         dlg.target.dispose();
@@ -132,10 +133,10 @@ public class InputTextFrameTest {
132 133
         window.textBox().enterText("testing:<- testing").selectText(8, 8);
133 134
         ((InputTextFrame) window.target).doPaste("line1\nline2");
134 135
 
135
-        final DialogFixture dlg = mainframe.dialog(DialogByTitleMatcher
136
-                .withTitleAndShowing("Multi-line paste"));
136
+        final DialogFixture dlg = mainframe.dialog(DialogMatcher
137
+                .withTitle("Multi-line paste").andShowing());
137 138
 
138
-        dlg.requireVisible().button(JButtonByTextMatcher.withText("Edit")).click();
139
+        dlg.requireVisible().button(JButtonMatcher.withText("Edit")).click();
139 140
         dlg.textBox(new ClassFinder<TextAreaInputField>(TextAreaInputField.class, null))
140 141
                 .requireText("testing:line1\nline2<- testing");
141 142
         dlg.target.dispose();
@@ -145,7 +146,6 @@ public class InputTextFrameTest {
145 146
         UIUtilities.initUISettings();
146 147
 
147 148
         mainframe = new FrameFixture(controller.getMainWindow());
148
-        mainframe.robot.settings().eventMode(EventMode.AWT);
149 149
 
150 150
         final CustomInputFrame titf = new CustomInputFrame(owner,
151 151
                 GlobalCommandParser.getGlobalCommandParser(), controller);

+ 76
- 81
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionEditorDialogTest.java Parādīt failu

@@ -42,9 +42,8 @@ import javax.swing.JPanel;
42 42
 import javax.swing.JTextField;
43 43
 import javax.swing.text.JTextComponent;
44 44
 
45
-import org.fest.swing.core.EventMode;
46
-import org.fest.swing.core.matcher.JButtonByTextMatcher;
47
-import org.fest.swing.core.matcher.JLabelByTextMatcher;
45
+import org.fest.swing.core.matcher.JButtonMatcher;
46
+import org.fest.swing.core.matcher.JLabelMatcher;
48 47
 import org.fest.swing.fixture.DialogFixture;
49 48
 import org.fest.swing.fixture.JLabelFixture;
50 49
 import org.fest.swing.fixture.JPanelFixture;
@@ -60,14 +59,13 @@ public class ActionEditorDialogTest {
60 59
 
61 60
     @BeforeClass
62 61
     public static void setUpClass() throws InvalidIdentityFileException {
62
+        IdentityManager.load();
63 63
         Main.setUI(new SwingController());
64
+        ActionManager.init();
64 65
     }
65 66
 
66 67
     @Before
67 68
     public void setUp() throws InvalidIdentityFileException {
68
-        IdentityManager.load();
69
-        ActionManager.init();
70
-
71 69
         if (!ActionManager.getGroups().containsKey("amd-ui-test1")) {
72 70
             ActionManager.makeGroup("amd-ui-test1");
73 71
         }
@@ -88,9 +86,9 @@ public class ActionEditorDialogTest {
88 86
     public void testName() {
89 87
         setupWindow(null);
90 88
 
91
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
89
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
92 90
                 textBox().requireEnabled().requireEditable().requireEmpty();
93
-        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
91
+        window.button(JButtonMatcher.withText("OK")).requireDisabled();
94 92
     }
95 93
 
96 94
     @Test
@@ -99,27 +97,27 @@ public class ActionEditorDialogTest {
99 97
         // 'Fix' was disabling the add trigger button when name was invalid
100 98
         setupWindow(null);
101 99
 
102
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
100
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
103 101
                 textBox().requireEnabled().requireEditable().requireEmpty();
104
-        window.panel(new ClassFinder<JPanel>(ActionTriggersPanel.class, null)).
105
-                button(JButtonByTextMatcher.withText("Add")).requireDisabled();
102
+        window.panel(new ClassFinder<ActionTriggersPanel>(ActionTriggersPanel.class, null)).
103
+                button(JButtonMatcher.withText("Add")).requireDisabled();
106 104
     }
107 105
 
108 106
     @Test
109 107
     public void testTriggerWithNoArgs() {
110 108
         setupWindow(null);
111 109
 
112
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
110
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
113 111
                 textBox().enterText("test1");
114 112
         final JPanelFixture triggers = window.panel(
115
-                new ClassFinder<JPanel>(ActionTriggersPanel.class, null));
113
+                new ClassFinder<ActionTriggersPanel>(ActionTriggersPanel.class, null));
116 114
 
117 115
         triggers.comboBox().selectItem("Client closed");
118
-        triggers.button(JButtonByTextMatcher.withText("Add")).requireEnabled().
116
+        triggers.button(JButtonMatcher.withText("Add")).requireEnabled().
119 117
                 click();
120 118
 
121
-        window.panel(new ClassFinder<JPanel>(ActionConditionsPanel.class, null)).
122
-                button(JButtonByTextMatcher.withText("Add")).requireDisabled();
119
+        window.panel(new ClassFinder<ActionConditionsPanel>(ActionConditionsPanel.class, null)).
120
+                button(JButtonMatcher.withText("Add")).requireDisabled();
123 121
     }
124 122
 
125 123
     @Test
@@ -127,55 +125,55 @@ public class ActionEditorDialogTest {
127 125
         setupWindow(null);
128 126
 
129 127
         final JPanelFixture triggers = window.panel(
130
-                new ClassFinder<JPanel>(ActionTriggersPanel.class, null));
128
+                new ClassFinder<ActionTriggersPanel>(ActionTriggersPanel.class, null));
131 129
         triggers.comboBox().requireDisabled();
132 130
 
133
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
131
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
134 132
                 textBox().enterText("test1");
135 133
 
136 134
         final int items = triggers.comboBox().target.getItemCount();
137 135
         triggers.comboBox().requireEnabled().selectItem("Channel message received");
138
-        triggers.button(JButtonByTextMatcher.withText("Add")).requireEnabled().
136
+        triggers.button(JButtonMatcher.withText("Add")).requireEnabled().
139 137
                 click();
140 138
 
141 139
         final JLabelFixture label =
142
-                triggers.label(JLabelByTextMatcher.withText("Channel message received"));
140
+                triggers.label(JLabelMatcher.withText("Channel message received"));
143 141
         label.requireVisible();
144 142
 
145 143
         assertTrue(items > triggers.comboBox().target.getItemCount());
146
-        window.button(JButtonByTextMatcher.withText("OK")).requireEnabled();
144
+        window.button(JButtonMatcher.withText("OK")).requireEnabled();
147 145
 
148
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
146
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
149 147
                 textBox().deleteText();
150
-        triggers.button(new ClassFinder<JButton>(ImageButton.class, null)).
148
+        triggers.button(new ClassFinder<ImageButton>(ImageButton.class, null)).
151 149
                 requireDisabled();
152 150
         triggers.comboBox().requireDisabled();
153
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
151
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
154 152
                 textBox().enterText("test1");
155 153
 
156
-        triggers.button(new ClassFinder<JButton>(ImageButton.class, null)).
154
+        triggers.button(new ClassFinder<ImageButton>(ImageButton.class, null)).
157 155
                 requireEnabled().click();
158 156
 
159
-        for (Component comp : triggers.panel(new ClassFinder<JPanel>(ActionTriggersListPanel.class,
157
+        for (Component comp : triggers.panel(new ClassFinder<ActionTriggersListPanel>(ActionTriggersListPanel.class,
160 158
                 null)).target.getComponents()) {
161 159
             assertNotSame(label.target, comp);
162 160
         }
163 161
 
164 162
         assertEquals(items, triggers.comboBox().target.getItemCount());
165
-        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
163
+        window.button(JButtonMatcher.withText("OK")).requireDisabled();
166 164
     }
167 165
 
168 166
     @Test
169 167
     public void testBasicConditionTrees() {
170 168
         setupWindow(null);
171 169
 
172
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
170
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
173 171
                 textBox().enterText("test1");
174 172
         final JPanelFixture triggers = window.panel(
175
-                new ClassFinder<JPanel>(ActionTriggersPanel.class, null));
173
+                new ClassFinder<ActionTriggersPanel>(ActionTriggersPanel.class, null));
176 174
 
177 175
         triggers.comboBox().selectItem("Channel message received");
178
-        triggers.button(JButtonByTextMatcher.withText("Add")).requireEnabled().
176
+        triggers.button(JButtonMatcher.withText("Add")).requireEnabled().
179 177
                 click();
180 178
 
181 179
         window.radioButton(new JRadioButtonByTextMatcher("All of the conditions are true")).
@@ -184,78 +182,78 @@ public class ActionEditorDialogTest {
184 182
                 requireEnabled();
185 183
         window.radioButton(new JRadioButtonByTextMatcher("The conditions match a custom rule")).
186 184
                 requireEnabled();
187
-        window.panel(new ClassFinder<JPanel>(ActionConditionsTreePanel.class,
188
-                null)).textBox(new ClassFinder<JTextComponent>(JTextField.class,
185
+        window.panel(new ClassFinder<ActionConditionsTreePanel>(ActionConditionsTreePanel.class,
186
+                null)).textBox(new ClassFinder<JTextField>(JTextField.class,
189 187
                 null)).requireDisabled();
190 188
 
191
-        window.button(JButtonByTextMatcher.withText("OK")).requireEnabled();
189
+        window.button(JButtonMatcher.withText("OK")).requireEnabled();
192 190
 
193 191
         window.radioButton(new JRadioButtonByTextMatcher("The conditions match a custom rule")).
194 192
                 click().requireSelected();
195
-        window.panel(new ClassFinder<JPanel>(ActionConditionsTreePanel.class,
196
-                null)).textBox(new ClassFinder<JTextComponent>(JTextField.class,
193
+        window.panel(new ClassFinder<ActionConditionsTreePanel>(ActionConditionsTreePanel.class,
194
+                null)).textBox(new ClassFinder<JTextField>(JTextField.class,
197 195
                 null)).requireEnabled().enterText("invalid");
198 196
 
199
-        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
197
+        window.button(JButtonMatcher.withText("OK")).requireDisabled();
200 198
     }
201 199
 
202 200
     @Test
203 201
     public void testConditionText() {        
204 202
         setupWindow(null);
205 203
 
206
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
204
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
207 205
                 textBox().enterText("test1");
208 206
         final JPanelFixture triggers = window.panel(
209
-                new ClassFinder<JPanel>(ActionTriggersPanel.class, null));
207
+                new ClassFinder<ActionTriggersPanel>(ActionTriggersPanel.class, null));
210 208
 
211 209
         triggers.comboBox().selectItem("Channel message received");
212
-        triggers.button(JButtonByTextMatcher.withText("Add")).requireEnabled().
210
+        triggers.button(JButtonMatcher.withText("Add")).requireEnabled().
213 211
                 click();
214 212
 
215
-        window.panel(new ClassFinder<JPanel>(ActionConditionsPanel.class, null)).
216
-                button(JButtonByTextMatcher.withText("Add")).requireEnabled().
213
+        window.panel(new ClassFinder<ActionConditionsPanel>(ActionConditionsPanel.class, null)).
214
+                button(JButtonMatcher.withText("Add")).requireEnabled().
217 215
                 click();
218 216
         
219 217
         Pattern pattern = Pattern.compile(".+<body>(.+)</body>.+", Pattern.DOTALL);
220 218
         
221
-        Matcher matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
222
-                null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
219
+        Matcher matcher = pattern.matcher(window.panel(new ClassFinder<ActionConditionDisplayPanel>(ActionConditionDisplayPanel.class,
220
+                null)).textBox(new ClassFinder<TextLabel>(TextLabel.class,
223 221
                 null)).target.getText());
224 222
         matcher.find();
225 223
         assertEquals("<p style=\"margin-top: 0\">\n      \n    </p>", matcher.group(1).trim());
226 224
 
227
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
225
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
228 226
                 null)).comboBox("argument").selectItem("message");
229 227
         
230
-        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
231
-                null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
228
+        matcher = pattern.matcher(window.panel(new ClassFinder<ActionConditionDisplayPanel>(ActionConditionDisplayPanel.class,
229
+                null)).textBox(new ClassFinder<TextLabel>(TextLabel.class,
232 230
                 null)).target.getText());
233 231
         matcher.find();
234 232
         assertEquals("The message's ...", matcher.group(1).trim());
235 233
 
236
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
234
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
237 235
                 null)).comboBox("component").selectItem("content");
238 236
         
239
-        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
240
-                null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
237
+        matcher = pattern.matcher(window.panel(new ClassFinder<ActionConditionDisplayPanel>(ActionConditionDisplayPanel.class,
238
+                null)).textBox(new ClassFinder<TextLabel>(TextLabel.class,
241 239
                 null)).target.getText());
242 240
         matcher.find();
243 241
         assertEquals("The message's content ...", matcher.group(1).trim());
244 242
 
245
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
243
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
246 244
                 null)).comboBox("comparison").selectItem("contains");
247 245
         
248
-        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
249
-                null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
246
+        matcher = pattern.matcher(window.panel(new ClassFinder<ActionConditionDisplayPanel>(ActionConditionDisplayPanel.class,
247
+                null)).textBox(new ClassFinder<TextLabel>(TextLabel.class,
250 248
                 null)).target.getText());
251 249
         matcher.find();
252 250
         assertEquals("The message's content contains ''", matcher.group(1).trim());
253 251
 
254
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
252
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
255 253
                 null)).textBox().enterText("foo");
256 254
         
257
-        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
258
-                null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
255
+        matcher = pattern.matcher(window.panel(new ClassFinder<ActionConditionDisplayPanel>(ActionConditionDisplayPanel.class,
256
+                null)).textBox(new ClassFinder<TextLabel>(TextLabel.class,
259 257
                 null)).target.getText());
260 258
         matcher.find();
261 259
         assertEquals("The message's content contains 'foo'", matcher.group(1).trim());
@@ -265,60 +263,57 @@ public class ActionEditorDialogTest {
265 263
     public void testIllegalCondition() {
266 264
         setupWindow(null);
267 265
 
268
-        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
266
+        window.panel(new ClassFinder<ActionNamePanel>(ActionNamePanel.class, null)).
269 267
                 textBox().enterText("test1");
270 268
         final JPanelFixture triggers = window.panel(
271
-                new ClassFinder<JPanel>(ActionTriggersPanel.class, null));
269
+                new ClassFinder<ActionTriggersPanel>(ActionTriggersPanel.class, null));
272 270
 
273 271
         triggers.comboBox().selectItem("Channel message received");
274
-        triggers.button(JButtonByTextMatcher.withText("Add")).requireEnabled().
275
-                click();
272
+        triggers.button(JButtonMatcher.withText("Add")).requireEnabled().click();
276 273
 
277
-        window.button(JButtonByTextMatcher.withText("OK")).requireEnabled();
274
+        window.button(JButtonMatcher.withText("OK")).requireEnabled();
278 275
 
279
-        window.panel(new ClassFinder<JPanel>(ActionConditionsPanel.class, null)).
280
-                button(JButtonByTextMatcher.withText("Add")).requireEnabled().
281
-                click();
276
+        window.panel(new ClassFinder<ActionConditionsPanel>(ActionConditionsPanel.class, null)).
277
+                button(JButtonMatcher.withText("Add")).requireEnabled().click();
282 278
 
283
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
279
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
284 280
                 null)).comboBox("argument").requireEnabled();
285
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
281
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
286 282
                 null)).comboBox("component").requireDisabled();
287
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
283
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
288 284
                 null)).comboBox("comparison").requireDisabled();
289
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
285
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
290 286
                 null)).textBox().requireDisabled();
291
-        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
287
+        window.button(JButtonMatcher.withText("OK")).requireDisabled();
292 288
 
293
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
289
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
294 290
                 null)).comboBox("argument").selectItem("message");
295
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
291
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
296 292
                 null)).comboBox("component").requireEnabled();
297
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
293
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
298 294
                 null)).comboBox("comparison").requireDisabled();
299
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
295
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
300 296
                 null)).textBox().requireDisabled();
301
-        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
297
+        window.button(JButtonMatcher.withText("OK")).requireDisabled();
302 298
 
303
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
299
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
304 300
                 null)).comboBox("component").selectItem("content");
305
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
301
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
306 302
                 null)).comboBox("comparison").requireEnabled();
307
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
303
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
308 304
                 null)).textBox().requireDisabled();
309
-        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
305
+        window.button(JButtonMatcher.withText("OK")).requireDisabled();
310 306
 
311
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
307
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
312 308
                 null)).comboBox("comparison").selectItem("contains");
313
-        window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
309
+        window.panel(new ClassFinder<ActionConditionEditorPanel>(ActionConditionEditorPanel.class,
314 310
                 null)).textBox().requireEnabled();
315
-        window.button(JButtonByTextMatcher.withText("OK")).requireEnabled();
311
+        window.button(JButtonMatcher.withText("OK")).requireEnabled();
316 312
     }
317 313
 
318 314
     protected void setupWindow(final Action action) {
319 315
         window = new DialogFixture(ActionEditorDialog.getActionEditorDialog(null,
320 316
                 "amd-ui-test1", action));
321
-        window.robot.settings().eventMode(EventMode.AWT);
322 317
         window.show();
323 318
     }
324 319
 

+ 21
- 23
test/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialogTest.java Parādīt failu

@@ -34,11 +34,10 @@ import com.dmdirc.addons.ui_swing.dialogs.actioneditor.ActionEditorDialog;
34 34
 import java.lang.reflect.InvocationTargetException;
35 35
 
36 36
 import javax.swing.JPanel;
37
+import javax.swing.JTextField;
37 38
 import javax.swing.SwingUtilities;
38
-import javax.swing.text.JTextComponent;
39 39
 
40
-import org.fest.swing.core.EventMode;
41
-import org.fest.swing.core.matcher.JButtonByTextMatcher;
40
+import org.fest.swing.core.matcher.JButtonMatcher;
42 41
 import org.fest.swing.finder.JOptionPaneFinder;
43 42
 import org.fest.swing.finder.WindowFinder;
44 43
 import org.fest.swing.fixture.DialogFixture;
@@ -55,8 +54,8 @@ public class ActionsManagerDialogTest {
55 54
 
56 55
     @BeforeClass
57 56
     public static void setUpClass() throws InvalidIdentityFileException {
58
-        Main.setUI(new SwingController());
59 57
         IdentityManager.load();
58
+        Main.setUI(new SwingController());
60 59
         ActionManager.init();
61 60
     }
62 61
     
@@ -98,7 +97,7 @@ public class ActionsManagerDialogTest {
98 97
         setupWindow();
99 98
         
100 99
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
101
-                .button(JButtonByTextMatcher.withText("Add")).click();
100
+                .button(JButtonMatcher.withText("Add")).click();
102 101
         
103 102
         DialogFixture newwin = WindowFinder.findDialog(StandardInputDialog.class)
104 103
                 .withTimeout(5000).using(window.robot);
@@ -106,23 +105,23 @@ public class ActionsManagerDialogTest {
106 105
         newwin.requireVisible();
107 106
         assertEquals("New action group", newwin.target.getTitle());
108 107
         
109
-        newwin.button(JButtonByTextMatcher.withText("Cancel")).click();
108
+        newwin.button(JButtonMatcher.withText("Cancel")).click();
110 109
         
111 110
         newwin.requireNotVisible();
112 111
         
113 112
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
114
-                .button(JButtonByTextMatcher.withText("Add")).click();
113
+                .button(JButtonMatcher.withText("Add")).click();
115 114
         
116 115
         newwin = WindowFinder.findDialog(StandardInputDialog.class)
117 116
                 .withTimeout(5000).using(window.robot);
118 117
         
119 118
         newwin.requireVisible();
120
-        newwin.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
119
+        newwin.button(JButtonMatcher.withText("OK")).requireDisabled();
121 120
         
122
-        newwin.textBox(new ClassFinder<JTextComponent>(javax.swing.JTextField.class,
121
+        newwin.textBox(new ClassFinder<JTextField>(JTextField.class,
123 122
                 null)).enterText("amd-ui-test1");
124 123
         
125
-        newwin.button(JButtonByTextMatcher.withText("OK")).requireEnabled().click();
124
+        newwin.button(JButtonMatcher.withText("OK")).requireEnabled().click();
126 125
         
127 126
         window.list().requireSelectedItems("amd-ui-test1");
128 127
 
@@ -137,7 +136,7 @@ public class ActionsManagerDialogTest {
137 136
         window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
138 137
         
139 138
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
140
-                .button(JButtonByTextMatcher.withText("Delete")).requireEnabled().click();
139
+                .button(JButtonMatcher.withText("Delete")).requireEnabled().click();
141 140
         
142 141
         JOptionPaneFixture newwin = JOptionPaneFinder.findOptionPane()
143 142
                 .withTimeout(5000).using(window.robot);
@@ -147,7 +146,7 @@ public class ActionsManagerDialogTest {
147 146
         window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
148 147
         
149 148
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
150
-                .button(JButtonByTextMatcher.withText("Delete")).click();
149
+                .button(JButtonMatcher.withText("Delete")).click();
151 150
         
152 151
         newwin = JOptionPaneFinder.findOptionPane()
153 152
                 .withTimeout(5000).using(window.robot);
@@ -166,15 +165,15 @@ public class ActionsManagerDialogTest {
166 165
         
167 166
         window.list().selectItem("performs").requireSelectedItems("performs");
168 167
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
169
-                .button(JButtonByTextMatcher.withText("Delete")).requireDisabled();
168
+                .button(JButtonMatcher.withText("Delete")).requireDisabled();
170 169
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
171
-                .button(JButtonByTextMatcher.withText("Edit")).requireDisabled();
170
+                .button(JButtonMatcher.withText("Edit")).requireDisabled();
172 171
         
173 172
         window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
174 173
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
175
-                .button(JButtonByTextMatcher.withText("Delete")).requireEnabled();
174
+                .button(JButtonMatcher.withText("Delete")).requireEnabled();
176 175
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
177
-                .button(JButtonByTextMatcher.withText("Edit")).requireEnabled();
176
+                .button(JButtonMatcher.withText("Edit")).requireEnabled();
178 177
     }
179 178
 
180 179
     @Test
@@ -182,8 +181,8 @@ public class ActionsManagerDialogTest {
182 181
         ActionManager.makeGroup("amd-ui-test1");
183 182
         setupWindow();
184 183
         window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
185
-        window.panel(new ClassFinder<JPanel>(ActionsGroupPanel.class, null))
186
-                .button(JButtonByTextMatcher.withText("Add")).click();
184
+        window.panel(new ClassFinder<ActionsGroupPanel>(ActionsGroupPanel.class, null))
185
+                .button(JButtonMatcher.withText("Add")).click();
187 186
 
188 187
         DialogFixture newwin = WindowFinder.findDialog(ActionEditorDialog.class)
189 188
                 .withTimeout(5000).using(window.robot);
@@ -196,7 +195,7 @@ public class ActionsManagerDialogTest {
196 195
         
197 196
         window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
198 197
         window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
199
-                .button(JButtonByTextMatcher.withText("Edit")).requireEnabled().click();
198
+                .button(JButtonMatcher.withText("Edit")).requireEnabled().click();
200 199
         
201 200
         DialogFixture newwin = WindowFinder.findDialog(StandardInputDialog.class)
202 201
                 .withTimeout(5000).using(window.robot);
@@ -205,12 +204,12 @@ public class ActionsManagerDialogTest {
205 204
         assertEquals("Edit action group", newwin.target.getTitle());
206 205
         
207 206
         assertEquals("amd-ui-test1", 
208
-                newwin.textBox(new ClassFinder<JTextComponent>(javax.swing.JTextField.class,
207
+                newwin.textBox(new ClassFinder<JTextField>(JTextField.class,
209 208
                 null)).target.getText());
210 209
         
211
-        newwin.textBox(new ClassFinder<JTextComponent>(javax.swing.JTextField.class,
210
+        newwin.textBox(new ClassFinder<JTextField>(JTextField.class,
212 211
                 null)).deleteText().enterText("amd-ui-test2");
213
-        newwin.button(JButtonByTextMatcher.withText(button)).requireEnabled().click();
212
+        newwin.button(JButtonMatcher.withText(button)).requireEnabled().click();
214 213
     }
215 214
     
216 215
     @Test
@@ -229,7 +228,6 @@ public class ActionsManagerDialogTest {
229 228
     
230 229
     protected void setupWindow() {
231 230
         window = new DialogFixture(ActionsManagerDialog.getActionsManagerDialog(null, null));
232
-        window.robot.settings().eventMode(EventMode.AWT);
233 231
         window.show();
234 232
     }
235 233
 

+ 5
- 5
test/com/dmdirc/addons/ui_swing/dialogs/profiles/ProfileManagerDialogTest.java Parādīt failu

@@ -26,6 +26,8 @@ import com.dmdirc.Main;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27 27
 import com.dmdirc.addons.ui_swing.UIUtilities;
28 28
 import com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList;
29
+import com.dmdirc.config.IdentityManager;
30
+import com.dmdirc.config.InvalidIdentityFileException;
29 31
 import com.dmdirc.config.prefs.validator.FileNameValidator;
30 32
 import com.dmdirc.config.prefs.validator.IdentValidator;
31 33
 import com.dmdirc.config.prefs.validator.NotEmptyValidator;
@@ -34,7 +36,6 @@ import com.dmdirc.harness.ui.ValidatingJTextFieldFinder;
34 36
 
35 37
 import javax.swing.JList;
36 38
 
37
-import org.fest.swing.core.EventMode;
38 39
 import org.fest.swing.fixture.DialogFixture;
39 40
 
40 41
 import org.junit.After;
@@ -49,13 +50,14 @@ public class ProfileManagerDialogTest {
49 50
     private Profile profile;
50 51
 
51 52
     @BeforeClass
52
-    public static void setUpClass() {
53
+    public static void setUpClass() throws InvalidIdentityFileException {
54
+        IdentityManager.load();
55
+        UIUtilities.initUISettings();
53 56
         Main.setUI(new SwingController());
54 57
     }
55 58
 
56 59
     @Before
57 60
     public void setUp() {
58
-        UIUtilities.initUISettings();
59 61
         profile = new Profile("unit-test1", "nick1", "real name", "ident");
60 62
         profile.save();
61 63
     }
@@ -89,8 +91,6 @@ public class ProfileManagerDialogTest {
89 91
 
90 92
     protected void setupWindow() {
91 93
         window = new DialogFixture(ProfileManagerDialog.getProfileManagerDialog(null));
92
-
93
-        window.robot.settings().eventMode(EventMode.AWT);
94 94
         window.show();
95 95
     }
96 96
 

+ 13
- 19
test/com/dmdirc/addons/ui_swing/dialogs/sslcertificate/SSLCertificateDialogTest.java Parādīt failu

@@ -24,26 +24,25 @@ package com.dmdirc.addons.ui_swing.dialogs.sslcertificate;
24 24
 
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.addons.ui_swing.SwingController;
27
+import com.dmdirc.config.InvalidIdentityFileException;
27 28
 import com.dmdirc.harness.ui.ClassFinder;
28 29
 import com.dmdirc.harness.ui.TestSSLCertificateDialogModel;
29 30
 import com.dmdirc.ui.IconManager;
30 31
 import com.dmdirc.addons.ui_swing.UIUtilities;
31 32
 
33
+import com.dmdirc.config.IdentityManager;
32 34
 import java.awt.Component;
33 35
 import java.util.Arrays;
34 36
 
35 37
 import javax.swing.Icon;
36 38
 import javax.swing.JLabel;
37
-import javax.swing.JList;
38
-import javax.swing.JScrollPane;
39 39
 import javax.swing.border.TitledBorder;
40 40
 
41
-import org.fest.swing.core.EventMode;
41
+import org.fest.swing.driver.BasicCellRendererReader;
42 42
 import org.fest.swing.driver.BasicJListCellReader;
43 43
 import org.fest.swing.fixture.DialogFixture;
44 44
 
45 45
 import org.junit.After;
46
-import org.junit.Before;
47 46
 import org.junit.BeforeClass;
48 47
 import org.junit.Test;
49 48
 import static org.junit.Assert.*;
@@ -53,13 +52,10 @@ public class SSLCertificateDialogTest {
53 52
     private DialogFixture window;
54 53
 
55 54
     @BeforeClass
56
-    public static void setUpClass() {
57
-        Main.setUI(new SwingController());
58
-    }
59
-
60
-    @Before
61
-    public void setUp() {
55
+    public static void setUpClass() throws InvalidIdentityFileException {
56
+        IdentityManager.load();
62 57
         UIUtilities.initUISettings();
58
+        Main.setUI(new SwingController());
63 59
     }
64 60
 
65 61
     @After
@@ -87,7 +83,8 @@ public class SSLCertificateDialogTest {
87 83
             "cross",
88 84
             "tick",
89 85
             "cross"
90
-        },window.list().cellReader(new CertificateListCellReader()).contents()));
86
+        },window.list().cellReader(new BasicJListCellReader(new CertificateListCellReader()))
87
+                .contents()));
91 88
     }
92 89
 
93 90
     @Test
@@ -100,7 +97,7 @@ public class SSLCertificateDialogTest {
100 97
             window.list().selectItem(cert).requireSelection(cert);
101 98
 
102 99
             assertEquals("Information for " + cert, ((TitledBorder) window
103
-                    .scrollPane(new ClassFinder<JScrollPane>(CertificateInfoPanel.class, null))
100
+                    .scrollPane(new ClassFinder<CertificateInfoPanel>(CertificateInfoPanel.class, null))
104 101
                     .target.getBorder()).getTitle());
105 102
         }
106 103
     }
@@ -108,18 +105,15 @@ public class SSLCertificateDialogTest {
108 105
     protected void setupWindow() {
109 106
         window = new DialogFixture(new SSLCertificateDialog(null,
110 107
                 new TestSSLCertificateDialogModel()));
111
-
112
-        window.robot.settings().eventMode(EventMode.AWT);
113 108
         window.show();
114 109
     }
115 110
 
116
-    private static class CertificateListCellReader extends BasicJListCellReader {
117
-
118
-        public String valueAt(JList arg0, int arg1) {
119
-            final Component c = cellRendererComponent(arg0, arg1);
111
+    private static class CertificateListCellReader extends BasicCellRendererReader {
120 112
 
113
+        @Override
114
+        public String valueFrom(Component c) {
121 115
             final Icon target = ((JLabel) c).getIcon();
122
-            
116
+
123 117
             for (String icon : new String[]{"tick", "cross", "nothing"}) {
124 118
                 if (target == IconManager.getIconManager().getIcon(icon)) {
125 119
                     return icon;

+ 47
- 0
test/com/dmdirc/harness/ui/ClassFinder.java Parādīt failu

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ * 
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ * 
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ * 
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.harness.ui;
24
+
25
+import java.awt.Component;
26
+import org.fest.swing.core.GenericTypeMatcher;
27
+
28
+public class ClassFinder<T extends Component> extends GenericTypeMatcher<T> {
29
+
30
+    protected final Class<T> clazz;
31
+    protected final String name;
32
+
33
+    public ClassFinder(final Class<T> clazz, final String name) {
34
+        super(clazz);
35
+        
36
+        this.clazz = clazz;
37
+        this.name = name;
38
+    }
39
+    
40
+    @Override
41
+    protected boolean isMatching(T arg0) {
42
+        return arg0.getClass().equals(clazz)
43
+                && ((arg0.getName() == null && name == null
44
+                || (arg0.getName() != null && arg0.getName().equals(name))));
45
+    }
46
+
47
+}

+ 43
- 0
test/com/dmdirc/harness/ui/JRadioButtonByTextMatcher.java Parādīt failu

@@ -0,0 +1,43 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.harness.ui;
24
+
25
+import javax.swing.JRadioButton;
26
+import org.fest.swing.core.GenericTypeMatcher;
27
+
28
+public class JRadioButtonByTextMatcher extends GenericTypeMatcher<JRadioButton> {
29
+
30
+    private final String name;
31
+
32
+    public JRadioButtonByTextMatcher(final String name) {
33
+        super(JRadioButton.class);
34
+        
35
+        this.name = name;
36
+    }
37
+
38
+    @Override
39
+    protected boolean isMatching(JRadioButton arg0) {
40
+        return arg0.getText().equals(name);
41
+    }
42
+
43
+}

+ 105
- 0
test/com/dmdirc/harness/ui/TestSSLCertificateDialogModel.java Parādīt failu

@@ -0,0 +1,105 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.harness.ui;
24
+
25
+import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateAction;
26
+import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateChainEntry;
27
+import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateInformationEntry;
28
+import com.dmdirc.ui.core.dialogs.sslcertificate.CertificateSummaryEntry;
29
+import com.dmdirc.ui.core.dialogs.sslcertificate.SSLCertificateDialogModel;
30
+
31
+import java.util.ArrayList;
32
+import java.util.Arrays;
33
+import java.util.List;
34
+
35
+public class TestSSLCertificateDialogModel extends SSLCertificateDialogModel {
36
+
37
+    public CertificateAction action = null;
38
+    public boolean needsResponse = true;
39
+
40
+    public TestSSLCertificateDialogModel() {
41
+        super(null, null, null);
42
+    }
43
+
44
+    @Override
45
+    public List<CertificateChainEntry> getCertificateChain() {
46
+        return Arrays.asList(new CertificateChainEntry[]{
47
+            new CertificateChainEntry("first cert", false, false),
48
+            new CertificateChainEntry("second cert", false, false),
49
+            new CertificateChainEntry("invalid cert", false, true),
50
+            new CertificateChainEntry("trusted cert", true, false),
51
+            new CertificateChainEntry("invalid+trusted", true, true),
52
+        });
53
+    }
54
+
55
+    @Override
56
+    public List<List<CertificateInformationEntry>> getCertificateInfo(int index) {
57
+        final List<List<CertificateInformationEntry>> res
58
+                = new ArrayList<List<CertificateInformationEntry>>();
59
+        
60
+        res.add(Arrays.asList(new CertificateInformationEntry[]{
61
+            new CertificateInformationEntry("G1 T1", "value", false, false),
62
+            new CertificateInformationEntry("G1 T2 missing", "value", false, true),
63
+            new CertificateInformationEntry("G1 T3 invalid", "value", true, false),
64
+        }));
65
+
66
+        res.add(Arrays.asList(new CertificateInformationEntry[]{
67
+            new CertificateInformationEntry("G2 T1", "value", false, false),
68
+            new CertificateInformationEntry("G2 T2 missing", "value", false, true),
69
+            new CertificateInformationEntry("G2 T3 invalid", "value", true, false),
70
+        }));
71
+
72
+        res.add(Arrays.asList(new CertificateInformationEntry[]{
73
+            new CertificateInformationEntry("G3 T1", "value", false, false),
74
+            new CertificateInformationEntry("G3 T2 missing", "value", false, true),
75
+            new CertificateInformationEntry("G3 T3 invalid", "value", true, false),
76
+        }));
77
+
78
+        return res;
79
+    }
80
+
81
+    @Override
82
+    public List<CertificateSummaryEntry> getSummary() {
83
+        return Arrays.asList(new CertificateSummaryEntry[]{
84
+            new CertificateSummaryEntry("Valid entry one", true),
85
+            new CertificateSummaryEntry("Valid entry two", true),
86
+            new CertificateSummaryEntry("INVALID ENTRY!!1111one", false),
87
+        });
88
+    }
89
+
90
+    @Override
91
+    public boolean needsResponse() {
92
+        return needsResponse;
93
+    }
94
+
95
+    @Override
96
+    public void performAction(CertificateAction action) {
97
+        this.action = action;
98
+    }
99
+
100
+    @Override
101
+    public String getServerName() {
102
+        return "server.name";
103
+    }
104
+
105
+}

+ 46
- 0
test/com/dmdirc/harness/ui/ValidatingJTextFieldFinder.java Parādīt failu

@@ -0,0 +1,46 @@
1
+/*
2
+ * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ * 
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ * 
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ * 
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.harness.ui;
24
+
25
+import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
26
+import com.dmdirc.config.prefs.validator.Validator;
27
+import javax.swing.JTextField;
28
+import org.fest.swing.core.GenericTypeMatcher;
29
+
30
+public class ValidatingJTextFieldFinder extends GenericTypeMatcher<JTextField> {
31
+
32
+    private final Class<? extends Validator> validator;
33
+
34
+    public ValidatingJTextFieldFinder(final Class<? extends Validator> validator) {
35
+        super(JTextField.class);
36
+        this.validator = validator;
37
+    }
38
+    
39
+    @Override
40
+    protected boolean isMatching(JTextField arg0) {
41
+        return arg0.getParent() instanceof ValidatingJTextField &&
42
+                validator.isAssignableFrom(((ValidatingJTextField) arg0.getParent()).getValidator()
43
+                .getClass());
44
+    }
45
+
46
+}

Notiek ielāde…
Atcelt
Saglabāt