|
1 | 1 | package com.openfin.desktop; |
2 | 2 |
|
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; |
13 | 6 |
|
| 7 | +import java.net.URL; |
| 8 | +import java.nio.file.Path; |
| 9 | +import java.nio.file.Paths; |
14 | 10 | import java.util.HashMap; |
15 | | -import java.util.List; |
16 | 11 | import java.util.Map; |
17 | 12 | import java.util.concurrent.CountDownLatch; |
18 | 13 | import java.util.concurrent.TimeUnit; |
19 | 14 | import java.util.concurrent.atomic.AtomicReference; |
20 | 15 |
|
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; |
24 | 26 |
|
25 | 27 | /** |
26 | 28 | * Created by wche on 1/25/16. |
@@ -637,5 +639,29 @@ public void onError(Ack ack) { |
637 | 639 | assertEquals("Window.executeJavaScript timeout", latch.getCount(), 0); |
638 | 640 | TestUtils.closeApplication(application); |
639 | 641 | } |
| 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 | + } |
640 | 666 |
|
641 | 667 | } |
0 commit comments