public void testWindowParenting1AWTTwoNewtChilds()
      throws InterruptedException, InvocationTargetException {
    Frame frame1 = new Frame("AWT Parent Frame");
    GLWindow glWindow1 = GLWindow.create(glCaps);
    glWindow1.setUpdateFPSFrames(1, null);
    NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
    newtCanvasAWT1.setPreferredSize(size);

    GLEventListener demo1 = new GearsES2(1);
    setDemoFields(demo1, glWindow1, false);
    glWindow1.addGLEventListener(demo1);
    glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1));
    GLAnimatorControl animator1 = new Animator(glWindow1);
    animator1.start();

    GLWindow glWindow2 = GLWindow.create(glCaps);
    glWindow2.setUpdateFPSFrames(1, null);
    NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
    newtCanvasAWT2.setPreferredSize(size);

    GLEventListener demo2 = new GearsES2(1);
    setDemoFields(demo2, glWindow2, false);
    glWindow2.addGLEventListener(demo2);
    glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2));
    GLAnimatorControl animator2 = new Animator(glWindow2);
    animator2.start();

    Container cont1 = new Container();
    cont1.setLayout(new BorderLayout());
    cont1.add(newtCanvasAWT1, BorderLayout.CENTER);
    System.err.println("******* Cont1 setVisible");
    cont1.setVisible(true);

    Container cont2 = new Container();
    cont2.setLayout(new BorderLayout());
    cont2.add(newtCanvasAWT2, BorderLayout.CENTER);
    System.err.println("******* Cont2 setVisible");
    cont2.setVisible(true);
    final Container f_cont2 = cont2;

    frame1.setLayout(new BorderLayout());
    frame1.add(new Label("NORTH"), BorderLayout.NORTH);
    frame1.add(new Label("CENTER"), BorderLayout.CENTER);
    frame1.add(new Label("SOUTH"), BorderLayout.SOUTH);
    frame1.add(cont1, BorderLayout.EAST);
    frame1.setLocation(0, 0);
    frame1.setSize((int) size.getWidth() * 2, (int) size.getHeight() * 2);
    final Frame f_frame1 = frame1;
    javax.swing.SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            f_frame1.pack();
            System.err.println("******* Frame setVisible");
            f_frame1.setVisible(true);
          }
        });

    Assert.assertEquals(newtCanvasAWT1.getNativeWindow(), glWindow1.getParent());
    Assert.assertEquals(newtCanvasAWT2.getNativeWindow(), glWindow2.getParent());

    Assert.assertEquals(true, animator1.isAnimating());
    Assert.assertEquals(false, animator1.isPaused());
    Assert.assertNotNull(animator1.getThread());

    Assert.assertEquals(true, animator2.isAnimating());
    Assert.assertEquals(false, animator2.isPaused());
    Assert.assertNotNull(animator2.getThread());

    Thread.sleep(waitAdd2nd);

    javax.swing.SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            f_frame1.add(f_cont2, BorderLayout.WEST);
            f_frame1.pack();
          }
        });

    Thread.sleep(durationPerTest);

    animator1.stop();
    Assert.assertEquals(false, animator1.isAnimating());
    Assert.assertEquals(false, animator1.isPaused());
    Assert.assertEquals(null, animator1.getThread());

    animator2.stop();
    Assert.assertEquals(false, animator2.isAnimating());
    Assert.assertEquals(false, animator2.isPaused());
    Assert.assertEquals(null, animator2.getThread());

    frame1.dispose();
    glWindow1.destroy();
    glWindow2.destroy();
  }
  protected void runTestGL(final GLCapabilitiesImmutable caps) throws InterruptedException {
    final Display nDisplay =
        NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null, false); // local display
    final Screen nScreen = NewtFactory.createScreen(nDisplay, 0); // screen 0
    final Window nWindow = NewtFactory.createWindow(nScreen, caps);

    final GLWindow glWindow = GLWindow.create(nWindow);
    Assert.assertNotNull(glWindow);
    glWindow.setTitle("Gears NewtAWTWrapper Test");

    glWindow.addGLEventListener(new GearsES2(1));

    final Animator animator = useAnimator ? new Animator(glWindow) : null;
    final QuitAdapter quitAdapter = new QuitAdapter();

    glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
    glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));

    if (useAnimator) {
      animator.start();
    }

    int div = 3;
    glWindow.setSize(width / div, height / div);
    glWindow.setVisible(true);
    if (doResizeTest) {
      glWindow.display();
      final int[] expSurfaceSize =
          glWindow.getNativeSurface().convertToPixelUnits(new int[] {width / div, height / div});
      Assert.assertTrue(
          "Surface Size not reached: Expected "
              + expSurfaceSize[0]
              + "x"
              + expSurfaceSize[1]
              + ", Is "
              + glWindow.getSurfaceWidth()
              + "x"
              + glWindow.getSurfaceHeight(),
          AWTRobotUtil.waitForSize(glWindow, expSurfaceSize[0], expSurfaceSize[1]));
      Thread.sleep(600);

      div = 2;
      glWindow.setSize(width / div, height / div);
      glWindow.display();
      expSurfaceSize[0] = width / div;
      expSurfaceSize[1] = height / div;
      glWindow.getNativeSurface().convertToPixelUnits(expSurfaceSize);
      Assert.assertTrue(
          "Surface Size not reached: Expected "
              + expSurfaceSize[0]
              + "x"
              + expSurfaceSize[1]
              + ", Is "
              + glWindow.getSurfaceWidth()
              + "x"
              + glWindow.getSurfaceHeight(),
          AWTRobotUtil.waitForSize(glWindow, expSurfaceSize[0], expSurfaceSize[1]));
      Thread.sleep(600);

      div = 1;
      glWindow.setSize(width / div, height / div);
      glWindow.display();
      expSurfaceSize[0] = width / div;
      expSurfaceSize[1] = height / div;
      glWindow.getNativeSurface().convertToPixelUnits(expSurfaceSize);
      Assert.assertTrue(
          "Surface Size not reached: Expected "
              + expSurfaceSize[0]
              + "x"
              + expSurfaceSize[1]
              + ", Is "
              + glWindow.getSurfaceWidth()
              + "x"
              + glWindow.getSurfaceHeight(),
          AWTRobotUtil.waitForSize(glWindow, expSurfaceSize[0], expSurfaceSize[1]));
      Thread.sleep(600);
    }

    final long t0 = System.currentTimeMillis();
    long t1 = t0;
    while (!quitAdapter.shouldQuit() && t1 - t0 < duration) {
      Thread.sleep(100);
      t1 = System.currentTimeMillis();
    }

    if (useAnimator) {
      animator.stop();
    }
    glWindow.destroy();
  }