/** * ****************************************************************** Miscellaneous Tests * * ****************************************************************** */ @Test public void setCurrentPageIndexAndNavigateWithKeyBoard() { pagination.setPageCount(25); pagination.setPageFactory( new Callback<Integer, Node>() { @Override public Node call(Integer pageIndex) { Node n = createPage(pageIndex); return n; } }); root.setPrefSize(400, 400); root.getChildren().add(pagination); show(); tk.firePulse(); assertTrue(pagination.isFocused()); KeyEventFirer keyboard = new KeyEventFirer(pagination); keyboard.doRightArrowPress(); tk.firePulse(); assertEquals(1, pagination.getCurrentPageIndex()); keyboard.doRightArrowPress(); tk.firePulse(); assertEquals(2, pagination.getCurrentPageIndex()); }
@Test public void divideByZeroErrorWhenSizeIsSmall_RT22687() { pagination.setPageCount(15); root.setMaxSize(100, 200); root.getChildren().add(pagination); show(); try { KeyEventFirer keyboard = new KeyEventFirer(pagination); keyboard.doRightArrowPress(); tk.firePulse(); } catch (Exception e) { fail(); } assertEquals(1, pagination.getCurrentPageIndex()); }
@Test public void pageCountIsLessThanMaxPageIndicatorCount_RT21660() { pagination.setPageCount(5); root.setPrefSize(400, 400); root.getChildren().add(pagination); show(); pagination.setCurrentPageIndex(4); tk.firePulse(); assertTrue(pagination.isFocused()); KeyEventFirer keyboard = new KeyEventFirer(pagination); keyboard.doRightArrowPress(); tk.firePulse(); assertEquals(4, pagination.getCurrentPageIndex()); }