Skip to content

Commit 3a5e3bd

Browse files
committed
ADAP-102 unit test case for getChildWindows
1 parent f4be5a8 commit 3a5e3bd

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/test/java/com/openfin/desktop/ApplicationTest.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,52 @@ public void onError(Ack ack) {
361361
}
362362
}, desktopConnection);
363363

364-
latch.await(50, TimeUnit.SECONDS);
364+
latch.await(10, TimeUnit.SECONDS);
365365

366366
assertEquals(0, latch.getCount());
367+
}
368+
369+
@Test
370+
public void getChildWindows() throws Exception {
371+
final int cnt = 5;
372+
Application application = TestUtils.runApplication(TestUtils.getAppOptions(null), desktopConnection);
373+
374+
for (int i=0; i<cnt; i++) {
375+
WindowOptions childOptions = TestUtils.getWindowOptions("childWindow_" + i, TestUtils.openfin_app_url);
376+
TestUtils.createChildWindow(application, childOptions, desktopConnection);
377+
}
367378

379+
final CountDownLatch latch = new CountDownLatch(1);
380+
final AtomicInteger winCnt = new AtomicInteger(0);
381+
application.getChildWindows(
382+
new AsyncCallback<List<Window>>() {
383+
@Override
384+
public void onSuccess(List<Window> windows) {
385+
for (Window w : windows) {
386+
try {
387+
w.close();
388+
winCnt.incrementAndGet();
389+
}
390+
catch (DesktopException e) {
391+
e.printStackTrace();
392+
}
393+
}
394+
latch.countDown();
395+
}
396+
}, new AckListener() {
397+
@Override
398+
public void onSuccess(Ack ack) {
399+
}
368400

401+
@Override
402+
public void onError(Ack ack) {
403+
logger.info("error getting child windows: {}", ack.getReason());
404+
}
405+
});
406+
407+
latch.await(10, TimeUnit.SECONDS);
408+
409+
assertEquals(0, latch.getCount());
410+
assertEquals(cnt, winCnt.get());
369411
}
370412
}

0 commit comments

Comments
 (0)