@@ -20,7 +20,7 @@ public class TestUtils {
2020 private static boolean connectionClosing ;
2121 private static String runtimeVersion ;
2222 private static CountDownLatch disconnectedLatch ;
23- private static final String openfin_app_url = "http://test.openf.in/test.html" ; // simple test app
23+ public static final String openfin_app_url = "http://test.openf.in/test.html" ; // simple test app
2424
2525 public static DesktopConnection setupConnection (String connectionUuid ) throws Exception {
2626 logger .debug ("starting" );
@@ -200,5 +200,33 @@ public void eventReceived(ActionEvent actionEvent) {
200200 assertEquals ("Close application timeout " + application .getUuid (), stoppedLatch .getCount (), 0 );
201201 }
202202
203+ public static WindowOptions getWindowOptions (String name , String url ) throws Exception {
204+ WindowOptions options = new WindowOptions (name , url );
205+ options .setDefaultWidth (200 );
206+ options .setDefaultHeight (200 );
207+ options .setDefaultTop (200 );
208+ options .setDefaultLeft (200 );
209+ options .setSaveWindowState (false ); // so the window opens with the same default bounds every time
210+ options .setAutoShow (true );
211+ options .setFrame (true );
212+ options .setResizable (true );
213+ return options ;
214+ }
215+
216+ public static Window createChildWindow (Application application , WindowOptions childOptions , DesktopConnection desktopConnection ) throws Exception {
203217
218+ final CountDownLatch windowCreatedLatch = new CountDownLatch (1 );
219+ // use window-end-load event to wait for the window to finish loading
220+ application .addEventListener ("window-end-load" , actionEvent -> {
221+ if (actionEvent .getEventObject ().has ("name" )) {
222+ if (childOptions .getName ().equals (actionEvent .getEventObject ().getString ("name" ))) {
223+ windowCreatedLatch .countDown ();
224+ }
225+ }
226+ }, null );
227+ application .createChildWindow (childOptions , null );
228+ windowCreatedLatch .await (10 , TimeUnit .SECONDS );
229+ assertEquals ("createChildWindow timeout" , windowCreatedLatch .getCount (), 0 );
230+ return Window .wrap (application .getOptions ().getUUID (), childOptions .getName (), desktopConnection );
231+ }
204232}
0 commit comments