Skip to content

Commit af2e7e7

Browse files
author
Wenjun Che
committed
RUN-1079: Cross app docking test cases
1 parent 6cb3602 commit af2e7e7

10 files changed

Lines changed: 125 additions & 25 deletions

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>co.openfin</groupId>
88
<artifactId>openfin-desktop-java-example</artifactId>
9-
<version>5.44.2.2</version>
9+
<version>5.44.2.3</version>
1010
<packaging>jar</packaging>
1111

1212
<name>openfin-desktop-java-example</name>
@@ -41,7 +41,7 @@
4141
<dependency>
4242
<groupId>co.openfin</groupId>
4343
<artifactId>openfin-desktop-java-adapter</artifactId>
44-
<version>5.44.2.2</version>
44+
<version>5.44.2.3</version>
4545
</dependency>
4646
<dependency>
4747
<groupId>tablelayout</groupId>

release/junit.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
java -cp openfin-desktop-java-example-5.44.2.2-tests.jar;openfin-desktop-java-adapter-5.44.2.2.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.jar;json-20140107.jar;slf4j-api-1.7.5.jar;slf4j-jdk14-1.6.1.jar;junit-4.11.jar;hamcrest-core-1.3.jar;hamcrest-core-1.3.jar;hamcrest-library-1.1.jar;mockito-core-1.9.5.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.demo.version=5.44.9.13 org.junit.runner.JUnitCore com.openfin.desktop.AllTests
1+
java -cp openfin-desktop-java-example-5.44.2.3-tests.jar;openfin-desktop-java-adapter-5.44.2.3.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.jar;json-20140107.jar;slf4j-api-1.7.5.jar;slf4j-jdk14-1.6.1.jar;junit-4.11.jar;hamcrest-core-1.3.jar;hamcrest-core-1.3.jar;hamcrest-library-1.1.jar;mockito-core-1.9.5.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.test.runtime.version=5.44.10.26 org.junit.runner.JUnitCore com.openfin.desktop.AllTests

release/junit2.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
java -cp openfin-desktop-java-example-5.44.2.2.jar;openfin-desktop-java-adapter-5.44.2.2.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.jar;json-20140107.jar;slf4j-api-1.7.5.jar;slf4j-jdk14-1.6.1.jar;junit-4.11.jar;hamcrest-core-1.3.jar;hamcrest-core-1.3.jar;hamcrest-library-1.1.jar;mockito-core-1.9.5.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.demo.runtime.version=5.44.10.25 org.junit.runner.JUnitCore com.openfin.desktop.demo.OpenFinWindowTest
1+
java -cp openfin-desktop-java-example-5.44.2.3.jar;openfin-desktop-java-adapter-5.44.2.3.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.jar;json-20140107.jar;slf4j-api-1.7.5.jar;slf4j-jdk14-1.6.1.jar;junit-4.11.jar;hamcrest-core-1.3.jar;hamcrest-core-1.3.jar;hamcrest-library-1.1.jar;mockito-core-1.9.5.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.demo.runtime.version=5.44.10.26 org.junit.runner.JUnitCore com.openfin.desktop.demo.OpenFinWindowTest
291 KB
Binary file not shown.
95.9 KB
Binary file not shown.
105 KB
Binary file not shown.

