Esempio n. 1
0
  @Test
  public void testWindowParenting02CreateVisibleDestroy2Defered() throws InterruptedException {
    int x = 0;
    int y = 0;

    NEWTEventFiFo eventFifo = new NEWTEventFiFo();

    GLWindow glWindow1 = GLWindow.create(glCaps);
    Assert.assertNotNull(glWindow1);
    Assert.assertEquals(false, glWindow1.isVisible());
    Assert.assertEquals(false, glWindow1.isNativeWindowValid());
    Assert.assertNull(glWindow1.getParentNativeWindow());
    GLEventListener demo1 = new RedSquare();
    setDemoFields(demo1, glWindow1, false);
    glWindow1.addGLEventListener(demo1);

    NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
    Assert.assertNotNull(newtCanvasAWT);
    Assert.assertEquals(false, glWindow1.isVisible());
    Assert.assertEquals(false, glWindow1.isNativeWindowValid());
    Assert.assertNull(glWindow1.getParentNativeWindow());

    Frame frame = new Frame("AWT Parent Frame");
    Assert.assertNotNull(frame);
    frame.setSize(width, height);

    // visible test
    frame.setVisible(true);

    frame.add(newtCanvasAWT);
    Assert.assertEquals(newtCanvasAWT.getNativeWindow(), glWindow1.getParentNativeWindow());

    Animator animator1 = new Animator(glWindow1);
    animator1.start();
    while (animator1.isAnimating() && animator1.getDuration() < durationPerTest) {
      Thread.sleep(100);
    }
    animator1.stop();
    Assert.assertEquals(false, animator1.isAnimating());

    frame.dispose();
    glWindow1.destroy(true);
  }
Esempio n. 2
0
  @Test
  public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException {
    int x = 0;
    int y = 0;

    NEWTEventFiFo eventFifo = new NEWTEventFiFo();

    GLWindow glWindow1 = GLWindow.create(glCaps);
    Assert.assertNotNull(glWindow1);
    Assert.assertEquals(false, glWindow1.isVisible());
    Assert.assertEquals(false, glWindow1.isNativeWindowValid());
    Assert.assertNull(glWindow1.getParentNativeWindow());
    glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy");
    GLEventListener demo1 = new RedSquare();
    setDemoFields(demo1, glWindow1, false);
    glWindow1.addGLEventListener(demo1);

    NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1);
    Assert.assertNotNull(newtCanvasAWT);
    Assert.assertEquals(false, glWindow1.isVisible());
    Assert.assertEquals(false, glWindow1.isNativeWindowValid());
    Assert.assertNull(glWindow1.getParentNativeWindow());

    Frame frame1 = new Frame("AWT Parent Frame");
    frame1.setLayout(new BorderLayout());
    frame1.add(new Button("North"), BorderLayout.NORTH);
    frame1.add(new Button("South"), BorderLayout.SOUTH);
    frame1.add(new Button("East"), BorderLayout.EAST);
    frame1.add(new Button("West"), BorderLayout.WEST);

    Container container1 = new Container();
    container1.setLayout(new BorderLayout());
    container1.add(new Button("north"), BorderLayout.NORTH);
    container1.add(new Button("south"), BorderLayout.SOUTH);
    container1.add(new Button("east"), BorderLayout.EAST);
    container1.add(new Button("west"), BorderLayout.WEST);
    container1.add(newtCanvasAWT, BorderLayout.CENTER);

    frame1.add(container1, BorderLayout.CENTER);
    frame1.setSize(width, height);

    // visible test
    frame1.setVisible(true);
    Assert.assertEquals(newtCanvasAWT.getNativeWindow(), glWindow1.getParentNativeWindow());

    Animator animator1 = new Animator(glWindow1);
    animator1.start();
    while (animator1.isAnimating() && animator1.getDuration() < durationPerTest) {
      Thread.sleep(100);
    }
    animator1.stop();
    Assert.assertEquals(false, animator1.isAnimating());

    frame1.setVisible(false);
    Assert.assertEquals(false, glWindow1.isDestroyed());

    frame1.setVisible(true);
    Assert.assertEquals(false, glWindow1.isDestroyed());

    frame1.remove(newtCanvasAWT);
    // Assert.assertNull(glWindow1.getParentNativeWindow());
    Assert.assertEquals(false, glWindow1.isDestroyed());

    frame1.dispose();
    Assert.assertEquals(false, glWindow1.isDestroyed());

    glWindow1.destroy(true);
    // Assert.assertEquals(true, glWindow1.isDestroyed());
  }