B2G/gecko/toolkit/content/tests/widgets/tree_shared.js
// viewidx is the row that should be visible at the top of the tree
viewidx is the row that should be visible at the top of the tree
viewidx is the row that should be visible at the top of the tree
function testtag_tree_TreeSelection_State(tree, testid, current, selected, viewidx, column)
{
  var selection = tree.view.selection;
  if (!column)
    column = (tree.selType == "cell") ? tree.columns[0] : null;
  is(selection.count, selected.length, testid + " count");
  is(tree.currentIndex, current, testid + " currentIndex");
  is(selection.currentIndex, current, testid + " TreeSelection currentIndex");
  is(selection.currentColumn, column, testid + " currentColumn");
  if (viewidx !== null && viewidx !== undefined)
    is(tree.treeBoxObject.getFirstVisibleRow(), viewidx, testid + " first visible row");
  var actualSelected = [];
  var count = tree.view.rowCount;
  for (var s = 0; s < count; s++) {
    if (selection.isSelected(s))
      actualSelected.push(s);
  }
  is(compareArrays(selected, actualSelected), true, testid + " selection [" + selected + "]");
  actualSelected = [];
  var rangecount = selection.getRangeCount();
  for (var r = 0; r < rangecount; r++) {
    var start = {}, end = {};
    selection.getRangeAt(r, start, end);
    for (var rs = start.value; rs <= end.value; rs++)
      actualSelected.push(rs);
  }
  is(compareArrays(selected, actualSelected), true, testid + " range selection [" + selected + "]");
}
function testtag_tree_TreeSelection_State ( tree , testid , current , selected , viewidx , column ) { var selection = tree . view . selection ; if ( ! column ) column = ( tree . selType == "cell" ) ? tree . columns [ 0 ] : null ; is ( selection . count , selected . length , testid + " count" ) ; is ( tree . currentIndex , current , testid + " currentIndex" ) ; is ( selection . currentIndex , current , testid + " TreeSelection currentIndex" ) ; is ( selection . currentColumn , column , testid + " currentColumn" ) ; if ( viewidx !== null && viewidx !== undefined ) is ( tree . treeBoxObject . getFirstVisibleRow ( ) , viewidx , testid + " first visible row" ) ; var actualSelected = [ ] ; var count = tree . view . rowCount ; for ( var s = 0 ; s < count ; s ++ ) { if ( selection . isSelected ( s ) ) actualSelected . push ( s ) ; } is ( compareArrays ( selected , actualSelected ) , true , testid + " selection [" + selected + "]" ) ; actualSelected = [ ] ; var rangecount = selection . getRangeCount ( ) ; for ( var r = 0 ; r < rangecount ; r ++ ) { var start = { } , end = { } ; selection . getRangeAt ( r , start , end ) ; for ( var rs = start . value ; rs <= end . value ; rs ++ ) actualSelected . push ( rs ) ; } is ( compareArrays ( selected , actualSelected ) , true , testid + " range selection [" + selected + "]" ) ; }
viewidx is the row that should be visible at the top of the tree
viewidx is the row that should be visible at the top of the tree