release/run.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
java -cp openfin-desktop-java-example-5.44.2.2.jar;openfin-desktop-java-adapter-5.44.2.2.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.jar;json-20140107.jar;slf4j-api-1.7.5.jar;slf4j-jdk14-1.6.1.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.temp=%LocalAppData%\OpenFin\temp com.openfin.desktop.demo.OpenFinDesktopDemo
1+
java -cp openfin-desktop-java-example-5.44.2.3.jar;openfin-desktop-java-adapter-5.44.2.3.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.jar;json-20140107.jar;slf4j-api-1.7.5.jar;slf4j-jdk14-1.6.1.jar -Djava.util.logging.config.file=logging.properties -Dcom.openfin.temp=%LocalAppData%\OpenFin\temp com.openfin.desktop.demo.OpenFinDesktopDemo

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,82 @@ public void createChildWindow() throws Exception {
150150
Window childWindow = TestUtils.createChildWindow(application, childOptions, desktopConnection);
151151
TestUtils.closeApplication(application);
152152
}
153+
154+
@Test
155+
public void crossAppDockAndUndock() throws Exception {
156+
Application application1 = TestUtils.runApplication(TestUtils.getAppOptions(null), desktopConnection);
157+
Application application2 = TestUtils.runApplication(TestUtils.getAppOptions(null), desktopConnection);
158+
159+
WindowBounds beforeMoveBounds = TestUtils.getBounds(application2.getWindow());
160+
CountDownLatch joinLatch = new CountDownLatch(1);
161+
application2.getWindow().joinGroup(application1.getWindow(), new AckListener() {
162+
@Override
163+
public void onSuccess(Ack ack) {
164+
if (ack.isSuccessful()) {
165+
joinLatch.countDown();
166+
}
167+
}
168+
@Override
169+
public void onError(Ack ack) {
170+
logger.error(String.format("onError %s", ack.getReason()));
171+
}
172+
});
173+
joinLatch.await(3, TimeUnit.SECONDS);
174+
assertEquals(joinLatch.getCount(), 0);
175+
176+
CountDownLatch groupInfoLatch = new CountDownLatch(2);
177+
application1.getWindow().getGroup(result -> {
178+
for (Window window : result) {
179+
if (window.getUuid().equals(application1.getWindow().getUuid()) && window.getName().equals(application1.getWindow().getName())) {
180+
groupInfoLatch.countDown();
181+
} else if (window.getUuid().equals(application2.getWindow().getUuid()) && window.getName().equals(application2.getWindow().getName())) {
182+
groupInfoLatch.countDown();
183+
}
184+
}
185+
}, new AckListener() {
186+
@Override
187+
public void onSuccess(Ack ack) {
188+
}
189+
@Override
190+
public void onError(Ack ack) {
191+
logger.error(String.format("onError %s", ack.getReason()));
192+
}
193+
});
194+
groupInfoLatch.await(3, TimeUnit.SECONDS);
195+
assertEquals(groupInfoLatch.getCount(), 0);
196+
197+
int leftBy = 20, topBy = 30;
198+
TestUtils.moveWindowBy(application1.getWindow(), leftBy, topBy);
199+
// child window sohuld move with main window since they are docked
200+
WindowBounds afterMoveBounds = TestUtils.getBounds(application2.getWindow());
201+
int topAfterDockMove = afterMoveBounds.getTop(), leftAfterDockMove = afterMoveBounds.getLeft();
202+
assertEquals(afterMoveBounds.getTop() - beforeMoveBounds.getTop(), topBy);
203+
assertEquals(afterMoveBounds.getLeft() - beforeMoveBounds.getLeft(), leftBy);
204+
205+
// undock by leaving the group
206+
CountDownLatch undockLatch = new CountDownLatch(1);
207+
application2.getWindow().leaveGroup(new AckListener() {
208+
@Override
209+
public void onSuccess(Ack ack) {
210+
if (ack.isSuccessful()) {
211+
undockLatch.countDown();
212+
}
213+
}
214+
215+
@Override
216+
public void onError(Ack ack) {
217+
logger.error(String.format("onError %s", ack.getReason()));
218+
}
219+
});
220+
undockLatch.await(5, TimeUnit.SECONDS);
221+
assertEquals(undockLatch.getCount(), 0);
222+
TestUtils.moveWindowBy(application1.getWindow(), leftBy, topBy);
223+
// child window should not move afer leaving group
224+
afterMoveBounds = TestUtils.getBounds(application2.getWindow());
225+
assertEquals(afterMoveBounds.getLeft().intValue(), leftAfterDockMove);
226+
assertEquals(afterMoveBounds.getTop().intValue(), topAfterDockMove);
227+
228+
TestUtils.closeApplication(application1);
229+
TestUtils.closeApplication(application2);
230+
}
153231
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,22 @@ public static WindowBounds getBounds(Window window) throws Exception {
291291
return windowBoundsAtomicReference.get();
292292
}
293293

