Browse Source

Rename UITest to UITestIface so JUnit doesn't try to run it as a test (despite it being an interface...)

Some new AED tests

git-svn-id: http://svn.dmdirc.com/trunk@4709 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6.3m1rc1
Chris Smith 16 years ago
parent
commit
0ef104d68b

+ 2
- 2
test/com/dmdirc/harness/ui/UIMethodTestRunner.java View File

@@ -55,8 +55,8 @@ public class UIMethodTestRunner extends TestMethodRunner {
55 55
             } catch (ActionFailedException e) {
56 56
                 if (--retries > 0) {
57 57
                     retry = true;
58
-                    ((UITest) test).tearDown();
59
-                    ((UITest) test).setUp();
58
+                    ((UITestIface) test).tearDown();
59
+                    ((UITestIface) test).setUp();
60 60
                 } else {
61 61
                     addFailure(e);
62 62
                 }

test/com/dmdirc/harness/ui/UITest.java → test/com/dmdirc/harness/ui/UITestIface.java View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.harness.ui;
24 24
 
25
-public interface UITest {
25
+public interface UITestIface {
26 26
 
27 27
     void setUp();
28 28
     void tearDown();

+ 41
- 0
test/com/dmdirc/ui/swing/JRadioButtonByTextMatcher.java View File

@@ -0,0 +1,41 @@
1
+/*
2
+ * Copyright (c) 2006-2007 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.ui.swing;
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
+        this.name = name;
34
+    }
35
+
36
+    @Override
37
+    protected boolean isMatching(JRadioButton arg0) {
38
+        return arg0.getText().equals(name);
39
+    }
40
+
41
+}

+ 2
- 2
test/com/dmdirc/ui/swing/MainFrameTest.java View File

@@ -24,7 +24,7 @@ package com.dmdirc.ui.swing;
24 24
 
25 25
 import com.dmdirc.config.IdentityManager;
26 26
 import com.dmdirc.harness.ui.UIClassTestRunner;
27
-import com.dmdirc.harness.ui.UITest;
27
+import com.dmdirc.harness.ui.UITestIface;
28 28
 import com.dmdirc.ui.swing.dialogs.FeedbackDialog;
29 29
 import com.dmdirc.ui.swing.dialogs.NewServerDialog;
30 30
 import com.dmdirc.ui.swing.dialogs.about.AboutDialog;
@@ -44,7 +44,7 @@ import org.junit.runner.RunWith;
44 44
 import static org.junit.Assert.*;
45 45
 
46 46
 @RunWith(UIClassTestRunner.class)
47
-public class MainFrameTest implements UITest {
47
+public class MainFrameTest implements UITestIface {
48 48
     
49 49
     private FrameFixture window;
50 50
 

+ 40
- 2
test/com/dmdirc/ui/swing/dialogs/actioneditor/ActionEditorDialogTest.java View File

@@ -28,13 +28,16 @@ import com.dmdirc.config.IdentityManager;
28 28
 import com.dmdirc.harness.ui.UIClassTestRunner;
29 29
 import com.dmdirc.harness.ui.ClassFinder;
30 30
 
31
-import com.dmdirc.harness.ui.UITest;
31
+import com.dmdirc.harness.ui.UITestIface;
32
+import com.dmdirc.ui.swing.JRadioButtonByTextMatcher;
32 33
 import com.dmdirc.ui.swing.components.ImageButton;
33 34
 
34 35
 import java.awt.Component;
35 36
 import javax.swing.JButton;
36 37
 import javax.swing.JPanel;
37 38
 
39
+import javax.swing.JTextField;
40
+import javax.swing.text.JTextComponent;
38 41
 import org.fest.swing.core.EventMode;
39 42
 import org.fest.swing.core.matcher.JButtonByTextMatcher;
40 43
 import org.fest.swing.core.matcher.JLabelByTextMatcher;
@@ -48,7 +51,7 @@ import org.junit.runner.RunWith;
48 51
 import static org.junit.Assert.*;
49 52
 
50 53
 @RunWith(UIClassTestRunner.class)
51
-public class ActionEditorDialogTest implements UITest {
54
+public class ActionEditorDialogTest implements UITestIface {
52 55
 
53 56
     private DialogFixture window;
54 57
 
@@ -100,6 +103,7 @@ public class ActionEditorDialogTest implements UITest {
100 103
         label.requireVisible();
101 104
 
102 105
         assertTrue(items > triggers.comboBox().target.getItemCount());
106
+        window.button(JButtonByTextMatcher.withText("OK")).requireEnabled();
103 107
 
104 108
         triggers.button(new ClassFinder<JButton>(ImageButton.class, null)).click();
105 109
         
@@ -109,6 +113,40 @@ public class ActionEditorDialogTest implements UITest {
109 113
         }
110 114
 
111 115
         assertEquals(items, triggers.comboBox().target.getItemCount());
116
+        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
117
+    }
118
+
119
+    @Test
120
+    public void testBasicConditionTrees() {
121
+        setupWindow(null);
122
+
123
+        window.panel(new ClassFinder<JPanel>(ActionNamePanel.class, null)).textBox()
124
+                .enterText("test1");
125
+        final JPanelFixture triggers = window.panel(
126
+                new ClassFinder<JPanel>(ActionTriggersPanel.class, null));
127
+
128
+        triggers.comboBox().selectItem("Channel message received");
129
+        triggers.button(JButtonByTextMatcher.withText("Add")).requireEnabled().click();
130
+
131
+        window.radioButton(new JRadioButtonByTextMatcher("All of the conditions are true"))
132
+                .requireEnabled().requireSelected();
133
+        window.radioButton(new JRadioButtonByTextMatcher("At least one of the conditions is true"))
134
+                .requireEnabled();
135
+        window.radioButton(new JRadioButtonByTextMatcher("The conditions match a custom rule"))
136
+                .requireEnabled();
137
+        window.panel(new ClassFinder<JPanel>(ActionConditionsTreePanel.class, null))
138
+                .textBox(new ClassFinder<JTextComponent>(JTextField.class, null))
139
+                .requireDisabled();
140
+
141
+        window.button(JButtonByTextMatcher.withText("OK")).requireEnabled();
142
+
143
+        window.radioButton(new JRadioButtonByTextMatcher("The conditions match a custom rule"))
144
+                .click().requireSelected();
145
+        window.panel(new ClassFinder<JPanel>(ActionConditionsTreePanel.class, null))
146
+                .textBox(new ClassFinder<JTextComponent>(JTextField.class, null))
147
+                .requireEnabled().enterText("invalid");
148
+
149
+        window.button(JButtonByTextMatcher.withText("OK")).requireDisabled();
112 150
     }
113 151
 
114 152
     protected void setupWindow(final Action action) {

+ 2
- 2
test/com/dmdirc/ui/swing/dialogs/actionsmanager/ActionsManagerDialogTest.java View File

@@ -26,7 +26,7 @@ import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.config.IdentityManager;
27 27
 import com.dmdirc.harness.ui.UIClassTestRunner;
28 28
 import com.dmdirc.harness.ui.ClassFinder;
29
-import com.dmdirc.harness.ui.UITest;
29
+import com.dmdirc.harness.ui.UITestIface;
30 30
 import com.dmdirc.ui.swing.components.StandardInputDialog;
31 31
 import com.dmdirc.ui.swing.dialogs.actioneditor.ActionEditorDialog;
32 32
 
@@ -46,7 +46,7 @@ import org.junit.runner.RunWith;
46 46
 import static org.junit.Assert.*;
47 47
 
48 48
 @RunWith(UIClassTestRunner.class)
49
-public class ActionsManagerDialogTest implements UITest {
49
+public class ActionsManagerDialogTest implements UITestIface {
50 50
     
51 51
     private DialogFixture window;
52 52
     

Loading…
Cancel
Save