Skip to content

Commit 26af64d

Browse files
committed
ADAP-102 added unit test cases for Applicaiton.getTrayIconInfo, Applicaiton.isRunning and Applicaiton.registerCustomData
1 parent fdc6849 commit 26af64d

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

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

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,4 +464,96 @@ public void onError(Ack ack) {
464464

465465
assertEquals(0, latch.getCount());
466466
}
467+
468+
@Test
469+
public void getTrayIconInfo() throws Exception {
470+
Application application = TestUtils.runApplication(TestUtils.getAppOptions(null), desktopConnection);
471+
final CountDownLatch latch = new CountDownLatch(1);
472+
application.setTrayIcon(
473+
"http://icons.iconarchive.com/icons/marcus-roberto/google-play/512/Google-Search-icon.png",
474+
null,
475+
new AckListener() {
476+
@Override
477+
public void onSuccess(Ack ack) {
478+
application.getTrayIconInfo(
479+
new AsyncCallback<JSONObject>() {
480+
@Override
481+
public void onSuccess(JSONObject obj) {
482+
logger.info("getTrayIconInfo: {}", obj.toString());
483+
latch.countDown();
484+
}
485+
}, new AckListener() {
486+
@Override
487+
public void onSuccess(Ack ack) {
488+
}
489+
490+
@Override
491+
public void onError(Ack ack) {
492+
logger.info("error getting tray icon info: {}", ack.getReason());
493+
}
494+
});
495+
}
496+
497+
@Override
498+
public void onError(Ack ack) {
499+
}
500+
});
501+
502+
503+
latch.await(5, TimeUnit.SECONDS);
504+
505+
assertEquals(0, latch.getCount());
506+
}
507+
508+
@Test
509+
public void isRunning() throws Exception {
510+
Application application = TestUtils.runApplication(TestUtils.getAppOptions(null), desktopConnection);
511+
final CountDownLatch latch = new CountDownLatch(1);
512+
application.isRunning(
513+
new AsyncCallback<Boolean>() {
514+
@Override
515+
public void onSuccess(Boolean running) {
516+
logger.info("isRunning: {}", running);
517+
latch.countDown();
518+
}
519+
}, new AckListener() {
520+
@Override
521+
public void onSuccess(Ack ack) {
522+
}
523+
524+
@Override
525+
public void onError(Ack ack) {
526+
logger.info("error getting application running status: {}", ack.getReason());
527+
}
528+
});
529+
530+
latch.await(5, TimeUnit.SECONDS);
531+
532+
assertEquals(0, latch.getCount());
533+
}
534+
535+
@Test
536+
public void registerCustomData() throws Exception {
537+
Application application = TestUtils.runApplication(TestUtils.getAppOptions(null), desktopConnection);
538+
final CountDownLatch latch = new CountDownLatch(1);
539+
JSONObject data = new JSONObject();
540+
data.put("userId", "myUserId");
541+
data.put("organization", "myOrganizationId");
542+
application.registerCustomData(data, new AckListener() {
543+
@Override
544+
public void onSuccess(Ack ack) {
545+
logger.info("registered custom data");
546+
latch.countDown();
547+
}
548+
549+
@Override
550+
public void onError(Ack ack) {
551+
logger.info("error registering custom data: {}", ack.getReason());
552+
}
553+
});
554+
555+
latch.await(5, TimeUnit.SECONDS);
556+
557+
assertEquals(0, latch.getCount());
558+
}
467559
}

0 commit comments

Comments
 (0)