Browse Source

fixes issue 1966

tags/0.6.3m1rc1
Gregory Holmes 15 years ago
parent
commit
83dbe899fa

+ 28
- 38
test/com/dmdirc/ui/swing/dialogs/actioneditor/ActionEditorDialogTest.java View File

@@ -27,21 +27,20 @@ import com.dmdirc.actions.ActionManager;
27 27
 import com.dmdirc.config.IdentityManager;
28 28
 import com.dmdirc.harness.ui.UIClassTestRunner;
29 29
 import com.dmdirc.harness.ui.ClassFinder;
30
-
31 30
 import com.dmdirc.harness.ui.UITestIface;
32 31
 import com.dmdirc.harness.ui.JRadioButtonByTextMatcher;
33 32
 import com.dmdirc.ui.swing.components.ImageButton;
34 33
 
35 34
 import com.dmdirc.ui.swing.components.TextLabel;
36 35
 import java.awt.Component;
37
-import java.awt.Font;
36
+
37
+import java.util.regex.Matcher;
38
+import java.util.regex.Pattern;
38 39
 import javax.swing.JButton;
39 40
 import javax.swing.JPanel;
40
-
41 41
 import javax.swing.JTextField;
42
-import javax.swing.UIManager;
43 42
 import javax.swing.text.JTextComponent;
44
-import javax.swing.text.html.HTMLDocument;
43
+
45 44
 import org.fest.swing.core.EventMode;
46 45
 import org.fest.swing.core.matcher.JButtonByTextMatcher;
47 46
 import org.fest.swing.core.matcher.JLabelByTextMatcher;
@@ -50,6 +49,7 @@ import org.fest.swing.fixture.JLabelFixture;
50 49
 import org.fest.swing.fixture.JPanelFixture;
51 50
 import org.junit.After;
52 51
 import org.junit.Before;
52
+import org.junit.Ignore;
53 53
 import org.junit.Test;
54 54
 import org.junit.runner.RunWith;
55 55
 import static org.junit.Assert.*;
@@ -184,17 +184,7 @@ public class ActionEditorDialogTest implements UITestIface {
184 184
     }
185 185
 
186 186
     @Test
187
-    public void testConditionText() {
188
-        final Font font = UIManager.getFont("Label.font");
189
-        final String style = "body { font-size: " + font.getSize() +
190
-                "pt; font-family: " + font.getFamily() + " }";
191
-
192
-        final String HEADER =
193
-                "<html>\n" + "  <head>\n" + "    <style type=\"text/css\">\n" +
194
-                "      <!--\n" + "        " + style + "\n" + "      -->\n" +
195
-                "    </style>\n" + "    \n" + "  </head>\n" + "  <body>\n" +
196
-                "    ";
197
-        final String FOOTER = "\n" + "  </body>\n" + "</html>\n";
187
+    public void testConditionText() {        
198 188
         setupWindow(null);
199 189
 
200 190
         window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).
@@ -209,50 +199,50 @@ public class ActionEditorDialogTest implements UITestIface {
209 199
         window.panel(new ClassFinder<JPanel>(ActionConditionsPanel.class, null)).
210 200
                 button(JButtonByTextMatcher.withText("Add")).requireEnabled().
211 201
                 click();
212
-
213
-        System.out.println(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
214
-                null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
215
-                null)).target.getText());
216
-        System.out.println("\n\n");
217
-        System.out.println(HEADER +
218
-                "<p style=\"margin-top: 0\">\n      \n    </p>" + FOOTER);
219
-        assertEquals(HEADER + "<p style=\"margin-top: 0\">\n      \n    </p>" +
220
-                FOOTER,
221
-                window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
202
+        
203
+        Pattern pattern = Pattern.compile(".+<body>(.+)</body>.+", Pattern.DOTALL);
204
+        
205
+        Matcher matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
222 206
                 null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
223 207
                 null)).target.getText());
208
+        matcher.find();
209
+        assertEquals("<p style=\"margin-top: 0\">\n      \n    </p>", matcher.group(1).trim());
224 210
 
225 211
         window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
226 212
                 null)).comboBox("argument").selectItem("message");
227
-
228
-        assertEquals(HEADER + "The message's ..." + FOOTER,
229
-                window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
213
+        
214
+        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
230 215
                 null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
231 216
                 null)).target.getText());
217
+        matcher.find();
218
+        assertEquals("The message's ...", matcher.group(1).trim());
232 219
 
233 220
         window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
234 221
                 null)).comboBox("component").selectItem("content");
235
-
236
-        assertEquals(HEADER + "The message's content ..." + FOOTER,
237
-                window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
222
+        
223
+        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
238 224
                 null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
239 225
                 null)).target.getText());
226
+        matcher.find();
227
+        assertEquals("The message's content ...", matcher.group(1).trim());
240 228
 
241 229
         window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
242 230
                 null)).comboBox("comparison").selectItem("contains");
243
-
244
-        assertEquals(HEADER + "The message's content contains ''" + FOOTER,
245
-                window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
231
+        
232
+        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
246 233
                 null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
247 234
                 null)).target.getText());
235
+        matcher.find();
236
+        assertEquals("The message's content contains ''", matcher.group(1).trim());
248 237
 
249 238
         window.panel(new ClassFinder<JPanel>(ActionConditionEditorPanel.class,
250 239
                 null)).textBox().enterText("foo");
251
-
252
-        assertEquals(HEADER + "The message's content contains 'foo'" + FOOTER,
253
-                window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
240
+        
241
+        matcher = pattern.matcher(window.panel(new ClassFinder<JPanel>(ActionConditionDisplayPanel.class,
254 242
                 null)).textBox(new ClassFinder<JTextComponent>(TextLabel.class,
255 243
                 null)).target.getText());
244
+        matcher.find();
245
+        assertEquals("The message's content contains 'foo'", matcher.group(1).trim());
256 246
     }
257 247
 
258 248
     @Test

Loading…
Cancel
Save