Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var _preload = 12345
54 changes: 40 additions & 14 deletions src/test/java/com/openfin/desktop/WindowTest.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
package com.openfin.desktop;

import com.openfin.desktop.animation.AnimationTransitions;
import com.openfin.desktop.animation.OpacityTransition;
import com.openfin.desktop.animation.PositionTransition;
import com.openfin.desktop.animation.SizeTransition;
import com.openfin.desktop.demo.WindowEmbedDemo;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.openfin.desktop.animation.AnimationTransitions;
import com.openfin.desktop.animation.OpacityTransition;
import com.openfin.desktop.animation.PositionTransition;
import com.openfin.desktop.animation.SizeTransition;

/**
* Created by wche on 1/25/16.
Expand Down Expand Up @@ -637,5 +639,29 @@ public void onError(Ack ack) {
assertEquals("Window.executeJavaScript timeout", latch.getCount(), 0);
TestUtils.closeApplication(application);
}

@Test
public void preload() throws Exception {

ApplicationOptions options = TestUtils.getAppOptions(null);
options.getMainWindowOptions().setPreload("https://cdn.openfin.co/examples/junit/preload.js");

Application application = TestUtils.runApplication(options, desktopConnection);

Window mainWindow = application.getWindow();

Thread.sleep(1000);
CountDownLatch latch = new CountDownLatch(1);
mainWindow.executeJavaScript("_preload", result -> {
if (result != null && result.toString().equals("12345")) {
latch.countDown();
}
}, null);

latch.await(5, TimeUnit.SECONDS);
assertEquals("execute java script timeout: " + options.getUUID(), 0, latch.getCount());

TestUtils.closeApplication(application);
}

}