Beispiel #1
0
  public void testHasChangesWhenaTextIsChanged() throws Exception {
    TextPanel.staticFontRenderingContext = new FontRenderContext(new AffineTransform(), true, true);
    panel.doLayout();

    panel.setText("blah");
    assertEquals(true, panel.needsLayout());

    panel.doLayout();
    panel.setText("blah");
    assertEquals(false, panel.needsLayout());

    panel.setText("new text");
    assertEquals(true, panel.needsLayout());
  }
Beispiel #2
0
  public void testText() throws Exception {
    panel.setText("blah");
    assertEquals("blah", panel.getText());
    assertEquals("blah", panel.getTextAccessor().getText());

    panel.getTextAccessor().setText("foo");
    assertEquals("foo", panel.getText());
  }
Beispiel #3
0
  public void testChangingTextColor() throws Exception {
    panel.setText("foo");
    panel.resetLayout();

    panel.styleChanged(Style.TEXT_COLOR, Style.TEXT_COLOR.compile("red"));

    assertEquals(true, panel.needsLayout());
  }
Beispiel #4
0
  public void testChangingFontStyle() throws Exception {
    panel.setText("foo");
    panel.resetLayout();
    panel.resetPendingSizeChange();

    panel.styleChanged(Style.FONT_STYLE, Style.FONT_STYLE.compile("italic"));

    assertEquals(true, panel.needsLayout());
    assertEquals(true, panel.sizeChangePending());
  }
Beispiel #5
0
  public void testKeyPressedForwardedToTextPanel() throws Exception {
    MockOS os = new MockOS();
    Context.instance().os = os;
    KeyEvent event = new KeyEvent(new JPanel(), 1, 2, 3, 4, 'a');

    panel.keyPressed(event);

    assertEquals(false, os.wasPrimaryModifierDownChecked());

    panel.setText("foo");
    panel.keyPressed(event);

    assertEquals(true, os.wasPrimaryModifierDownChecked());
  }