Selaa lähdekoodia

Update AED unit tests

Introduce DMDirc base UI test with helper methods
Move utility classes into harness/ui package

Change-Id: Id70553a03baa43b02036524a577aaa9f791b795b
Reviewed-on: http://gerrit.dmdirc.com/1264
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.4
Greg 14 vuotta sitten
vanhempi
commit
f03d296053
22 muutettua tiedostoa jossa 1134 lisäystä ja 88 poistoa
  1. 12
    0
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanel.java
  2. 1
    0
      src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionEditorPanel.java
  3. 3
    20
      test/com/dmdirc/addons/ui_swing/MainFrameTest.java
  4. 0
    1
      test/com/dmdirc/addons/ui_swing/UIUtilitiesTest.java
  5. 10
    55
      test/com/dmdirc/addons/ui_swing/components/frames/InputTextFrameTest.java
  6. 0
    4
      test/com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferHandlerTest.java
  7. 0
    1
      test/com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferableTest.java
  8. 64
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionAdvancedPanelTest.java
  9. 279
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanelTest.java
  10. 266
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionEditorPanelTest.java
  11. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsListPanelTest.java
  12. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsPanelTest.java
  13. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsTreePanelTest.java
  14. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionNamePanelTest.java
  15. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionResponsePanelTest.java
  16. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionSubstitutionsPanelTest.java
  17. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersListPanelTest.java
  18. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersPanelTest.java
  19. 37
    0
      test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTypeModelTest.java
  20. 59
    0
      test/com/dmdirc/harness/ui/ClassAndNameComponentMatcher.java
  21. 3
    7
      test/com/dmdirc/harness/ui/ClassComponentMatcher.java
  22. 104
    0
      test/com/dmdirc/harness/ui/DMDircUITestCase.java

+ 12
- 0
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanel.java Näytä tiedosto

@@ -85,6 +85,7 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
85 85
         initComponents();
86 86
         addListeners();
87 87
         layoutComponents();
88
+        setTrigger(trigger);
88 89
         validate();
89 90
         layoutComponents();
90 91
 
@@ -110,6 +111,17 @@ public class ActionConditionDisplayPanel extends JPanel implements ActionListene
110 111
         label.setText(updateSentence());
111 112
     }
112 113
 
114
+    /**
115
+     * Sets the action condition.
116
+     *
117
+     * @param condition new condition
118
+     */
119
+    protected void setCondition(final ActionCondition condition) {
120
+        this.condition = condition;
121
+
122
+        label.setText(updateSentence());
123
+    }
124
+
113 125
     /** Initialises the components. */
114 126
     private void initComponents() {
115 127
         label = new TextLabel("", false);

+ 1
- 0
src/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionEditorPanel.java Näytä tiedosto

@@ -97,6 +97,7 @@ public class ActionConditionEditorPanel extends JPanel implements ActionListener
97 97
 
98 98
         addListeners();
99 99
         layoutComponents();
100
+        setEnabled(trigger != null);
100 101
     }
101 102
 
102 103
     /** Initialises the components. */

+ 3
- 20
test/com/dmdirc/addons/ui_swing/MainFrameTest.java Näytä tiedosto

@@ -22,34 +22,17 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25
-import com.dmdirc.config.IdentityManager;
26
-import com.dmdirc.config.InvalidIdentityFileException;
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
27 26
 import org.junit.Test;
28
-import org.uispec4j.UISpecTestCase;
29 27
 import org.uispec4j.Window;
30 28
 import org.uispec4j.interception.WindowInterceptor;
31
-import static org.mockito.Mockito.*;
32 29
 
