function testMoveAndRemoveItems() {
  var rootBlock = editor.questionnaire_.getRootBlock();
  var rootBlockChildren = rootBlock.getContainerItems();

  var firstChild = rootBlockChildren[0];
  var secondChild = rootBlockChildren[1];
  // Nothing should happen here.
  editor.moveItemUp(firstChild.container.firstChild);
  assertEquals(rootBlockChildren[0], firstChild);
  assertEquals(rootBlockChildren[1], secondChild);
  // Swap the first and second item.
  editor.moveItemDown(firstChild.container.firstChild);
  assertEquals(rootBlockChildren[1], firstChild);
  assertEquals(rootBlockChildren[0], secondChild);
  // Remove the second child so that the first child is really first again.
  editor.removeItem(secondChild.container.firstChild);
  assertEquals(rootBlockChildren[0], firstChild);

  var numberChildren = rootBlockChildren.length;
  var nextToLastChild = rootBlockChildren[numberChildren - 2];
  var lastChild = rootBlockChildren[numberChildren - 1];
  // Nothing should happen here.
  editor.moveItemDown(lastChild.container.firstChild);
  assertEquals(rootBlockChildren[numberChildren - 2], nextToLastChild);
  assertEquals(rootBlockChildren[numberChildren - 1], lastChild);
  // Swap the last and next to last item.
  editor.moveItemUp(lastChild.container.firstChild);
  assertEquals(rootBlockChildren[numberChildren - 2], lastChild);
  assertEquals(rootBlockChildren[numberChildren - 1], nextToLastChild);
  // Remove next to last child so that the last child is really last again.
  editor.removeItem(nextToLastChild.container.firstChild);
  numberChildren = rootBlockChildren.length;
  assertEquals(rootBlockChildren[numberChildren - 1], lastChild);
}
/**
 * Move items within the questionnaire.
 */
Move items within the questionnaire.
Move items within the questionnaire .
function testMoveAndRemoveItems() {
  var rootBlock = editor.questionnaire_.getRootBlock();
  var rootBlockChildren = rootBlock.getContainerItems();
  var firstChild = rootBlockChildren[0];
  var secondChild = rootBlockChildren[1];
  editor.moveItemUp(firstChild.container.firstChild);
  assertEquals(rootBlockChildren[0], firstChild);
  assertEquals(rootBlockChildren[1], secondChild);
  editor.moveItemDown(firstChild.container.firstChild);
  assertEquals(rootBlockChildren[1], firstChild);
  assertEquals(rootBlockChildren[0], secondChild);
  editor.removeItem(secondChild.container.firstChild);
  assertEquals(rootBlockChildren[0], firstChild);
  var numberChildren = rootBlockChildren.length;
  var nextToLastChild = rootBlockChildren[numberChildren - 2];
  var lastChild = rootBlockChildren[numberChildren - 1];
  editor.moveItemDown(lastChild.container.firstChild);
  assertEquals(rootBlockChildren[numberChildren - 2], nextToLastChild);
  assertEquals(rootBlockChildren[numberChildren - 1], lastChild);
  editor.moveItemUp(lastChild.container.firstChild);
  assertEquals(rootBlockChildren[numberChildren - 2], lastChild);
  assertEquals(rootBlockChildren[numberChildren - 1], nextToLastChild);
  editor.removeItem(nextToLastChild.container.firstChild);
  numberChildren = rootBlockChildren.length;
  assertEquals(rootBlockChildren[numberChildren - 1], lastChild);
}
function testMoveAndRemoveItems ( ) { var rootBlock = editor . questionnaire_ . getRootBlock ( ) ; var rootBlockChildren = rootBlock . getContainerItems ( ) ; var firstChild = rootBlockChildren [ 0 ] ; var secondChild = rootBlockChildren [ 1 ] ; editor . moveItemUp ( firstChild . container . firstChild ) ; assertEquals ( rootBlockChildren [ 0 ] , firstChild ) ; assertEquals ( rootBlockChildren [ 1 ] , secondChild ) ; editor . moveItemDown ( firstChild . container . firstChild ) ; assertEquals ( rootBlockChildren [ 1 ] , firstChild ) ; assertEquals ( rootBlockChildren [ 0 ] , secondChild ) ; editor . removeItem ( secondChild . container . firstChild ) ; assertEquals ( rootBlockChildren [ 0 ] , firstChild ) ; var numberChildren = rootBlockChildren . length ; var nextToLastChild = rootBlockChildren [ numberChildren - 2 ] ; var lastChild = rootBlockChildren [ numberChildren - 1 ] ; editor . moveItemDown ( lastChild . container . firstChild ) ; assertEquals ( rootBlockChildren [ numberChildren - 2 ] , nextToLastChild ) ; assertEquals ( rootBlockChildren [ numberChildren - 1 ] , lastChild ) ; editor . moveItemUp ( lastChild . container . firstChild ) ; assertEquals ( rootBlockChildren [ numberChildren - 2 ] , lastChild ) ; assertEquals ( rootBlockChildren [ numberChildren - 1 ] , nextToLastChild ) ; editor . removeItem ( nextToLastChild . container . firstChild ) ; numberChildren = rootBlockChildren . length ; assertEquals ( rootBlockChildren [ numberChildren - 1 ] , lastChild ) ; }
Move items within the questionnaire.
Move items within the questionnaire .
// Nothing should happen here. // Swap the first and second item. // Remove the second child so that the first child is really first again. // Nothing should happen here. // Swap the last and next to last item. // Remove next to last child so that the last child is really last again.