Package libshapedraw.event

Examples of libshapedraw.event.MockLSDEventListener


        lib.getEventListeners().add(new MockLSDEventListener());
    }

    @Test
    public void testEventListenersAddDupe() {
        MockLSDEventListener dupe = new MockLSDEventListener();
        lib.addEventListener(dupe);
        assertEquals(1, lib.getEventListeners().size());
        lib.addEventListener(dupe);
        assertEquals(1, lib.getEventListeners().size());
    }
View Full Code Here


        assertEquals(1, lib.getEventListeners().size());
    }

    @Test
    public void testEventListenersRemoveClear() {
        MockLSDEventListener listener0 = new MockLSDEventListener();
        MockLSDEventListener listener1 = new MockLSDEventListener();
        MockLSDEventListener listener2 = new MockLSDEventListener();
        MockLSDEventListener listener3 = new MockLSDEventListener();
        lib.addEventListener(listener0).addEventListener(listener1).addEventListener(listener2).addEventListener(listener3);
        assertEquals(4, lib.getEventListeners().size());

        lib.removeEventListener(listener0);
        assertEquals(3, lib.getEventListeners().size());

        lib.removeEventListener(listener0);
        assertEquals(3, lib.getEventListeners().size());
        lib.removeEventListener(new MockLSDEventListener());
        assertEquals(3, lib.getEventListeners().size());
        lib.removeEventListener(null);
        assertEquals(3, lib.getEventListeners().size());

        lib.removeEventListener(listener1).removeEventListener(listener2);
View Full Code Here

        assertEquals(0, lib.getEventListeners().size());
    }

    @Test
    public void testEventListenersRemoveInvalid() {
        MockLSDEventListener listener = new MockLSDEventListener();
        assertFalse(lib.getEventListeners().contains(listener));
        lib.removeEventListener(listener); // allowed no-op

        lib.removeEventListener(null); // also allowed
    }
View Full Code Here

        lib.removeEventListener(null); // also allowed
    }

    @Test
    public void testEventListenersFire() {
        MockLSDEventListener counter = new MockLSDEventListener();
        counter.assertCountsEqual(0, 0, 0);

        // ensure listener doesn't receive events if not registered
        LSDController.getInstance().respawn(new Vector3(0,0,0), true, true);
        LSDController.getInstance().gameTick(new Vector3(0,0,0));
        LSDController.getInstance().render(new Vector3(0,0,0), false);
        counter.assertCountsEqual(0, 0, 0);

        // register listener and ensure events are received
        lib.addEventListener(counter);

        LSDController.getInstance().respawn(new Vector3(0,0,0), true, true);
        counter.assertCountsEqual(1, 0, 0);
        LSDController.getInstance().gameTick(new Vector3(0,0,0));
        counter.assertCountsEqual(1, 1, 0);
        LSDController.getInstance().render(new Vector3(0,0,0), false);
        counter.assertCountsEqual(1, 1, 1);
    }
View Full Code Here

        counter.assertCountsEqual(1, 1, 1);
    }

    @Test
    public void testEventListenersFireMultiple() {
        MockLSDEventListener counter0 = new MockLSDEventListener();
        MockLSDEventListener counter1 = new MockLSDEventListener();
        MockLSDEventListener counter2 = new MockLSDEventListener();
        lib.addEventListener(counter0).addEventListener(counter1).addEventListener(counter2);
        LSDController.getInstance().respawn(new Vector3(0,0,0), true, true);
        counter0.assertCountsEqual(1, 0, 0);
        counter1.assertCountsEqual(1, 0, 0);
        counter2.assertCountsEqual(1, 0, 0);
        LSDController.getInstance().gameTick(new Vector3(0,0,0));
        counter0.assertCountsEqual(1, 1, 0);
        counter1.assertCountsEqual(1, 1, 0);
        counter2.assertCountsEqual(1, 1, 0);
        LSDController.getInstance().render(new Vector3(0,0,0), false);
        counter0.assertCountsEqual(1, 1, 1);
        counter1.assertCountsEqual(1, 1, 1);
        counter2.assertCountsEqual(1, 1, 1);
    }
View Full Code Here

    // ----------------------------------------------------------------------

    @Test
    public void testEventListenersAdd() {
        assertEquals(0, lib.getEventListeners().size());
        lib.addEventListener(new MockLSDEventListener());
        assertEquals(1, lib.getEventListeners().size());
        lib.addEventListener(new MockLSDEventListener());
        assertEquals(2, lib.getEventListeners().size());
        lib.addEventListener(new MockLSDEventListener()).addEventListener(new MockLSDEventListener()); // method chaining
        assertEquals(4, lib.getEventListeners().size());
        render(false);
    }
View Full Code Here

        lib.addEventListener(null);
    }

    @Test(expected=UnsupportedOperationException.class)
    public void testEventListenersUnmodifiable() {
        lib.getEventListeners().add(new MockLSDEventListener());
    }
View Full Code Here

TOP

Related Classes of libshapedraw.event.MockLSDEventListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.