294+
public static void moveWindowBy(Window window, int deltaLeft, int deltaTop) throws Exception {
295+
CountDownLatch latch = new CountDownLatch(1);
296+
window.moveBy(deltaLeft, deltaTop, new AckListener() {
297+
@Override
298+
public void onSuccess(Ack ack) {
299+
if (ack.isSuccessful()) {
300+
latch.countDown();
301+
}
302+
}
303+
@Override
304+
public void onError(Ack ack) {
305+
logger.error(String.format("onError %s", ack.getReason()));
306+
}
307+
});
308+
latch.await(5, TimeUnit.SECONDS);
309+
assertEquals(latch.getCount(), 0);
310+
}
311+
294312
}

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.slf4j.LoggerFactory;
1212

1313
import java.util.HashMap;
14+
import java.util.List;
1415
import java.util.Map;
1516
import java.util.concurrent.CountDownLatch;
1617
import java.util.concurrent.TimeUnit;
@@ -235,9 +236,29 @@ public void onError(Ack ack) {
235236
joinLatch.await(3, TimeUnit.SECONDS);
236237
assertEquals(joinLatch.getCount(), 0);
237238

238-
CountDownLatch moveLatch = new CountDownLatch(1);
239+
CountDownLatch groupInfoLatch = new CountDownLatch(2);
240+
mainWindow.getGroup(result -> {
241+
for (Window window : result) {
242+
if (window.getUuid().equals(mainWindow.getUuid()) && window.getName().equals(mainWindow.getName())) {
243+
groupInfoLatch.countDown();
244+
}
245+
else if (window.getUuid().equals(childWindow.getUuid()) && window.getName().equals(childWindow.getName())) {
246+
groupInfoLatch.countDown();
247+
}
248+
}
249+
}, new AckListener() {
250+
@Override
251+
public void onSuccess(Ack ack) {
252+
}
253+
@Override
254+
public void onError(Ack ack) {
255+
}
256+
});
257+
groupInfoLatch.await(3, TimeUnit.SECONDS);
258+
assertEquals(groupInfoLatch.getCount(), 0);
259+
239260
int leftBy = 20, topBy = 30;
240-
moveWindowBy(mainWindow, leftBy, topBy);
261+
TestUtils.moveWindowBy(mainWindow, leftBy, topBy);
241262
// child window sohuld move with main window since they are docked
242263
WindowBounds afterMoveBounds = TestUtils.getBounds(childWindow);
243264
int topAfterDockMove = afterMoveBounds.getTop(), leftAfterDockMove = afterMoveBounds.getLeft();
@@ -260,7 +281,7 @@ public void onError(Ack ack) {
260281
});
261282
undockLatch.await(5, TimeUnit.SECONDS);
262283
assertEquals(undockLatch.getCount(), 0);
263-
moveWindowBy(mainWindow, leftBy, topBy);
284+
TestUtils.moveWindowBy(mainWindow, leftBy, topBy);
264285
// child window should not move afer leaving group
265286
afterMoveBounds = TestUtils.getBounds(childWindow);
266287
assertEquals(afterMoveBounds.getLeft().intValue(), leftAfterDockMove);
@@ -407,22 +428,5 @@ private WindowOptions getOptions(Window window) throws Exception {
407428
return windowAtomicReference.get();
408429
}
409430

410-
private void moveWindowBy(Window window, int deltaLeft, int deltaTop) throws Exception {
411-
CountDownLatch latch = new CountDownLatch(1);
412-
window.moveBy(deltaLeft, deltaTop, new AckListener() {
413-
@Override
414-
public void onSuccess(Ack ack) {
415-
if (ack.isSuccessful()) {
416-
latch.countDown();
417-
}
418-
}
419-
@Override
420-
public void onError(Ack ack) {
421-
logger.error(String.format("onError %s", ack.getReason()));
422-
}
423-
});
424-
latch.await(5, TimeUnit.SECONDS);
425-
assertEquals(latch.getCount(), 0);
426-
}
427431

428432
}

0 commit comments

Comments
 (0)