Skip to content

Commit 9b5dbf7

Browse files
authored
Merge pull request openfin#9 from openfin/feature-preload
ADAP-78: added test case for "preload" in "windowOptions"
2 parents fa310db + 716f08c commit 9b5dbf7

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

release/preload.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var _preload = 12345

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

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
package com.openfin.desktop;
22

3-
import com.openfin.desktop.animation.AnimationTransitions;
4-
import com.openfin.desktop.animation.OpacityTransition;
5-
import com.openfin.desktop.animation.PositionTransition;
6-
import com.openfin.desktop.animation.SizeTransition;
7-
import com.openfin.desktop.demo.WindowEmbedDemo;
8-
import org.junit.AfterClass;
9-
import org.junit.BeforeClass;
10-
import org.junit.Test;
11-
import org.slf4j.Logger;
12-
import org.slf4j.LoggerFactory;
3+
import static junit.framework.Assert.assertEquals;
4+
import static junit.framework.Assert.assertFalse;
5+
import static junit.framework.Assert.assertTrue;
136

7+
import java.net.URL;
8+
import java.nio.file.Path;
9+
import java.nio.file.Paths;
1410
import java.util.HashMap;
15-
import java.util.List;
1611
import java.util.Map;
1712
import java.util.concurrent.CountDownLatch;
1813
import java.util.concurrent.TimeUnit;
1914
import java.util.concurrent.atomic.AtomicReference;
2015

21-
import static junit.framework.Assert.assertEquals;
22-
import static junit.framework.Assert.assertFalse;
23-
import static junit.framework.Assert.assertTrue;
16+
import org.junit.AfterClass;
17+
import org.junit.BeforeClass;
18+
import org.junit.Test;
19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
21+
22+
import com.openfin.desktop.animation.AnimationTransitions;
23+
import com.openfin.desktop.animation.OpacityTransition;
24+
import com.openfin.desktop.animation.PositionTransition;
25+
import com.openfin.desktop.animation.SizeTransition;
2426

2527
/**
2628
* Created by wche on 1/25/16.
@@ -637,5 +639,29 @@ public void onError(Ack ack) {
637639
assertEquals("Window.executeJavaScript timeout", latch.getCount(), 0);
638640
TestUtils.closeApplication(application);
639641
}
642+
643+
@Test
644+
public void preload() throws Exception {
645+
646+
ApplicationOptions options = TestUtils.getAppOptions(null);
647+
options.getMainWindowOptions().setPreload("https://cdn.openfin.co/examples/junit/preload.js");
648+
649+
Application application = TestUtils.runApplication(options, desktopConnection);
650+
651+
Window mainWindow = application.getWindow();
652+
653+
Thread.sleep(1000);
654+
CountDownLatch latch = new CountDownLatch(1);
655+
mainWindow.executeJavaScript("_preload", result -> {
656+
if (result != null && result.toString().equals("12345")) {
657+
latch.countDown();
658+
}
659+
}, null);
660+
661+
latch.await(5, TimeUnit.SECONDS);
662+
assertEquals("execute java script timeout: " + options.getUUID(), 0, latch.getCount());
663+
664+
TestUtils.closeApplication(application);
665+
}
640666

641667
}

0 commit comments

Comments
 (0)