Search in sources :

Example 16 with MockPanel

use of limelight.ui.MockPanel in project limelight by slagyr.

the class StageMouseListenerTest method mouseEnteredAndExited.

@Test
public void mouseEnteredAndExited() throws Exception {
    MockPanel child2Panel = new MockPanel();
    parent.add(child2Panel);
    child2Panel.setLocation(1, 1);
    child2Panel.setSize(100, 100);
    assertNull(listener.hooveredPanel);
    MockEventAction moveAction = new MockEventAction();
    parent.getEventHandler().add(MouseEnteredEvent.class, parentAction);
    parent.getEventHandler().add(MouseMovedEvent.class, moveAction);
    listener.mouseMoved(event(0, 0));
    assertSame(parent, listener.hooveredPanel);
    checkEvent(parentAction, MouseEnteredEvent.class, 0, 0);
    checkEvent(moveAction, MouseMovedEvent.class, 0, 0);
    moveAction.reset();
    parentAction.reset();
    MockEventAction child2MoveAction = new MockEventAction();
    child2Panel.getEventHandler().add(MouseEnteredEvent.class, childAction);
    child2Panel.getEventHandler().add(MouseMovedEvent.class, child2MoveAction);
    listener.mouseMoved(event(50, 50));
    assertSame(child2Panel, listener.hooveredPanel);
    assertEquals(false, moveAction.invoked || parentAction.invoked);
    checkEvent(childAction, MouseEnteredEvent.class, 50, 50);
    checkEvent(child2MoveAction, MouseMovedEvent.class, 50, 50);
    child2MoveAction.reset();
    MockEventAction childExitAction = new MockEventAction();
    MockEventAction childMoveAction = new MockEventAction();
    child2Panel.getEventHandler().add(MouseExitedEvent.class, childExitAction);
    child.getEventHandler().add(MouseMovedEvent.class, childMoveAction);
    listener.mouseMoved(event(500, 500));
    assertSame(child, listener.hooveredPanel);
    checkEvent(childExitAction, MouseExitedEvent.class, 500, 500);
    checkEvent(childMoveAction, MouseMovedEvent.class, 500, 500);
}
Also used : MockPanel(limelight.ui.MockPanel) MockEventAction(limelight.ui.model.inputs.MockEventAction) Test(org.junit.Test)

Example 17 with MockPanel

use of limelight.ui.MockPanel in project limelight by slagyr.

the class StageMouseListenerTest method draggingInvokesEnteredAndExited.

@Test
public void draggingInvokesEnteredAndExited() throws Exception {
    MockPanel child2Panel = new MockPanel();
    parent.add(child2Panel);
    child2Panel.setLocation(1, 1);
    child2Panel.setSize(100, 100);
    assertNull(listener.hooveredPanel);
    MockEventAction parentDragAction = new MockEventAction();
    parent.getEventHandler().add(MouseDraggedEvent.class, parentDragAction);
    listener.mousePressed(event(0, 0));
    listener.mouseDragged(event(0, 0));
    assertSame(parent, listener.hooveredPanel);
    checkEvent(parentDragAction, MouseDraggedEvent.class, 0, 0);
    parentDragAction.reset();
    MockEventAction child2EnteredAction = new MockEventAction();
    child2Panel.getEventHandler().add(MouseEnteredEvent.class, child2EnteredAction);
    listener.mouseDragged(event(50, 50));
    assertSame(child2Panel, listener.hooveredPanel);
    checkEvent(parentDragAction, MouseDraggedEvent.class, 50, 50);
    checkEvent(child2EnteredAction, MouseEnteredEvent.class, 50, 50);
    MockEventAction child2ExitedAction = new MockEventAction();
    child2Panel.getEventHandler().add(MouseExitedEvent.class, child2ExitedAction);
    MockEventAction childEnteredAction = new MockEventAction();
    child.getEventHandler().add(MouseEnteredEvent.class, childEnteredAction);
    listener.mouseDragged(event(500, 500));
    assertSame(child, listener.hooveredPanel);
    checkEvent(child2ExitedAction, MouseExitedEvent.class, 500, 500);
    checkEvent(childEnteredAction, MouseEnteredEvent.class, 500, 500);
}
Also used : MockPanel(limelight.ui.MockPanel) MockEventAction(limelight.ui.model.inputs.MockEventAction) Test(org.junit.Test)

Example 18 with MockPanel

use of limelight.ui.MockPanel in project limelight by slagyr.

the class CharTypedEventTest method setUp.

@Before
public void setUp() throws Exception {
    panel = new MockPanel();
    event = new CharTypedEvent(123, 'a');
}
Also used : MockPanel(limelight.ui.MockPanel) Before(org.junit.Before)

Example 19 with MockPanel

use of limelight.ui.MockPanel in project limelight by slagyr.

the class KeyEventTest method setUp.

@Before
public void setUp() throws Exception {
    panel = new MockPanel();
    event = new TestableKeyEvent(panel, 123, KeyEvent.KEY_ENTER, KeyEvent.LOCATION_LEFT);
}
Also used : MockPanel(limelight.ui.MockPanel) Before(org.junit.Before)

Example 20 with MockPanel

use of limelight.ui.MockPanel in project limelight by slagyr.

the class ModifiableEventTest method setUp.

@Before
public void setUp() {
    panel = new MockPanel();
    event = new TestableModifiableEvent(panel, 0);
}
Also used : MockPanel(limelight.ui.MockPanel) Before(org.junit.Before)

Aggregations

MockPanel (limelight.ui.MockPanel)40 Test (org.junit.Test)26 Panel (limelight.ui.Panel)12 Before (org.junit.Before)10 MockEventAction (limelight.ui.model.inputs.MockEventAction)4 java.util (java.util)2 MockAnimation (limelight.background.MockAnimation)2 java.awt (java.awt)1 Point (java.awt.Point)1 Box (limelight.util.Box)1