예제 #1
0
  public void testScrollbarsDontGetRemovedOnRemoveAll() throws Exception {
    panel.addVerticalScrollBar();
    panel.addHorizontalScrollBar();
    panel.add(new PropPanel(new MockProp()));

    panel.removeAll();

    assertEquals(2, panel.children.size());
    assertEquals(panel.getVerticalScrollbar(), panel.children.get(0));
    assertEquals(panel.getHorizontalScrollbar(), panel.children.get(1));
  }
예제 #2
0
  public void testHorizontalMouseWheelMovement() throws Exception {
    panel.addVerticalScrollBar();
    panel.getVerticalScrollbar().configure(100, 200);
    panel.addHorizontalScrollBar();
    panel.getHorizontalScrollbar().configure(100, 200);

    int modifer = 1;
    int scrollAmount = 8;
    int wheelRotation = 2;
    MouseWheelEvent e =
        new MouseWheelEvent(
            root.getContentPane(), 1, 2, modifer, 4, 5, 6, false, 7, scrollAmount, wheelRotation);

    panel.mouseWheelMoved(e);

    assertEquals(0, panel.getVerticalScrollbar().getScrollBar().getValue());
    assertEquals(16, panel.getHorizontalScrollbar().getScrollBar().getValue());
  }
예제 #3
0
  public void testGetOwnerOfPointGivesPriorityToScrollBars() throws Exception {
    panel.setSize(100, 100);

    MockPanel child = new MockPanel();
    child.setSize(100, 100);
    child.setLocation(0, 0);
    panel.add(child);

    panel.addVerticalScrollBar();
    ScrollBarPanel vertical = panel.getVerticalScrollbar();
    vertical.setSize(15, 100);
    vertical.setLocation(85, 0);
    panel.addHorizontalScrollBar();
    ScrollBarPanel horizontal = panel.getHorizontalScrollbar();
    horizontal.setSize(100, 15);
    horizontal.setLocation(0, 85);

    assertSame(child, panel.getOwnerOfPoint(new Point(0, 0)));
    assertSame(child, panel.getOwnerOfPoint(new Point(50, 50)));
    assertSame(vertical, panel.getOwnerOfPoint(new Point(90, 50)));
    assertSame(horizontal, panel.getOwnerOfPoint(new Point(50, 90)));
  }
예제 #4
0
  public void testAddingScrollBarChangesChildConsumableArea() throws Exception {
    int scrollWidth = new JScrollBar(JScrollBar.VERTICAL).getPreferredSize().width;
    style.setMargin("0");
    style.setPadding("0");
    style.setBorderWidth("0");
    panel.setSize(100, 100);

    panel.addVerticalScrollBar();
    assertEquals(100 - scrollWidth, panel.getChildConsumableArea().width);
    assertEquals(100, panel.getChildConsumableArea().height);

    panel.addHorizontalScrollBar();
    assertEquals(100 - scrollWidth, panel.getChildConsumableArea().width);
    assertEquals(100 - scrollWidth, panel.getChildConsumableArea().height);

    panel.removeVerticalScrollBar();
    assertEquals(100, panel.getChildConsumableArea().width);
    assertEquals(100 - scrollWidth, panel.getChildConsumableArea().height);

    panel.removeHorizontalScrollBar();
    assertEquals(100, panel.getChildConsumableArea().width);
    assertEquals(100, panel.getChildConsumableArea().height);
  }