|
@@ -0,0 +1,103 @@
|
|
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.dialogs.actionsmanager;
|
|
24
|
+
|
|
25
|
+import com.dmdirc.actions.ActionManager;
|
|
26
|
+import com.dmdirc.config.IdentityManager;
|
|
27
|
+import com.dmdirc.harness.ui.ButtonTextFinder;
|
|
28
|
+import com.dmdirc.harness.ui.ClassFinder;
|
|
29
|
+import com.dmdirc.ui.swing.components.StandardInputDialog;
|
|
30
|
+
|
|
31
|
+import javax.swing.JPanel;
|
|
32
|
+import javax.swing.text.JTextComponent;
|
|
33
|
+import org.fest.swing.core.GenericTypeMatcher;
|
|
34
|
+import org.fest.swing.finder.WindowFinder;
|
|
35
|
+import org.fest.swing.fixture.DialogFixture;
|
|
36
|
+import org.junit.After;
|
|
37
|
+import org.junit.Before;
|
|
38
|
+import org.junit.Test;
|
|
39
|
+import static org.junit.Assert.*;
|
|
40
|
+
|
|
41
|
+public class ActionsManagerDialogTest {
|
|
42
|
+
|
|
43
|
+ private DialogFixture window;
|
|
44
|
+
|
|
45
|
+ @Before
|
|
46
|
+ public void setUp() {
|
|
47
|
+ IdentityManager.load();
|
|
48
|
+ ActionManager.loadActions();
|
|
49
|
+
|
|
50
|
+ if (ActionManager.getGroups().containsKey("amd-ui-test1")) {
|
|
51
|
+ ActionManager.removeGroup("amd-ui-test1");
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ window = new DialogFixture(ActionsManagerDialog.getActionsManagerDialog());
|
|
55
|
+ window.show();
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ @After
|
|
59
|
+ public void tearDown() {
|
|
60
|
+ if (window != null) {
|
|
61
|
+ window.cleanUp();
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ @Test
|
|
66
|
+ public void testAddGroup() {
|
|
67
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, null))
|
|
68
|
+ .button(new ButtonTextFinder("Add")).click();
|
|
69
|
+
|
|
70
|
+ DialogFixture newwin = WindowFinder.findDialog(StandardInputDialog.class)
|
|
71
|
+ .withTimeout(5000).using(window.robot);
|
|
72
|
+ newwin.requireVisible();
|
|
73
|
+ assertEquals("New action group", newwin.target.getTitle());
|
|
74
|
+
|
|
75
|
+ newwin.button(new ButtonTextFinder("Cancel")).click();
|
|
76
|
+ newwin.requireNotVisible();
|
|
77
|
+
|
|
78
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, null))
|
|
79
|
+ .button(new ButtonTextFinder("Add")).click();
|
|
80
|
+
|
|
81
|
+ newwin = WindowFinder.findDialog(StandardInputDialog.class)
|
|
82
|
+ .withTimeout(5000).using(window.robot);
|
|
83
|
+ newwin.requireVisible();
|
|
84
|
+ assertEquals("New action group", newwin.target.getTitle());
|
|
85
|
+ newwin.button(new ButtonTextFinder("OK")).requireDisabled();
|
|
86
|
+
|
|
87
|
+ newwin.textBox(new GenericTypeMatcher<JTextComponent>() {
|
|
88
|
+ @Override
|
|
89
|
+ protected boolean isMatching(JTextComponent arg0) {
|
|
90
|
+ return arg0.getClass().equals(javax.swing.JTextField.class);
|
|
91
|
+ }
|
|
92
|
+ }).enterText("amd-ui-test1");
|
|
93
|
+ newwin.button(new ButtonTextFinder("OK")).requireEnabled().click();
|
|
94
|
+
|
|
95
|
+ // Ensure it's added
|
|
96
|
+ window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
|
|
97
|
+ }
|
|
98
|
+
|
|
99
|
+ public static junit.framework.Test suite() {
|
|
100
|
+ return new junit.framework.JUnit4TestAdapter(ActionsManagerDialogTest.class);
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+}
|