|
@@ -34,6 +34,8 @@ import com.dmdirc.addons.ui_swing.dialogs.actionsmanager.ActionsManagerDialog;
|
34
|
34
|
import com.dmdirc.addons.ui_swing.dialogs.aliases.AliasManagerDialog;
|
35
|
35
|
import com.dmdirc.addons.ui_swing.dialogs.prefs.SwingPreferencesDialog;
|
36
|
36
|
import com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog;
|
|
37
|
+import java.lang.reflect.InvocationTargetException;
|
|
38
|
+import javax.swing.SwingUtilities;
|
37
|
39
|
import org.fest.swing.finder.WindowFinder;
|
38
|
40
|
import org.fest.swing.fixture.DialogFixture;
|
39
|
41
|
import org.fest.swing.fixture.FrameFixture;
|
|
@@ -47,31 +49,29 @@ import static org.junit.Assert.*;
|
47
|
49
|
@RunWith(UIClassTestRunner.class)
|
48
|
50
|
public class MainFrameTest implements UITestIface {
|
49
|
51
|
|
50
|
|
- private FrameFixture window;
|
|
52
|
+ private static FrameFixture window;
|
|
53
|
+ private DialogFixture newwin;
|
51
|
54
|
|
52
|
55
|
@BeforeClass
|
53
|
56
|
public static void setUpClass() {
|
|
57
|
+ IdentityManager.load();
|
|
58
|
+
|
54
|
59
|
Main.setUI(new SwingController());
|
|
60
|
+
|
55
|
61
|
}
|
56
|
62
|
|
57
|
63
|
@Before
|
58
|
64
|
public void setUp() {
|
59
|
|
- IdentityManager.load();
|
60
|
|
- window = new FrameFixture(SwingController.getMainFrame());
|
61
|
|
- window.show();
|
62
|
|
- }
|
63
|
|
-
|
64
|
|
- @After
|
65
|
|
- public void tearDown() {
|
66
|
|
- if (window != null) {
|
67
|
|
- window.cleanUp();
|
|
65
|
+ if (window == null) {
|
|
66
|
+ window = new FrameFixture(SwingController.getMainFrame());
|
|
67
|
+ window.show();
|
68
|
68
|
}
|
69
|
69
|
}
|
70
|
70
|
|
71
|
71
|
@Test
|
72
|
72
|
public void testNewServerDialog() {
|
73
|
73
|
window.menuItemWithPath("Server", "New Server...").click();
|
74
|
|
- DialogFixture newwin = WindowFinder.findDialog(NewServerDialog.class)
|
|
74
|
+ newwin = WindowFinder.findDialog(NewServerDialog.class)
|
75
|
75
|
.withTimeout(5000).using(window.robot);
|
76
|
76
|
newwin.requireVisible();
|
77
|
77
|
}
|
|
@@ -79,7 +79,7 @@ public class MainFrameTest implements UITestIface {
|
79
|
79
|
@Test
|
80
|
80
|
public void testAboutDialog() {
|
81
|
81
|
window.menuItemWithPath("Help", "About").click();
|
82
|
|
- DialogFixture newwin = WindowFinder.findDialog(AboutDialog.class)
|
|
82
|
+ newwin = WindowFinder.findDialog(AboutDialog.class)
|
83
|
83
|
.withTimeout(5000).using(window.robot);
|
84
|
84
|
newwin.requireVisible();
|
85
|
85
|
}
|
|
@@ -87,7 +87,7 @@ public class MainFrameTest implements UITestIface {
|
87
|
87
|
@Test
|
88
|
88
|
public void testFeedbackDialog() {
|
89
|
89
|
window.menuItemWithPath("Help", "Send Feedback").click();
|
90
|
|
- DialogFixture newwin = WindowFinder.findDialog(FeedbackDialog.class)
|
|
90
|
+ newwin = WindowFinder.findDialog(FeedbackDialog.class)
|
91
|
91
|
.withTimeout(5000).using(window.robot);
|
92
|
92
|
newwin.requireVisible();
|
93
|
93
|
}
|
|
@@ -95,7 +95,7 @@ public class MainFrameTest implements UITestIface {
|
95
|
95
|
@Test
|
96
|
96
|
public void testPreferencesDialog() {
|
97
|
97
|
window.menuItemWithPath("Settings", "Preferences").click();
|
98
|
|
- DialogFixture newwin = WindowFinder.findDialog(SwingPreferencesDialog.class)
|
|
98
|
+ newwin = WindowFinder.findDialog(SwingPreferencesDialog.class)
|
99
|
99
|
.withTimeout(5000).using(window.robot);
|
100
|
100
|
newwin.requireVisible();
|
101
|
101
|
}
|
|
@@ -103,7 +103,7 @@ public class MainFrameTest implements UITestIface {
|
103
|
103
|
@Test
|
104
|
104
|
public void testProfileManagerDialog() {
|
105
|
105
|
window.menuItemWithPath("Settings", "Profile Manager").click();
|
106
|
|
- DialogFixture newwin = WindowFinder.findDialog(ProfileManagerDialog.class)
|
|
106
|
+ newwin = WindowFinder.findDialog(ProfileManagerDialog.class)
|
107
|
107
|
.withTimeout(5000).using(window.robot);
|
108
|
108
|
newwin.requireVisible();
|
109
|
109
|
}
|
|
@@ -111,7 +111,7 @@ public class MainFrameTest implements UITestIface {
|
111
|
111
|
@Test
|
112
|
112
|
public void testActionsManagerDialog() {
|
113
|
113
|
window.menuItemWithPath("Settings", "Actions Manager").click();
|
114
|
|
- DialogFixture newwin = WindowFinder.findDialog(ActionsManagerDialog.class)
|
|
114
|
+ newwin = WindowFinder.findDialog(ActionsManagerDialog.class)
|
115
|
115
|
.withTimeout(5000).using(window.robot);
|
116
|
116
|
newwin.requireVisible();
|
117
|
117
|
}
|
|
@@ -119,7 +119,7 @@ public class MainFrameTest implements UITestIface {
|
119
|
119
|
@Test
|
120
|
120
|
public void testAliasManagerDialog() {
|
121
|
121
|
window.menuItemWithPath("Settings", "Alias Manager").click();
|
122
|
|
- DialogFixture newwin = WindowFinder.findDialog(AliasManagerDialog.class)
|
|
122
|
+ newwin = WindowFinder.findDialog(AliasManagerDialog.class)
|
123
|
123
|
.withTimeout(5000).using(window.robot);
|
124
|
124
|
newwin.requireVisible();
|
125
|
125
|
}
|
|
@@ -134,4 +134,24 @@ public class MainFrameTest implements UITestIface {
|
134
|
134
|
window.menuItemWithPath("Server", "Server settings").requireDisabled();
|
135
|
135
|
}
|
136
|
136
|
|
|
137
|
+ @Override @After
|
|
138
|
+ public void tearDown() throws InterruptedException, InvocationTargetException {
|
|
139
|
+ SwingUtilities.invokeAndWait(new Runnable() {
|
|
140
|
+ @Override
|
|
141
|
+ public void run() {
|
|
142
|
+ close();
|
|
143
|
+ }
|
|
144
|
+ });
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+ protected void close() {
|
|
148
|
+ if (newwin != null && newwin.target != null) {
|
|
149
|
+ try {
|
|
150
|
+ newwin.target.dispose();
|
|
151
|
+ } catch (Throwable ex) {
|
|
152
|
+ ex.printStackTrace();
|
|
153
|
+ }
|
|
154
|
+ }
|
|
155
|
+ }
|
|
156
|
+
|
137
|
157
|
}
|