@Test
 public void testShowRootAnchorOn() {
   initSkin();
   int index = 3;
   getSelectionModel().select(index);
   assertEquals("sanity: anchor", index, getAnchorIndex());
   getView().setShowRoot(true);
   assertEquals(index + 1, getAnchorIndex());
 }
 protected void assertBehaviourFocusMove(String method, int intialSelected, int expectedFocus)
     throws Exception {
   initSkin();
   getSelectionModel().select(intialSelected);
   invokeBehavior(method);
   assertEquals(method + " focus must be moved", expectedFocus, getFocusedIndex());
   assertFalse(
       method + " focus must not be selected", getSelectionModel().isSelected(expectedFocus));
   assertEquals(method + " selection must be unchanged", intialSelected, getSelectedIndex());
   assertEquals(method + " anchor must be unchanged", intialSelected, getAnchorIndex());
 }
 /**
  * Steps tested:
  *
  * <p>select -> run (if not null) -> invokeBehavior(method) -> test selection/focus state
  *
  * @param method the name of the method do invoke in behaviour
  * @param selectedIndex the index to select
  * @param expectedIndex the expected index after running and invoking
  * @param run the action to run after selecting, may be null to do nothing
  * @throws Exception
  */
 protected void assertBehaviorSelectionMovedWithModification(
     String method, int selectedIndex, int expectedIndex, Runnable run) throws Exception {
   initSkin();
   getSelectionModel().select(selectedIndex);
   if (run != null) run.run();
   invokeBehavior(method);
   assertEquals(method + " selected index must be moved", expectedIndex, getSelectedIndex());
   assertEquals(method + " focus must same as selected index", expectedIndex, getFocusedIndex());
   assertEquals(method + " selection size must be one", 1, getSelectedIndices().size());
   assertEquals(method + " anchor must be same as focus", expectedIndex, getAnchorIndex());
 }
 /**
  * @param anchorFocus
  * @throws Exception
  */
 protected void assertBehaviorSelectAllToFocus(boolean anchorFocus) throws Exception {
   initSkin();
   String method = "selectAllToFocus";
   int index = 2;
   getSelectionModel().select(index);
   int focus = 4;
   int size = focus - index + 1;
   getFocusModel().focus(focus);
   invokeBehavior(method, anchorFocus);
   assertEquals(focus, getSelectedIndex());
   assertEquals("sanity: focus unchanged", focus, getFocusedIndex());
   if (multipleMode) {
     int expectedAnchor = anchorFocus ? focus : index;
     assertEquals(expectedAnchor, getAnchorIndex());
     assertEquals(size, getSelectedIndices().size());
   } else {
     assertEquals(focus, getAnchorIndex());
     assertEquals(1, getSelectedIndices().size());
   }
 }
 /**
  * Sets up the selection model with one index selected initially and asserts state for after
  * invoking a method that extends the selection.
  *
  * @param method the name of the method to test
  * @param index the index to select initially
  * @param focus the expected selected index/focus after invoking the method
  * @param size the size of the selectedIndices
  * @throws Exception bunch of exceptions if reflective method lookup/invocation fails
  */
 protected void assertBehaviourSelectionExtended(String method, int index, int focus, int size)
     throws Exception {
   initSkin();
   getSelectionModel().select(index);
   invokeKey("isShiftDown");
   invokeBehavior(method);
   assertEquals(method + " selected index must be moved", focus, getSelectedIndex());
   assertEquals(method + " focus must be moved", focus, getFocusedIndex());
   if (multipleMode) {
     assertEquals(
         method + " selection size must be changed in multiple mode",
         size,
         getSelectedIndices().size());
     assertEquals(method + " anchor must be unchanged in multiple mode", index, getAnchorIndex());
   } else {
     assertEquals(
         method + " selection size must be 1 in single mode", 1, getSelectedIndices().size());
     assertEquals(
         method + " anchor must be updated to focus in single mode", focus, getAnchorIndex());
   }
 }