|
@@ -32,9 +32,10 @@ import javax.swing.JPanel;
|
32
|
32
|
import javax.swing.text.JTextComponent;
|
33
|
33
|
|
34
|
34
|
import org.fest.swing.core.EventMode;
|
|
35
|
+import org.fest.swing.finder.JOptionPaneFinder;
|
35
|
36
|
import org.fest.swing.finder.WindowFinder;
|
36
|
37
|
import org.fest.swing.fixture.DialogFixture;
|
37
|
|
-import org.fest.swing.fixture.JTextComponentFixture;
|
|
38
|
+import org.fest.swing.fixture.JOptionPaneFixture;
|
38
|
39
|
import org.junit.After;
|
39
|
40
|
import org.junit.Before;
|
40
|
41
|
import org.junit.Test;
|
|
@@ -47,15 +48,9 @@ public class ActionsManagerDialogTest {
|
47
|
48
|
@Before
|
48
|
49
|
public void setUp() {
|
49
|
50
|
IdentityManager.load();
|
50
|
|
- ActionManager.loadActions();
|
|
51
|
+ ActionManager.init();
|
51
|
52
|
|
52
|
|
- if (ActionManager.getGroups().containsKey("amd-ui-test1")) {
|
53
|
|
- ActionManager.removeGroup("amd-ui-test1");
|
54
|
|
- }
|
55
|
|
-
|
56
|
|
- window = new DialogFixture(ActionsManagerDialog.getActionsManagerDialog());
|
57
|
|
- window.robot.settings().eventMode(EventMode.AWT);
|
58
|
|
- window.show();
|
|
53
|
+ removeGroups();
|
59
|
54
|
}
|
60
|
55
|
|
61
|
56
|
@After
|
|
@@ -63,15 +58,23 @@ public class ActionsManagerDialogTest {
|
63
|
58
|
if (window != null) {
|
64
|
59
|
window.cleanUp();
|
65
|
60
|
}
|
66
|
|
-
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ protected void removeGroups() {
|
67
|
64
|
if (ActionManager.getGroups().containsKey("amd-ui-test1")) {
|
68
|
65
|
ActionManager.removeGroup("amd-ui-test1");
|
69
|
66
|
}
|
|
67
|
+
|
|
68
|
+ if (ActionManager.getGroups().containsKey("amd-ui-test2")) {
|
|
69
|
+ ActionManager.removeGroup("amd-ui-test2");
|
|
70
|
+ }
|
70
|
71
|
}
|
71
|
72
|
|
72
|
|
- @Test(timeout=30000)
|
|
73
|
+ @Test
|
73
|
74
|
public void testAddGroup() throws InterruptedException {
|
74
|
|
- window.panel(new ClassFinder<JPanel>(JPanel.class, null))
|
|
75
|
+ setupWindow();
|
|
76
|
+
|
|
77
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
75
|
78
|
.button(new ButtonTextFinder("Add")).click();
|
76
|
79
|
|
77
|
80
|
DialogFixture newwin = WindowFinder.findDialog(StandardInputDialog.class)
|
|
@@ -84,7 +87,7 @@ public class ActionsManagerDialogTest {
|
84
|
87
|
|
85
|
88
|
newwin.requireNotVisible();
|
86
|
89
|
|
87
|
|
- window.panel(new ClassFinder<JPanel>(JPanel.class, null))
|
|
90
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
88
|
91
|
.button(new ButtonTextFinder("Add")).click();
|
89
|
92
|
|
90
|
93
|
newwin = WindowFinder.findDialog(StandardInputDialog.class)
|
|
@@ -93,14 +96,105 @@ public class ActionsManagerDialogTest {
|
93
|
96
|
newwin.requireVisible();
|
94
|
97
|
newwin.button(new ButtonTextFinder("OK")).requireDisabled();
|
95
|
98
|
|
96
|
|
- final JTextComponentFixture jtcf = newwin.textBox(
|
97
|
|
- new ClassFinder<JTextComponent>(javax.swing.JTextField.class, null));
|
98
|
|
- jtcf.enterText("amd-ui-test1");
|
|
99
|
+ newwin.textBox(new ClassFinder<JTextComponent>(javax.swing.JTextField.class,
|
|
100
|
+ null)).enterText("amd-ui-test1");
|
99
|
101
|
|
100
|
102
|
newwin.button(new ButtonTextFinder("OK")).requireEnabled().click();
|
101
|
103
|
|
102
|
|
- // Ensure it's added
|
103
|
104
|
window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
|
|
105
|
+
|
|
106
|
+ assertTrue(ActionManager.getGroups().containsKey("amd-ui-test1"));
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ @Test
|
|
110
|
+ public void testDeleteGroup() {
|
|
111
|
+ ActionManager.makeGroup("amd-ui-test1");
|
|
112
|
+ setupWindow();
|
|
113
|
+
|
|
114
|
+ window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
|
|
115
|
+
|
|
116
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
|
117
|
+ .button(new ButtonTextFinder("Delete")).requireEnabled().click();
|
|
118
|
+
|
|
119
|
+ JOptionPaneFixture newwin = JOptionPaneFinder.findOptionPane()
|
|
120
|
+ .withTimeout(5000).using(window.robot);
|
|
121
|
+ newwin.buttonWithText("No").click();
|
|
122
|
+
|
|
123
|
+ assertTrue(ActionManager.getGroups().containsKey("amd-ui-test1"));
|
|
124
|
+ window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
|
|
125
|
+
|
|
126
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
|
127
|
+ .button(new ButtonTextFinder("Delete")).click();
|
|
128
|
+
|
|
129
|
+ newwin = JOptionPaneFinder.findOptionPane()
|
|
130
|
+ .withTimeout(5000).using(window.robot);
|
|
131
|
+ newwin.buttonWithText("Yes").click();
|
|
132
|
+
|
|
133
|
+ assertTrue(window.list().selection().length != 1 ||
|
|
134
|
+ !window.list().selection()[0].equals("amd-ui-test1"));
|
|
135
|
+
|
|
136
|
+ assertFalse(ActionManager.getGroups().containsKey("amd-ui-test1"));
|
|
137
|
+ }
|
|
138
|
+
|
|
139
|
+ @Test
|
|
140
|
+ public void testEnablingGroupButtons() {
|
|
141
|
+ ActionManager.makeGroup("amd-ui-test1");
|
|
142
|
+ setupWindow();
|
|
143
|
+
|
|
144
|
+ window.list().selectItem("performs").requireSelectedItems("performs");
|
|
145
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
|
146
|
+ .button(new ButtonTextFinder("Delete")).requireDisabled();
|
|
147
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
|
148
|
+ .button(new ButtonTextFinder("Edit")).requireDisabled();
|
|
149
|
+
|
|
150
|
+ window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
|
|
151
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
|
152
|
+ .button(new ButtonTextFinder("Delete")).requireEnabled();
|
|
153
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
|
154
|
+ .button(new ButtonTextFinder("Edit")).requireEnabled();
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ public void editGroupCheck(final String button) {
|
|
158
|
+ ActionManager.makeGroup("amd-ui-test1");
|
|
159
|
+ setupWindow();
|
|
160
|
+
|
|
161
|
+ window.list().selectItem("amd-ui-test1").requireSelectedItems("amd-ui-test1");
|
|
162
|
+ window.panel(new ClassFinder<JPanel>(JPanel.class, "Groups"))
|
|
163
|
+ .button(new ButtonTextFinder("Edit")).requireEnabled().click();
|
|
164
|
+
|
|
165
|
+ DialogFixture newwin = WindowFinder.findDialog(StandardInputDialog.class)
|
|
166
|
+ .withTimeout(5000).using(window.robot);
|
|
167
|
+
|
|
168
|
+ newwin.requireVisible();
|
|
169
|
+ assertEquals("Edit action group", newwin.target.getTitle());
|
|
170
|
+
|
|
171
|
+ assertEquals("amd-ui-test1",
|
|
172
|
+ newwin.textBox(new ClassFinder<JTextComponent>(javax.swing.JTextField.class,
|
|
173
|
+ null)).target.getText());
|
|
174
|
+
|
|
175
|
+ newwin.textBox(new ClassFinder<JTextComponent>(javax.swing.JTextField.class,
|
|
176
|
+ null)).deleteText().enterText("amd-ui-test2");
|
|
177
|
+ newwin.button(new ButtonTextFinder(button)).requireEnabled().click();
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ @Test
|
|
181
|
+ public void testEditGroupCancel() {
|
|
182
|
+ editGroupCheck("Cancel");
|
|
183
|
+ assertTrue(ActionManager.getGroups().containsKey("amd-ui-test1"));
|
|
184
|
+ assertFalse(ActionManager.getGroups().containsKey("amd-ui-test2"));
|
|
185
|
+ }
|
|
186
|
+
|
|
187
|
+ @Test
|
|
188
|
+ public void testEditGroupOK() {
|
|
189
|
+ editGroupCheck("OK");
|
|
190
|
+ assertFalse(ActionManager.getGroups().containsKey("amd-ui-test1"));
|
|
191
|
+ assertTrue(ActionManager.getGroups().containsKey("amd-ui-test2"));
|
|
192
|
+ }
|
|
193
|
+
|
|
194
|
+ protected void setupWindow() {
|
|
195
|
+ window = new DialogFixture(ActionsManagerDialog.getActionsManagerDialog());
|
|
196
|
+ window.robot.settings().eventMode(EventMode.AWT);
|
|
197
|
+ window.show();
|
104
|
198
|
}
|
105
|
199
|
|
106
|
200
|
public static junit.framework.Test suite() {
|