Selaa lähdekoodia

Fix broken unit tests.

Change-Id: I2300fc55ee5a682bc00ec332826c5bd092161a82
Reviewed-on: http://gerrit.dmdirc.com/1469
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.6.5
Greg Holmes 14 vuotta sitten
vanhempi
commit
2d9dd05889

+ 32
- 17
test/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionGroupInformationPanelTest.java Näytä tiedosto

@@ -22,11 +22,15 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.actionsmanager;
24 24
 
25
+import javax.swing.JLabel;
26
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
25 27
 import com.dmdirc.actions.ActionGroup;
26 28
 import com.dmdirc.updater.Version;
27 29
 import org.junit.Test;
28 30
 import org.uispec4j.Panel;
31
+import org.uispec4j.UIComponent;
29 32
 import org.uispec4j.UISpecTestCase;
33
+import org.uispec4j.finder.ComponentMatcher;
30 34
 import static org.junit.Assert.*;
31 35
 import static org.mockito.Mockito.*;
32 36
 
@@ -59,13 +63,18 @@ public class ActionGroupInformationPanelTest extends UISpecTestCase {
59 63
         
60 64
         final Panel panel = new Panel(new ActionGroupInformationPanel(group));
61 65
 
62
-        assertEquals("<panel>"
63
-                + "<textBox text=\"description\"/>"
64
-                + "<textBox text=\"Author: \"/>"
65
-                + "<textBox text=\"foo &lt;bar@baz&gt;\"/>"
66
-                + "<textBox text=\"Version: \"/>"
67
-                + "<textBox text=\"17\"/>"
68
-                + "</panel>", panel.getDescription().replace("\n", ""));
66
+        final UIComponent[] components = panel.getUIComponents(
67
+                ComponentMatcher.ALL);
68
+        assertEquals("Description", "description", ((TextLabel) components[0]
69
+                .getAwtComponent()).getText().split("</?body.*?>")[1].trim());
70
+        assertEquals("Author label", "Author: ", ((JLabel) components[1]
71
+                .getAwtComponent()).getText());
72
+        assertEquals("Author", "foo <bar@baz>", ((JLabel) components[2]
73
+                .getAwtComponent()).getText());
74
+        assertEquals("Version label", "Version: ", ((JLabel) components[3]
75
+                .getAwtComponent()).getText());
76
+        assertEquals("version", "17", ((JLabel) components[4].getAwtComponent())
77
+                .getText());
69 78
     }
70 79
 
71 80
     @Test
@@ -76,11 +85,14 @@ public class ActionGroupInformationPanelTest extends UISpecTestCase {
76 85
 
77 86
         final Panel panel = new Panel(new ActionGroupInformationPanel(group));
78 87
 
79
-        assertEquals("<panel>"
80
-                + "<textBox text=\"description\"/>"
81
-                + "<textBox text=\"Version: \"/>"
82
-                + "<textBox text=\"17\"/>"
83
-                + "</panel>", panel.getDescription().replace("\n", ""));
88
+        final UIComponent[] components = panel.getUIComponents(
89
+                ComponentMatcher.ALL);
90
+        assertEquals("Description", "description", ((TextLabel) components[0]
91
+                .getAwtComponent()).getText().split("</?body.*?>")[1].trim());
92
+        assertEquals("Version label", "Version: ", ((JLabel) components[3]
93
+                .getAwtComponent()).getText());
94
+        assertEquals("version", "17", ((JLabel) components[4].getAwtComponent())
95
+                .getText());
84 96
     }
85 97
 
86 98
     @Test
@@ -92,11 +104,14 @@ public class ActionGroupInformationPanelTest extends UISpecTestCase {
92 104
 
93 105
         final Panel panel = new Panel(new ActionGroupInformationPanel(group));
94 106
 
95
-        assertEquals("<panel>"
96
-                + "<textBox text=\"description\"/>"
97
-                + "<textBox text=\"Author: \"/>"
98
-                + "<textBox text=\"foo &lt;bar@baz&gt;\"/>"
99
-                + "</panel>", panel.getDescription().replace("\n", ""));
107
+        final UIComponent[] components = panel.getUIComponents(
108
+                ComponentMatcher.ALL);
109
+        assertEquals("Description", "description", ((TextLabel) components[0]
110
+                .getAwtComponent()).getText().split("</?body.*?>")[1].trim());
111
+        assertEquals("Author label", "Author: ", ((JLabel) components[1]
112
+                .getAwtComponent()).getText());
113
+        assertEquals("Author", "foo <bar@baz>", ((JLabel) components[2]
114
+                .getAwtComponent()).getText());
100 115
     }
101 116
 
102 117
 }

+ 1
- 1
test/com/dmdirc/harness/ui/DMDircUITestCase.java Näytä tiedosto

@@ -51,7 +51,7 @@ public class DMDircUITestCase extends UISpecTestCase {
51 51
 
52 52
         IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
53 53
         IdentityManager.getAddonIdentity().setOption("test", "desktopbackground", "");
54
-        IdentityManager.getAddonIdentity().setOption("test", "desktopbackgroundoption", "STRETCH");
54
+        IdentityManager.getAddonIdentity().setOption("test", "desktopbackgroundoption", "SCALE");
55 55
         IdentityManager.getAddonIdentity().setOption("test", "windowMenuItems", "1");
56 56
         IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
57 57
         Main.ensureExists(PluginManager.getPluginManager(), "tabcompletion");

Loading…
Peruuta
Tallenna