33
-public class MainFrameTest extends UISpecTestCase {
30
+public class MainFrameTest extends DMDircUITestCase {
34 31
     
35 32
     private static Window window;
36 33
 
37 34
     static {
38
-        try {
39
-            IdentityManager.load();
40
-        } catch (InvalidIdentityFileException ex) {
41
-            //Ignore
42
-        }
43
-        SwingController controller = mock(SwingController.class);
44
-        final SwingWindowFactory windowFactory = mock(SwingWindowFactory.class);
45
-        when(controller.getDomain()).thenReturn("test");
46
-        when(controller.getWindowFactory()).thenReturn(windowFactory);
47
-
48
-        IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
49
-        IdentityManager.getAddonIdentity().setOption("test", "desktopbackground", "");
50
-        IdentityManager.getAddonIdentity().setOption("test", "desktopbackgroundoption", "STRETCH");
51
-        IdentityManager.getAddonIdentity().setOption("test", "windowMenuItems", "1");
52
-        IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
35
+        SwingController controller = getMockedController();
53 36
 
54 37
         window = new Window(new MainFrame(controller));
55 38
         window.containsMenuBar().check();

+ 0
- 1
test/com/dmdirc/addons/ui_swing/UIUtilitiesTest.java Näytä tiedosto

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25 25
 
26
-import com.dmdirc.addons.ui_swing.UIUtilities;
27 26
 import com.dmdirc.addons.ui_swing.actions.RedoAction;
28 27
 import com.dmdirc.addons.ui_swing.actions.UndoAction;
29 28
 import javax.swing.JTextField;

+ 10
- 55
test/com/dmdirc/addons/ui_swing/components/frames/InputTextFrameTest.java Näytä tiedosto

@@ -22,67 +22,22 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25
-import com.dmdirc.Main;
26
-import com.dmdirc.WritableFrameContainer;
27
-import com.dmdirc.addons.ui_swing.ClassComponentMatcher;
28
-import com.dmdirc.addons.ui_swing.MainFrame;
29
-import com.dmdirc.config.ConfigManager;
30
-import com.dmdirc.config.IdentityManager;
31
-import com.dmdirc.config.InvalidIdentityFileException;
32
-import com.dmdirc.addons.ui_swing.SwingController;
33
-import com.dmdirc.addons.ui_swing.SwingWindowFactory;
25
+import com.dmdirc.harness.ui.ClassComponentMatcher;
26
+import com.dmdirc.harness.ui.DMDircUITestCase;
34 27
 import com.dmdirc.addons.ui_swing.components.TextAreaInputField;
35
-import com.dmdirc.plugins.PluginManager;
36
-import com.dmdirc.ui.messages.IRCDocument;
37
-
38
-
39
-import org.junit.After;
40
-import org.junit.Before;
41 28
 import org.junit.Test;
42 29
 import org.uispec4j.Trigger;
43
-import org.uispec4j.UISpecTestCase;
44 30
 import org.uispec4j.Window;
45 31
 import org.uispec4j.interception.WindowInterceptor;
46
-import static org.mockito.Mockito.*;
47 32
 
48
-public class InputTextFrameTest extends UISpecTestCase {
33
+public class InputTextFrameTest extends DMDircUITestCase {
49 34
 
50 35
     static InputTextFrame tf;
51 36
     static String text;
52 37
 
53 38
     static {
54
-        try {
55
-            IdentityManager.load();
56
-        } catch (InvalidIdentityFileException ex) {
57
-            //Ignore
58
-        }
59
-        IdentityManager.getAddonIdentity().setOption("test", "windowMenuItems",
60
-                "1");
61
-        IdentityManager.getAddonIdentity().setOption("test",
62
-                "windowMenuScrollInterval", "1");
63
-        IdentityManager.getAddonIdentity().setOption("test", "debugEDT", "false");
64
-        IdentityManager.getAddonIdentity().setOption("test",
65
-                "textpanebackground", "");
66
-        IdentityManager.getAddonIdentity().setOption("test", "desktopbackground",
67
-                "");
68
-        Main.ensureExists(PluginManager.getPluginManager(), "tabcompletion");
69
-
70
-        final IRCDocument document = mock(IRCDocument.class);
71
-        @SuppressWarnings("unchecked")
72
-        final WritableFrameContainer<CustomInputFrame> container = mock(
73
-                WritableFrameContainer.class);
74
-        final ConfigManager config = mock(ConfigManager.class);
75
-        when(container.getDocument()).thenReturn(document);
76
-        when(container.getConfigManager()).thenReturn(config);
77
-        when(config.getOption(anyString(), anyString())).thenReturn("mirc");
78
-        final SwingController controller = mock(SwingController.class);
79
-        when(controller.getDomain()).thenReturn("test");
80
-        final SwingWindowFactory wf = new SwingWindowFactory(controller);
81
-        when(controller.getWindowFactory()).thenReturn(wf);
82
-        final MainFrame mainFrame = new MainFrame(controller);
83
-        when(controller.getMainFrame()).thenReturn(mainFrame);
84
-
85
-        tf = new CustomInputFrame(controller, container);
39
+        tf = new CustomInputFrame(getMockedControllerAndMainFrame(),
40
+                getMockedContainer());
86 41
         text = "line1\nline2";
87 42
     }
88 43
 
@@ -91,7 +46,7 @@ public class InputTextFrameTest extends UISpecTestCase {
91 46
         final Window dialog = getDialog();
92 47
         dialog.titleEquals("DMDirc: Multi-line paste").check();
93 48
         dialog.getButton("Edit").click();
94
-        assertTrue(dialog.getTextBox(new ClassComponentMatcher(dialog,
49
+        assertTrue(dialog.getTextBox(new ClassComponentMatcher(
95 50
                 TextAreaInputField.class)).getText().equals(text));
96 51
     }
97 52
 
@@ -101,7 +56,7 @@ public class InputTextFrameTest extends UISpecTestCase {
101 56
         final Window dialog = getDialog();
102 57
         dialog.titleEquals("DMDirc: Multi-line paste").check();
103 58
         dialog.getButton("Edit").click();
104
-        assertTrue(dialog.getTextBox(new ClassComponentMatcher(dialog,
59
+        assertTrue(dialog.getTextBox(new ClassComponentMatcher(
105 60
                 TextAreaInputField.class)).getText().equals("testing:" + text));
106 61
     }
107 62
 
@@ -112,7 +67,7 @@ public class InputTextFrameTest extends UISpecTestCase {
112 67
         final Window dialog = getDialog();
113 68
         dialog.titleEquals("DMDirc: Multi-line paste").check();
114 69
         dialog.getButton("Edit").click();
115
-        assertTrue(dialog.getTextBox(new ClassComponentMatcher(dialog,
70
+        assertTrue(dialog.getTextBox(new ClassComponentMatcher(
116 71
                 TextAreaInputField.class)).getText().equals(text + ":testing"));
117 72
     }
118 73
 
@@ -124,7 +79,7 @@ public class InputTextFrameTest extends UISpecTestCase {
124 79
         dialog.titleEquals("DMDirc: Multi-line paste").check();
125 80
         dialog.getButton("Edit").click();
126 81
         assertEquals("testing:" + text + ":testing",
127
-                dialog.getTextBox(new ClassComponentMatcher(dialog,
82
+                dialog.getTextBox(new ClassComponentMatcher(
128 83
                 TextAreaInputField.class)).getText());
129 84
     }
130 85
 
@@ -137,7 +92,7 @@ public class InputTextFrameTest extends UISpecTestCase {
137 92
         dialog.titleEquals("DMDirc: Multi-line paste").check();
138 93
         dialog.getButton("Edit").click();
139 94
         assertEquals("testing:" + text + ":testing",
140
-                dialog.getTextBox(new ClassComponentMatcher(dialog,
95
+                dialog.getTextBox(new ClassComponentMatcher(
141 96
                 TextAreaInputField.class)).getText());
142 97
     }
143 98
 

+ 0
- 4
test/com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferHandlerTest.java Näytä tiedosto

@@ -21,8 +21,6 @@
21 21
  */
22 22
 package com.dmdirc.addons.ui_swing.components.reorderablelist;
23 23
 
24
-import com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler;
25
-import com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferable;
26 24
 import java.awt.datatransfer.DataFlavor;
27 25
 import java.awt.datatransfer.Transferable;
28 26
 import java.awt.datatransfer.UnsupportedFlavorException;
@@ -31,8 +29,6 @@ import java.util.ArrayList;
31 29
 import javax.swing.DefaultListModel;
32 30
 import javax.swing.JList;
33 31
 import javax.swing.TransferHandler;
34
-import org.junit.AfterClass;
35
-import org.junit.BeforeClass;
36 32
 import org.junit.Test;
37 33
 import static org.junit.Assert.*;
38 34
 

+ 0
- 1
test/com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferableTest.java Näytä tiedosto

@@ -21,7 +21,6 @@
21 21
  */
22 22
 package com.dmdirc.addons.ui_swing.components.reorderablelist;
23 23
 
24
-import com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferable;
25 24
 import java.awt.datatransfer.UnsupportedFlavorException;
26 25
 import java.util.ArrayList;
27 26
 

+ 64
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionAdvancedPanelTest.java Näytä tiedosto

@@ -0,0 +1,64 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+import org.uispec4j.Panel;
28
+
29
+public class ActionAdvancedPanelTest extends DMDircUITestCase {
30
+
31
+    @Test
32
+    public void testActionEnabled() {
33
+        final ActionAdvancedPanel panel = new ActionAdvancedPanel();
34
+        final Panel test = new Panel(panel);
35
+
36
+        test.getCheckBox().isEnabled().check();
37
+        assertTrue(test.getCheckBox().isSelected());
38
+        assertTrue(panel.isActionEnabled());
39
+        test.getCheckBox().click();
40
+        assertFalse(test.getCheckBox().isSelected());
41
+        assertFalse(panel.isActionEnabled());
42
+
43
+        panel.setActionEnabled(false);
44
+        assertFalse(test.getCheckBox().isSelected());
45
+        panel.setActionEnabled(true);
46
+        assertTrue(test.getCheckBox().isSelected());
47
+    }
48
+
49
+    @Test
50
+    public void testConcurrencyGroup() {
51
+        final ActionAdvancedPanel panel = new ActionAdvancedPanel();
52
+        final Panel test = new Panel(panel);
53
+
54
+        test.getInputTextBox().textIsEmpty().check();
55
+        assertEquals("", panel.getConcurrencyGroup());
56
+        test.getInputTextBox().setText("testing");
57
+        assertEquals("testing", panel.getConcurrencyGroup());
58
+
59
+        panel.setConcurrencyGroup("");
60
+        assertEquals("", test.getInputTextBox().getText());
61
+        panel.setConcurrencyGroup("testing");
62
+        assertEquals("testing", test.getInputTextBox().getText());
63
+    }
64
+}

+ 279
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionDisplayPanelTest.java Näytä tiedosto

@@ -0,0 +1,279 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.actions.ActionCondition;
26
+import com.dmdirc.actions.ActionManager;
27
+import com.dmdirc.actions.CoreActionComparison;
28
+import com.dmdirc.actions.CoreActionComponent;
29
+import com.dmdirc.actions.CoreActionType;
30
+import com.dmdirc.addons.ui_swing.components.ImageButton;
31
+import com.dmdirc.addons.ui_swing.components.ImageToggleButton;
32
+import com.dmdirc.addons.ui_swing.components.text.TextLabel;
33
+import com.dmdirc.harness.ui.ClassComponentMatcher;
34
+import com.dmdirc.harness.ui.DMDircUITestCase;
35
+import java.util.regex.Matcher;
36
+import java.util.regex.Pattern;
37
+import org.junit.Test;
38
+import org.uispec4j.Button;
39
+import org.uispec4j.Panel;
40
+import org.uispec4j.ToggleButton;
41
+import org.uispec4j.UIComponent;
42
+import static org.mockito.Mockito.*;
43
+
44
+public class ActionConditionDisplayPanelTest extends DMDircUITestCase {
45
+
46
+    Pattern pattern = Pattern.compile(".+<body>(.+)</body>.+", Pattern.DOTALL);
47
+
48
+    static {
49
+        ActionManager.init();
50
+    }
51
+
52
+    @Test
53
+    public void testBlankInitialising() {
54
+        ActionConditionDisplayPanel panel = new ActionConditionDisplayPanel(
55
+                new ActionCondition(-1, null, null, ""),
56
+                CoreActionType.CHANNEL_MESSAGE);
57
+        Panel test = new Panel(panel);
58
+
59
+        Matcher matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
60
+                TextLabel.class)).getText());
61
+        matcher.find();
62
+        assertEquals("The ...", matcher.group(1).trim());
63
+        UIComponent[] components = test.getUIComponents(new ClassComponentMatcher(
64
+                ActionConditionEditorPanel.class));
65
+        assertNotNull(components);
66
+        assertTrue(components.length == 1);
67
+        assertTrue(components[0].isEnabled());
68
+        assertTrue(components[0].isVisible());
69
+        ToggleButton toggle = test.getToggleButton(new ClassComponentMatcher(
70
+                ImageToggleButton.class));
71
+        assertTrue(toggle.isEnabled());
72
+        assertTrue(toggle.isVisible());
73
+        assertTrue(toggle.isSelected());
74
+        Button button = test.getButton(new ClassComponentMatcher(
75
+                ImageButton.class));
76
+        assertTrue(button.isEnabled());
77
+        assertTrue(button.isVisible());
78
+    }
79
+
80
+    @Test
81
+    public void testInitialising() {
82
+        ActionConditionDisplayPanel panel = new ActionConditionDisplayPanel(
83
+                new ActionCondition(2, CoreActionComponent.CHANNEL_NAME,
84
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
85
+                CoreActionType.CHANNEL_MESSAGE);
86
+        Panel test = new Panel(panel);
87
+
88
+        Matcher matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
89
+                TextLabel.class)).getText());
90
+        matcher.find();
91
+        assertEquals("The message's name starts with 'abc'", matcher.group(1).
92
+                trim());
93
+        UIComponent[] components = test.getUIComponents(new ClassComponentMatcher(
94
+                ActionConditionEditorPanel.class));
95
+        assertNotNull(components);
96
+        assertTrue(components.length == 1);
97
+        assertTrue(components[0].isEnabled());
98
+        assertFalse(components[0].isVisible());
99
+        ToggleButton toggle = test.getToggleButton(new ClassComponentMatcher(
100
+                ImageToggleButton.class));
101
+        assertTrue(toggle.isEnabled());
102
+        assertTrue(toggle.isVisible());
103
+        assertFalse(toggle.isSelected());
104
+        Button button = test.getButton(new ClassComponentMatcher(
105
+                ImageButton.class));
106
+        assertTrue(button.isEnabled());
107
+        assertTrue(button.isVisible());
108
+    }
109
+
110
+    @Test
111
+    public void testSetTrigger() {
112
+        ActionConditionDisplayPanel panel = new ActionConditionDisplayPanel(
113
+                new ActionCondition(2, CoreActionComponent.CHANNEL_NAME,
114
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
115
+                CoreActionType.CHANNEL_MESSAGE);
116
+        Panel test = new Panel(panel);
117
+
118
+        panel.setTrigger(null);
119
+
120
+        Matcher matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
121
+                TextLabel.class)).getText());
122
+        matcher.find();
123
+        assertEquals("...", matcher.group(1).trim());
124
+        UIComponent[] components = test.getUIComponents(new ClassComponentMatcher(
125
+                ActionConditionEditorPanel.class));
126
+        assertNotNull(components);
127
+        assertTrue(components.length == 1);
128
+        assertFalse(components[0].isEnabled());
129
+        assertTrue(components[0].isVisible());
130
+        ToggleButton toggle = test.getToggleButton(new ClassComponentMatcher(
131
+                ImageToggleButton.class));
132
+        assertTrue(toggle.isEnabled());
133
+        assertTrue(toggle.isVisible());
134
+        assertTrue(toggle.isSelected());
135
+
136
+        panel.setTrigger(CoreActionType.CHANNEL_MESSAGE);
137
+
138
+        matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
139
+                TextLabel.class)).getText());
140
+        matcher.find();
141
+        assertEquals("The message's name starts with 'abc'", matcher.group(1).
142
+                trim());
143
+        components = test.getUIComponents(new ClassComponentMatcher(
144
+                ActionConditionEditorPanel.class));
145
+        assertNotNull(components);
146
+        assertTrue(components.length == 1);
147
+        assertTrue(components[0].isEnabled());
148
+        assertFalse(components[0].isVisible());
149
+        toggle = test.getToggleButton(new ClassComponentMatcher(
150
+                ImageToggleButton.class));
151
+        assertTrue(toggle.isEnabled());
152
+        assertTrue(toggle.isVisible());
153
+        assertFalse(toggle.isSelected());
154
+    }
155
+
156
+    @Test
157
+    public void testDeleteCondition() {
158
+        ActionConditionDisplayPanel panel = new ActionConditionDisplayPanel(
159
+                new ActionCondition(2, CoreActionComponent.CHANNEL_NAME,
160
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
161
+                CoreActionType.CHANNEL_MESSAGE);
162
+        Panel test = new Panel(panel);
163
+        ActionConditionRemovalListener listener = mock(
164
+                ActionConditionRemovalListener.class);
165
+        panel.addConditionListener(listener);
166
+
167
+        Button button = test.getButton(new ClassComponentMatcher(
168
+                ImageButton.class));
169
+        assertTrue(button.isEnabled());
170
+        assertTrue(button.isVisible());
171
+        button.click();
172
+
173
+        verify(listener).conditionRemoved(panel);
174
+    }
175
+
176
+    @Test
177
+    public void testEditCondition() {
178
+        ActionConditionDisplayPanel panel = new ActionConditionDisplayPanel(
179
+                new ActionCondition(2, CoreActionComponent.CHANNEL_NAME,
180
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
181
+                CoreActionType.CHANNEL_MESSAGE);
182
+        Panel test = new Panel(panel);
183
+
184
+        UIComponent[] components = test.getUIComponents(new ClassComponentMatcher(
185
+                ActionConditionEditorPanel.class));
186
+        assertNotNull(components);
187
+        assertTrue(components.length == 1);
188
+        assertTrue(components[0].isEnabled());
189
+        assertFalse(components[0].isVisible());
190
+
191
+        ToggleButton toggle = test.getToggleButton(new ClassComponentMatcher(
192
+                ImageToggleButton.class));
193
+        assertTrue(toggle.isEnabled());
194
+        assertTrue(toggle.isVisible());
195
+        toggle.click();
196
+
197
+        assertTrue(components[0].isEnabled());
198
+        assertTrue(components[0].isVisible());
199
+
200
+        toggle.click();
201
+
202
+        assertTrue(components[0].isEnabled());
203
+        assertFalse(components[0].isVisible());
204
+    }
205
+
206
+    @Test
207
+    public void testSetEnabled() {
208
+        ActionConditionDisplayPanel panel = new ActionConditionDisplayPanel(
209
+                new ActionCondition(2, CoreActionComponent.CHANNEL_NAME,
210
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
211
+                CoreActionType.CHANNEL_MESSAGE);
212
+        Panel test = new Panel(panel);
213
+
214
+        UIComponent[] components = test.getUIComponents(new ClassComponentMatcher(
215
+                ActionConditionEditorPanel.class));
216
+        assertNotNull(components);
217
+        assertTrue(components.length == 1);
218
+        assertTrue(components[0].isEnabled());
219
+        ToggleButton toggle = test.getToggleButton(new ClassComponentMatcher(
220
+                ImageToggleButton.class));
221
+        assertTrue(toggle.isEnabled());
222
+        Button button = test.getButton(new ClassComponentMatcher(
223
+                ImageButton.class));
224
+        assertTrue(button.isEnabled());
225
+
226
+        panel.setEnabled(false);
227
+        assertFalse(components[0].isEnabled());
228
+        assertFalse(toggle.isEnabled());
229
+        assertFalse(button.isEnabled());
230
+        panel.setEnabled(true);
231
+        assertTrue(components[0].isEnabled());
232
+        assertTrue(toggle.isEnabled());
233
+        assertTrue(button.isEnabled());
234
+    }
235
+
236
+    @Test
237
+    public void testUpdateSentence() {
238
+        ActionConditionDisplayPanel panel = new ActionConditionDisplayPanel(
239
+                new ActionCondition(-1, null, null, ""), null);
240
+        Panel test = new Panel(panel);
241
+
242
+        Matcher matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
243
+                TextLabel.class)).getText());
244
+        matcher.find();
245
+        assertEquals("...", matcher.group(1).trim());
246
+        panel.setTrigger(CoreActionType.CHANNEL_MESSAGE);
247
+        matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
248
+                TextLabel.class)).getText());
249
+        matcher.find();
250
+        assertEquals("The ...", matcher.group(1).trim());
251
+        panel.setCondition(new ActionCondition(0, null, null, ""));
252
+        matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
253
+                TextLabel.class)).getText());
254
+        matcher.find();
255
+        assertEquals("The channel's ...", matcher.group(1).trim());
256
+        panel.setCondition(new ActionCondition(0,
257
+                CoreActionComponent.CHANNEL_NAME, null, ""));
258
+        matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
259
+                TextLabel.class)).getText());
260
+        matcher.find();
261
+        assertEquals("The channel's name ...", matcher.group(1).trim());
262
+        panel.setCondition(new ActionCondition(0,
263
+                CoreActionComponent.CHANNEL_NAME,
264
+                CoreActionComparison.STRING_STARTSWITH, ""));
265
+        matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
266
+                TextLabel.class)).getText());
267
+        matcher.find();
268
+        assertEquals("The channel's name starts with ''", matcher.group(1).
269
+                trim());
270
+        panel.setCondition(new ActionCondition(0,
271
+                CoreActionComponent.CHANNEL_NAME,
272
+                CoreActionComparison.STRING_STARTSWITH, "abc"));
273
+        matcher = pattern.matcher(test.getTextBox(new ClassComponentMatcher(
274
+                TextLabel.class)).getText());
275
+        matcher.find();
276
+        assertEquals("The channel's name starts with 'abc'", matcher.group(1).
277
+                trim());
278
+    }
279
+}

