Elim cr-checkbox
[chromium-blink-merge.git] / chrome / test / data / webui / list_selection_model_test_util.js
bloba604dc4c58f7ca3f9702b27a554df20a62e4294c
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 /**
6 * Creates an array spanning a range of integer values.
7 * @param {number} start The first number in the range.
8 * @param {number} end The last number in the range inclusive.
9 * @return {!Array<number>}
11 function range(start, end) {
12 var a = [];
13 for (var i = start; i <= end; i++) {
14 a.push(i);
16 return a;
19 /**
20 * Modifies a selection model.
21 * @param {!ListSelectionModel} model The selection model to adjust.
22 * @param {number} index Starting index of the edit.
23 * @param {number} removed Number of entries to remove from the list.
24 * @param {number} added Number of entries to add to the list.
26 function adjust(model, index, removed, added) {
27 var permutation = [];
28 for (var i = 0; i < index; i++) {
29 permutation.push(i);
31 for (var i = 0; i < removed; i++) {
32 permutation.push(-1);
34 for (var i = index + removed; i < model.length; i++) {
35 permutation.push(i - removed + added);
37 model.adjustLength(model.length - removed + added);
38 model.adjustToReordering(permutation);