Skip to content

Commit

Permalink
TestDisplayLifecycle02NEWT: Ensure window/screen has been destroyed b…
Browse files Browse the repository at this point in the history
…efore validating active count.
  • Loading branch information
sgothel committed Jul 4, 2013
1 parent 3981d4c commit 6d0607b
Showing 1 changed file with 19 additions and 3 deletions.
Expand Up @@ -39,6 +39,7 @@
import com.jogamp.newt.opengl.*;
import java.io.IOException;

import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
Expand Down Expand Up @@ -141,6 +142,9 @@ private void testDisplayCreate01Impl() throws InterruptedException {

// destruction.. ref count down, but keep all
window.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));

Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(0,Display.getActiveDisplayNumber());
Assert.assertEquals(0,display.getReferenceCount());
Expand Down Expand Up @@ -186,6 +190,9 @@ private void testDisplayCreate01Impl() throws InterruptedException {
System.err.println("duration: "+window.getTotalFPSDuration());

window.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));

Assert.assertEquals(screen,window.getScreen());
Assert.assertEquals(false,window.isNativeValid());
Assert.assertEquals(false,window.isVisible());
Expand All @@ -208,7 +215,9 @@ public void testDisplayCreate01() throws InterruptedException {
Assert.assertEquals(0,Display.getActiveDisplayNumber());

// Create Display/Screen, pending lazy native creation
System.err.println("Pass - 1");
testDisplayCreate01Impl();
System.err.println("Pass - 2");
testDisplayCreate01Impl();

Assert.assertEquals(0,Display.getActiveDisplayNumber());
Expand Down Expand Up @@ -285,6 +294,8 @@ private void testDisplayCreate02Impl() throws InterruptedException {

// destruction ...
window1.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window1, false));

Assert.assertNotNull(window1.getScreen());
Assert.assertEquals(false,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());
Expand All @@ -300,6 +311,9 @@ private void testDisplayCreate02Impl() throws InterruptedException {

// destruction
window2.destroy();
Assert.assertTrue(AWTRobotUtil.waitForRealized(window2, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false));

Assert.assertNotNull(window2.getScreen());
Assert.assertEquals(false,window2.isNativeValid());
Assert.assertEquals(false,window2.isVisible());
Expand All @@ -314,24 +328,26 @@ private void testDisplayCreate02Impl() throws InterruptedException {
Assert.assertEquals(0,screen.getReferenceCount());
Assert.assertEquals(false,screen.isNativeValid());

// invalidate .. remove all refs
// invalidate (again) ..
window1.destroy();
Assert.assertEquals(false,window1.isNativeValid());
Assert.assertEquals(false,window1.isVisible());

// invalidate .. remove all refs
// invalidate (again) ..
window2.destroy();
Assert.assertEquals(false,window2.isNativeValid());
Assert.assertEquals(false,window2.isVisible());

}

@Test
// @Test
public void testDisplayCreate02() throws InterruptedException {
Assert.assertEquals(0,Display.getActiveDisplayNumber());

// Create Display/Screen, pending lazy native creation
System.err.println("Pass - 1");
testDisplayCreate02Impl();
System.err.println("Pass - 2");
testDisplayCreate02Impl();

Assert.assertEquals(0,Display.getActiveDisplayNumber());
Expand Down

0 comments on commit 6d0607b

Please sign in to comment.