+ 266
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionEditorPanelTest.java Näytä tiedosto

@@ -0,0 +1,266 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.actions.ActionCondition;
26
+import com.dmdirc.actions.ActionManager;
27
+import com.dmdirc.actions.CoreActionComparison;
28
+import com.dmdirc.actions.CoreActionComponent;
29
+import com.dmdirc.actions.CoreActionType;
30
+import com.dmdirc.harness.ui.ClassAndNameComponentMatcher;
31
+import com.dmdirc.harness.ui.DMDircUITestCase;
32
+import javax.swing.JComboBox;
33
+import org.junit.Test;
34
+import org.uispec4j.ComboBox;
35
+import org.uispec4j.Panel;
36
+import org.uispec4j.TextBox;
37
+
38
+public class ActionConditionEditorPanelTest extends DMDircUITestCase {
39
+
40
+    static {
41
+        ActionManager.init();
42
+    }
43
+
44
+    @Test
45
+    public void testNullInitilisation() {
46
+        ActionConditionEditorPanel panel = new ActionConditionEditorPanel(
47
+                new ActionCondition(-1, null, null, ""), null);
48
+        Panel test = new Panel(panel);
49
+        assertFalse(test.getComboBox(new ClassAndNameComponentMatcher(
50
+                JComboBox.class, "argument")).isEnabled());
51
+        assertFalse(test.getComboBox(new ClassAndNameComponentMatcher(
52
+                JComboBox.class, "component")).isEnabled());
53
+        assertFalse(test.getComboBox(new ClassAndNameComponentMatcher(
54
+                JComboBox.class, "comparison")).isEnabled());
55
+        assertFalse(test.getInputTextBox().isEnabled());
56
+    }
57
+
58
+    @Test
59
+    public void testEmptyInitilisation() {
60
+        ActionConditionEditorPanel panel = new ActionConditionEditorPanel(
61
+                new ActionCondition(-1, null, null, ""),
62
+                CoreActionType.CHANNEL_MESSAGE);
63
+        Panel test = new Panel(panel);
64
+        assertTrue(test.getComboBox(new ClassAndNameComponentMatcher(
65
+                JComboBox.class, "argument")).isEnabled());
66
+        assertFalse(test.getComboBox(new ClassAndNameComponentMatcher(
67
+                JComboBox.class, "component")).isEnabled());
68
+        assertFalse(test.getComboBox(new ClassAndNameComponentMatcher(
69
+                JComboBox.class, "comparison")).isEnabled());
70
+        assertFalse(test.getInputTextBox().isEnabled());
71
+    }
72
+
73
+    @Test
74
+    public void testInitilisation() {
75
+        ActionConditionEditorPanel panel = new ActionConditionEditorPanel(
76
+                new ActionCondition(0, CoreActionComponent.CHANNEL_NAME,
77
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
78
+                CoreActionType.CHANNEL_MESSAGE);
79
+        Panel test = new Panel(panel);
80
+        assertTrue(test.getComboBox(new ClassAndNameComponentMatcher(
81
+                JComboBox.class, "argument")).isEnabled());
82
+        assertTrue(test.getComboBox(new ClassAndNameComponentMatcher(
83
+                JComboBox.class, "component")).isEnabled());
84
+        assertTrue(test.getComboBox(new ClassAndNameComponentMatcher(
85
+                JComboBox.class, "comparison")).isEnabled());
86
+        assertTrue(test.getInputTextBox().isEnabled());
87
+    }
88
+
89
+    @Test
90
+    public void testHandleArgument() {
91
+        ActionConditionEditorPanel panel = new ActionConditionEditorPanel(
92
+                new ActionCondition(-1, null, null, ""),
93
+                CoreActionType.CHANNEL_MESSAGE);
94
+        Panel test = new Panel(panel);
95
+
96
+        ComboBox argument = test.getComboBox(new ClassAndNameComponentMatcher(
97
+                JComboBox.class, "argument"));
98
+        ComboBox component = test.getComboBox(new ClassAndNameComponentMatcher(
99
+                JComboBox.class, "component"));
100
+        ComboBox comparison = test.getComboBox(new ClassAndNameComponentMatcher(
101
+                JComboBox.class, "comparison"));
102
+        TextBox target = test.getInputTextBox();
103
+
104
+        assertTrue(argument.isEnabled());
105
+        assertTrue(argument.selectionEquals(null));
106
+        assertFalse(component.isEnabled());
107
+        assertTrue(component.selectionEquals(null));
108
+        assertFalse(comparison.isEnabled());
109
+        assertTrue(comparison.selectionEquals(null));
110
+        assertFalse(target.isEnabled());
111
+        assertTrue(target.textIsEmpty());
112
+
113
+        panel = new ActionConditionEditorPanel(
114
+                new ActionCondition(0, CoreActionComponent.CHANNEL_NAME,
115
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
116
+                CoreActionType.CHANNEL_MESSAGE);
117
+        test = new Panel(panel);
118
+
119
+        argument = test.getComboBox(new ClassAndNameComponentMatcher(
120
+                JComboBox.class, "argument"));
121
+        component = test.getComboBox(new ClassAndNameComponentMatcher(
122
+                JComboBox.class, "component"));
123
+        comparison = test.getComboBox(new ClassAndNameComponentMatcher(
124
+                JComboBox.class, "comparison"));
125
+        target = test.getInputTextBox();
126
+
127
+        assertTrue(argument.isEnabled());
128
+        assertTrue(argument.selectionEquals("channel"));
129
+        assertTrue(component.isEnabled());
130
+        assertTrue(component.selectionEquals("name"));
131
+        assertTrue(comparison.isEnabled());
132
+        assertTrue(comparison.selectionEquals("starts with"));
133
+        assertTrue(target.isEnabled());
134
+        assertTrue(target.textEquals("abc"));
135
+
136
+        argument.select("user");
137
+
138
+        assertTrue(argument.isEnabled());
139
+        assertTrue(argument.selectionEquals("user"));
140
+        assertTrue(component.isEnabled());
141
+        assertTrue(component.selectionEquals(null));
142
+        assertFalse(comparison.isEnabled());
143
+        assertTrue(comparison.selectionEquals(null));
144
+        assertFalse(target.isEnabled());
145
+        assertTrue(target.textIsEmpty());
146
+    }
147
+
148
+    @Test
149
+    public void testHandleComponent() {
150
+        ActionConditionEditorPanel panel = new ActionConditionEditorPanel(
151
+                new ActionCondition(0, null, null, ""),
152
+                CoreActionType.CHANNEL_MESSAGE);
153
+        Panel test = new Panel(panel);
154
+
155
+        ComboBox argument = test.getComboBox(new ClassAndNameComponentMatcher(
156
+                JComboBox.class, "argument"));
157
+        ComboBox component = test.getComboBox(new ClassAndNameComponentMatcher(
158
+                JComboBox.class, "component"));
159
+        ComboBox comparison = test.getComboBox(new ClassAndNameComponentMatcher(
160
+                JComboBox.class, "comparison"));
161
+        TextBox target = test.getInputTextBox();
162
+
163
+        assertTrue(argument.isEnabled());
164
+        assertTrue(argument.selectionEquals("channel"));
165
+        assertTrue(component.isEnabled());
166
+        assertTrue(component.selectionEquals(null));
167
+        assertFalse(comparison.isEnabled());
168
+        assertTrue(comparison.selectionEquals(null));
169
+        assertFalse(target.isEnabled());
170
+        assertTrue(target.textIsEmpty());
171
+
172
+        panel = new ActionConditionEditorPanel(
173
+                new ActionCondition(0, CoreActionComponent.CHANNEL_NAME,
174
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
175
+                CoreActionType.CHANNEL_MESSAGE);
176
+        test = new Panel(panel);
177
+
178
+        argument = test.getComboBox(new ClassAndNameComponentMatcher(
179
+                JComboBox.class, "argument"));
180
+        component = test.getComboBox(new ClassAndNameComponentMatcher(
181
+                JComboBox.class, "component"));
182
+        comparison = test.getComboBox(new ClassAndNameComponentMatcher(
183
+                JComboBox.class, "comparison"));
184
+        target = test.getInputTextBox();
185
+
186
+        assertTrue(argument.isEnabled());
187
+        assertTrue(argument.selectionEquals("channel"));
188
+        assertTrue(component.isEnabled());
189
+        assertTrue(component.selectionEquals("name"));
190
+        assertTrue(comparison.isEnabled());
191
+        assertTrue(comparison.selectionEquals("starts with"));
192
+        assertTrue(target.isEnabled());
193
+        assertTrue(target.textEquals("abc"));
194
+
195
+        component.select("notification colour");
196
+
197
+        assertTrue(argument.isEnabled());
198
+        assertTrue(argument.selectionEquals("channel"));
199
+        assertTrue(component.isEnabled());
200
+        assertTrue(component.selectionEquals("notification colour"));
201
+        assertTrue(comparison.isEnabled());
202
+        assertTrue(comparison.selectionEquals(null));
203
+        assertFalse(target.isEnabled());
204
+        assertTrue(target.textIsEmpty());
205
+    }
206
+
207
+    @Test
208
+    public void testHandleComparison() {
209
+        ActionConditionEditorPanel panel = new ActionConditionEditorPanel(
210
+                new ActionCondition(0, CoreActionComponent.CHANNEL_NAME, null,
211
+                ""),
212
+                CoreActionType.CHANNEL_MESSAGE);
213
+        Panel test = new Panel(panel);
214
+
215
+        ComboBox argument = test.getComboBox(new ClassAndNameComponentMatcher(
216
+                JComboBox.class, "argument"));
217
+        ComboBox component = test.getComboBox(new ClassAndNameComponentMatcher(
218
+                JComboBox.class, "component"));
219
+        ComboBox comparison = test.getComboBox(new ClassAndNameComponentMatcher(
220
+                JComboBox.class, "comparison"));
221
+        TextBox target = test.getInputTextBox();
222
+
223
+        assertTrue(argument.isEnabled());
224
+        assertTrue(argument.selectionEquals("channel"));
225
+        assertTrue(component.isEnabled());
226
+        assertTrue(component.selectionEquals("name"));
227
+        assertTrue(comparison.isEnabled());
228
+        assertTrue(comparison.selectionEquals(null));
229
+        assertFalse(target.isEnabled());
230
+        assertTrue(target.textIsEmpty());
231
+
232
+        panel = new ActionConditionEditorPanel(
233
+                new ActionCondition(0, CoreActionComponent.CHANNEL_NAME,
234
+                CoreActionComparison.STRING_STARTSWITH, "abc"),
235
+                CoreActionType.CHANNEL_MESSAGE);
236
+        test = new Panel(panel);
237
+
238
+        argument = test.getComboBox(new ClassAndNameComponentMatcher(
239
+                JComboBox.class, "argument"));
240
+        component = test.getComboBox(new ClassAndNameComponentMatcher(
241
+                JComboBox.class, "component"));
242
+        comparison = test.getComboBox(new ClassAndNameComponentMatcher(
243
+                JComboBox.class, "comparison"));
244
+        target = test.getInputTextBox();
245
+
246
+        assertTrue(argument.isEnabled());
247
+        assertTrue(argument.selectionEquals("channel"));
248
+        assertTrue(component.isEnabled());
249
+        assertTrue(component.selectionEquals("name"));
250
+        assertTrue(comparison.isEnabled());
251
+        assertTrue(comparison.selectionEquals("starts with"));
252
+        assertTrue(target.isEnabled());
253
+        assertTrue(target.textEquals("abc"));
254
+
255
+        comparison.select("equals");
256
+
257
+        assertTrue(argument.isEnabled());
258
+        assertTrue(argument.selectionEquals("channel"));
259
+        assertTrue(component.isEnabled());
260
+        assertTrue(component.selectionEquals("name"));
261
+        assertTrue(comparison.isEnabled());
262
+        assertTrue(comparison.selectionEquals("equals"));
263
+        assertTrue(target.isEnabled());
264
+        assertTrue(target.textEquals("abc"));
265
+    }
266
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsListPanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionConditionsListPanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsPanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionConditionsPanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionConditionsTreePanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionConditionsTreePanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionNamePanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionNamePanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionResponsePanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionResponsePanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionSubstitutionsPanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionSubstitutionsPanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersListPanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionTriggersListPanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTriggersPanelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionTriggersPanelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 37
- 0
test/com/dmdirc/addons/ui_swing/dialogs/actioneditor/ActionTypeModelTest.java Näytä tiedosto

@@ -0,0 +1,37 @@
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.addons.ui_swing.dialogs.actioneditor;
24
+
25
+import com.dmdirc.harness.ui.DMDircUITestCase;
26
+import org.junit.Test;
27
+
28
+/**
29
+ *
30
+ */
31
+public class ActionTypeModelTest extends DMDircUITestCase {
32
+
33
+    @Test
34
+    public void testNothing() {
35
+
36
+    }
37
+}

+ 59
- 0
test/com/dmdirc/harness/ui/ClassAndNameComponentMatcher.java Näytä tiedosto

@@ -0,0 +1,59 @@
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.uispec4j.finder.ComponentMatcher;
27
+
28
+/**
29
+ * Component matcher that matches components on their class and name.
30
+ */
31
+public class ClassAndNameComponentMatcher implements ComponentMatcher {
32
+
33
+    private Class clazz;
34
+    private String name;
35
+
36
+    /**
37
+     * Creates a new component matcher than matches components on their
38
+     * class and their name.
39
+     *
40
+     * @param clazz Class to match
41
+     * @param name Component name to match
42
+     */
43
+    public ClassAndNameComponentMatcher(final Class clazz, final String name) {
44
+        this.clazz = clazz;
45
+        this.name = name;
46
+    }
47
+
48
+    /**
49
+     * {@inheritDoc}
50
+     * 
51
+     * @param component Component to try and match
52
+     *
53
+     * @return true iif the component matches
54
+     */
55
+    @Override
56
+    public boolean matches(final Component component) {
57
+        return component.getClass() == clazz && component.getName().equals(name);
58
+    }
59
+}

test/com/dmdirc/addons/ui_swing/ClassComponentMatcher.java → test/com/dmdirc/harness/ui/ClassComponentMatcher.java Näytä tiedosto

@@ -20,11 +20,10 @@
20 20
  * SOFTWARE.
21 21
  */
22 22
 
23
-package com.dmdirc.addons.ui_swing;
23
+package com.dmdirc.harness.ui;
24 24
 
25 25
 import java.awt.Component;
26 26
 
27
-import org.uispec4j.Panel;
28 27
 import org.uispec4j.finder.ComponentMatcher;
29 28
 
30 29
 /**
@@ -32,18 +31,15 @@ import org.uispec4j.finder.ComponentMatcher;
32 31
  */
33 32
 public class ClassComponentMatcher implements ComponentMatcher {
34 33
 
35
-    private final Panel comp;
36 34
     private final Class clazz;
37 35
 
38 36
     /**
39 37
      * Creates a new component matcher, searching for any components matching
40 38
      * the specified class in the specified component.
41 39
      *
42
-     * @param comp Component to search in
43 40
      * @param clazz Class to search for
44 41
      */
45
-    public ClassComponentMatcher(final Panel comp, final Class clazz) {
46
-        this.comp = comp;
42
+    public ClassComponentMatcher(final Class clazz) {
47 43
         this.clazz = clazz;
48 44
     }
49 45
 
@@ -56,6 +52,6 @@ public class ClassComponentMatcher implements ComponentMatcher {
56 52
      */
57 53
     @Override
58 54
     public boolean matches(final Component component) {
59
-        return component    .getClass() == clazz;
55
+        return component.getClass() == clazz;
60 56
     }
61 57
 }

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

@@ -0,0 +1,104 @@
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.Main;
26
+import com.dmdirc.WritableFrameContainer;
27
+import com.dmdirc.addons.ui_swing.MainFrame;
28
+import com.dmdirc.addons.ui_swing.SwingController;
29
+import com.dmdirc.addons.ui_swing.SwingWindowFactory;
30
+import com.dmdirc.addons.ui_swing.components.frames.CustomInputFrame;
31
+import com.dmdirc.config.ConfigManager;
32
+import com.dmdirc.config.IdentityManager;
33
+import com.dmdirc.config.InvalidIdentityFileException;
34
+import com.dmdirc.plugins.PluginManager;
35
+import com.dmdirc.ui.messages.IRCDocument;
36
+import org.junit.Test;
37
+import org.uispec4j.UISpecTestCase;
38
+import static org.mockito.Mockito.*;
39
+
40
+/**
41
+ * Provides a basic test environment for testing the DMDirc Swing UI.
42
+ */
43
+public class DMDircUITestCase extends UISpecTestCase {
44
+
45
+    static {
46
+        try {
47
+            IdentityManager.load();
48
+        } catch (InvalidIdentityFileException ex) {
49
+            //Ignore
50
+        }
51
+
52
+        IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
53
+        IdentityManager.getAddonIdentity().setOption("test", "desktopbackground", "");
54
+        IdentityManager.getAddonIdentity().setOption("test", "desktopbackgroundoption", "STRETCH");
55
+        IdentityManager.getAddonIdentity().setOption("test", "windowMenuItems", "1");
56
+        IdentityManager.getAddonIdentity().setOption("test", "windowMenuScrollInterval", "1");
57
+        Main.ensureExists(PluginManager.getPluginManager(), "tabcompletion");
58
+    }
59
+
60
+    /**
61
+     * Returns a mocked SwingController.
62
+     *
63
+     * @return SwingController mock
64
+     */
65
+    public static SwingController getMockedController() {
66
+        SwingController controller = mock(SwingController.class);
67
+        final SwingWindowFactory windowFactory = mock(SwingWindowFactory.class);
68
+        when(controller.getDomain()).thenReturn("test");
69
+        when(controller.getWindowFactory()).thenReturn(windowFactory);
70
+
71
+        return controller;
72
+    }
73
+
74
+    /**
75
+     * Returns a mocked SwingController that contains a mocked Main Frame.
76
+     *
77
+     * @return SwingController + MainFrame mock
78
+     */
79
+    public static SwingController getMockedControllerAndMainFrame() {
80
+        SwingController controller = getMockedController();
81
+        final MainFrame mainFrame = new MainFrame(controller);
82
+        when(controller.getMainFrame()).thenReturn(mainFrame);
83
+
84
+        return controller;
85
+    }
86
+
87
+    /**
88
+     * Returns a mocked WritableFrameContainer.
89
+     *
90
+     * @return FrameContainer mock
91
+     */
92
+    public static WritableFrameContainer<CustomInputFrame> getMockedContainer() {
93
+        final IRCDocument document = mock(IRCDocument.class);
94
+        @SuppressWarnings("unchecked")
95
+        final WritableFrameContainer<CustomInputFrame> container = mock(
96
+                WritableFrameContainer.class);
97
+        final ConfigManager config = mock(ConfigManager.class);
98
+        when(container.getDocument()).thenReturn(document);
99
+        when(container.getConfigManager()).thenReturn(config);
100
+        when(config.getOption(anyString(), anyString())).thenReturn("mirc");
101
+
102
+        return container;
103
+    }
104
+}

Loading…
Peruuta
Tallenna