Exemplo n.º 1
0
 @Test
 public void testDispose1() {
   final Actor a = new ActorImpl(scene, "actor", "a");
   scene.add(a);
   scene.dispose();
   Assert.assertTrue(scene.lookupAll(Actor.class).isEmpty());
 }
Exemplo n.º 2
0
 /** Test of getActor method, of class AwtAbstractScene. */
 @Test
 public void testGetActorById() {
   final ShapeActor actor = new ShapeActor(scene);
   actor.setShape(new Rectangle2D(1.0, 1.0));
   Assert.assertNull(scene.getActor(actor.getId()));
   scene.add(actor);
   Assert.assertNotNull(scene.getActor(actor.getId()));
   Assert.assertEquals(actor, scene.getActor(actor.getId()));
   scene.remove(actor);
   Assert.assertNull(scene.getActor(actor.getId()));
 }
Exemplo n.º 3
0
 /** Test of getActor method, of class AwtAbstractScene. */
 @Test(expected = IllegalArgumentException.class)
 public void testGetActorByIdDuplicate1() {
   final ShapeActor actor = new ShapeActor(scene);
   actor.setShape(new Rectangle2D(1.0, 1.0));
   final ShapeActor duplicate = new ShapeActor(scene, actor.getId());
   duplicate.setShape(new Rectangle2D(1.0, 1.0));
   Assert.assertNull(scene.getActor(actor.getId()));
   scene.add(actor);
   Assert.assertNotNull(scene.getActor(actor.getId()));
   Assert.assertEquals(actor, scene.getActor(actor.getId()));
   Assert.assertTrue(actor == scene.getActor(actor.getId()));
   scene.add(duplicate);
   Assert.assertTrue(duplicate == scene.getActor(actor.getId()));
 }
Exemplo n.º 4
0
  @Test
  public void testDispose2() {
    final Actor a = new ActorImpl(scene, "actor", "a");
    ColorSupport.newInstance(a);
    TransformSupport.newInstance(a);
    scene.add(a);

    scene.dispose();
    Assert.assertTrue(scene.lookupAll(Actor.class).isEmpty());
    Assert.assertTrue(scene.lookupAll(ColorSupport.class).isEmpty());
    Assert.assertTrue(scene.lookupAll(TransformSupport.class).isEmpty());
    Assert.assertNull(a.lookup(ColorSupport.class));
    Assert.assertNull(a.lookup(TransformSupport.class));
    Assert.assertNull(scene.getActor("a"));
  }
Exemplo n.º 5
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));
  }
Exemplo n.º 6
0
 /**
  * Clean up after testing
  *
  * @throws Exception
  */
 @After
 public void tearDown() throws Exception {
   scene.tearDown();
 }
Exemplo n.º 7
0
 /**
  * Set up for testing
  *
  * @throws Exception
  */
 @Before
 public void setUp() throws Exception {
   scene.setUp();
 }
Exemplo n.º 8
0
 /** Test of getGLUT method, of class AwtAbstractScene. */
 @Test
 public void testGetGLUT() {
   Assert.assertNotNull(scene.getGLUT());
 }
Exemplo n.º 9
0
 /**
  * Clean up after testing
  *
  * @throws Exception
  */
 @AfterClass
 public static void tearDown() throws Exception {
   scene.tearDown();
 }
Exemplo n.º 10
0
 /**
  * Set up for testing
  *
  * @throws Exception
  */
 @BeforeClass
 public static void setUp() throws Exception {
   scene.setUp();
 }