Beispiel #1
0
  /**
   * Test of add method, of class AwtAbstractScene.
   *
   * @throws InterruptedException
   * @throws InvocationTargetException
   */
  @Test
  public void testAdd() throws InterruptedException, InvocationTargetException {
    final GLCanvas panel = (GLCanvas) scene.getComponent();
    // create listeners
    final KeyListener listener0 = new KeyAdapter() {};

    final MouseListener listener1 = new MouseAdapter() {};
    final MouseMotionListener listener2 = new MouseMotionAdapter() {};
    final MouseWheelListener listener3 =
        new MouseWheelListener() {
          @Override
          public void mouseWheelMoved(final MouseWheelEvent event) {
            // no operation
          }
        };
    final ComponentListener listener4 = new ComponentAdapter() {};
    final ContainerListener listener5 = new ContainerAdapter() {};
    final FocusListener listener6 = new FocusAdapter() {};
    // add all the listeners on the event thread
    SwingUtilities.invokeAndWait(
        new Runnable() {
          @Override
          public void run() {
            scene.add(listener0);
            scene.add(listener1);
            scene.add(listener2);
            scene.add(listener3);
            scene.add(listener4);
            scene.add(listener5);
            scene.add(listener6);
          }
        });
    // ensure they are all added to the panel
    Assert.assertTrue(containsValue(panel.getKeyListeners(), listener0));
    Assert.assertTrue(containsValue(panel.getMouseListeners(), listener1));
    Assert.assertTrue(containsValue(panel.getMouseMotionListeners(), listener2));
    Assert.assertTrue(containsValue(panel.getMouseWheelListeners(), listener3));
    Assert.assertTrue(containsValue(panel.getComponentListeners(), listener4));
    //        Assert.assertTrue(containsValue(panel.getContainerListeners(), listener5));
    Assert.assertTrue(containsValue(panel.getFocusListeners(), listener6));
  }