@Test public void newlineIsTyped() throws Exception { model.setCaretLocation(TextLocation.origin); new CharTypedEvent(0, '\n').dispatch(panel); assertEquals("\nSome Text", model.getText()); }
@Test public void backspaceIsNotTyped() throws Exception { model.setCaretLocation(TextLocation.origin); new CharTypedEvent(0, '\b').dispatch(panel); assertEquals("Some Text", model.getText()); }
@Test public void typedCharsWithCommandModifierDoNothing() throws Exception { model.setCaretLocation(TextLocation.origin); new CharTypedEvent(KeyEvent.COMMAND_MASK, 'A').dispatch(panel); assertEquals("Some Text", model.getText()); }
@Test public void typingACharWillInsertIt() throws Exception { model.setCaretLocation(TextLocation.origin); new CharTypedEvent(0, 'Z').dispatch(panel); assertEquals("ZSome Text", model.getText()); }
@Test public void changesToModelAreReportedOnFocusLost() throws Exception { final MockEventAction action = new MockEventAction(); panel.getEventHandler().add(ValueChangedEvent.class, action); new FocusGainedEvent().dispatch(panel); model.insertChar('a'); assertEquals(true, model.hasChanged()); new FocusLostEvent().dispatch(panel); assertEquals(true, action.invoked); }
@Test public void consumedMouseDragEventsDoNothing() throws Exception { new MousePressedEvent(0, new Point(0, 0), 1).dispatch(panel); new MouseDraggedEvent(0, new Point(25, 5), 1).consumed().dispatch(panel); assertEquals(false, model.hasSelection()); }
@Test public void typingACharMakesThePanelDirty() throws Exception { assertEquals(0, root.dirtyRegions.size()); model.setCaretLocation(TextLocation.origin); new CharTypedEvent(0, 'Z').dispatch(panel); assertEquals(1, root.dirtyRegions.size()); assertEquals(panel.getBounds(), root.dirtyRegions.get(0)); }
@Before public void setUp() { assumeTrue(TestUtil.notHeadless()); root = new FakeScene(); panel = new MockTextInputPanel(); parent = new PropPanel(new FakePropProxy()); parent.add(panel); root.add(parent); stage = new MockStage(); root.setStage(stage); model = panel.getModel(); model.setText("Some Text"); }