Пример #1
0
  @Test
  public void consumedFocusGainedEventsShouldNotStartTheCaret() throws Exception {
    assertEquals(false, panel.isCaretBlinking());

    new FocusGainedEvent().consumed().dispatch(panel);

    assertEquals(false, panel.isCaretBlinking());
  }
Пример #2
0
  @Test
  public void caretAnimationIsStoppedWhenPanelIsDisowned() throws Exception {
    stage.getKeyListener().focusOn(panel);
    assertEquals(true, panel.isCaretBlinking());

    panel.setParent(null);

    assertEquals(false, panel.isCaretBlinking());
  }
Пример #3
0
  @Test
  public void consumedCharTypedEventsDoNothing() throws Exception {
    panel = new TextBoxPanel();
    root.add(panel);
    panel.getModel().setText("Some Text");
    new CharTypedEvent(0, 'A').consumed().dispatch(panel);

    assertEquals("Some Text", panel.getText());
  }
Пример #4
0
  @Test
  public void consumedKeyPressEventsDoNothing() throws Exception {
    panel = new TextBoxPanel();
    root.add(panel);
    panel.getModel().setText("Some Text");
    new KeyPressedEvent(0, KeyEvent.KEY_BACK_SPACE, 0).consumed().dispatch(panel);

    assertEquals("Some Text", panel.getText());
  }
Пример #5
0
  @Test
  public void shouldRequireLayoutAfterConsumableSizeChanges() throws Exception {
    FakeScene root = new FakeScene();
    root.add(panel);
    panel.getRoot();
    panel.resetLayout();

    panel.consumableAreaChanged();

    assertEquals(true, panel.needsLayout());
  }
Пример #6
0
  @Test
  public void canLoseFocus() {
    stage.getKeyListener().focusOn(panel);
    root.dirtyRegions.clear();
    stage.getKeyListener().focusOn(root);

    assertEquals(false, panel.hasFocus());
    assertEquals(false, panel.isCaretBlinking());
    assertEquals(true, root.dirtyRegions.contains(panel.getBounds()));
    assertEquals(true, root.dirtyRegions.contains(parent.getBounds()));
  }
Пример #7
0
  @Test
  public void canGainFocus() {
    assertEquals(0, root.dirtyRegions.size());

    stage.getKeyListener().focusOn(panel);

    assertEquals(true, panel.hasFocus());
    assertEquals(true, panel.isCaretBlinking());
    assertEquals(true, root.dirtyRegions.contains(panel.getBounds()));
    assertEquals(true, root.dirtyRegions.contains(parent.getBounds()));
  }
Пример #8
0
  @Test
  public void valuChangedEventInvokedWhenChangingText() throws Exception {
    panel.setText("foo");
    final MockEventAction action = new MockEventAction();
    panel.getEventHandler().add(ValueChangedEvent.class, action);

    panel.setText("foo");
    assertEquals(false, action.invoked);

    panel.setText("bar");
    assertEquals(true, action.invoked);
  }
Пример #9
0
  @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));
  }
Пример #10
0
  @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);
  }
Пример #11
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");
 }
Пример #12
0
 @Test
 public void shouldDefaultLayout() throws Exception {
   assertSame(TextInputPanelLayout.instance, panel.getDefaultLayout());
 }