Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/list-model.js

Issue 2916743002: [DevTools] Introduce Common.List used as a backend for list controls (Closed)
Patch Set: addressed comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 TestRunner.addResult('Test ListModel API.');
2
3 var list = new UI.ListModel();
4 list.addEventListener(UI.ListModel.Events.ItemsReplaced, event => {
5 var data = event.data;
6 var inserted = [];
7 for (var index = data.index; index < data.index + data.inserted; index++)
8 inserted.push(list.itemAtIndex(index));
9 TestRunner.addResult(`Replaced [${data.removed.join(', ')}] at index ${data.in dex} with [${inserted.join(', ')}]`);
10 var all = [];
11 for (var index = 0; index < list.length(); index++)
12 all.push(list.itemAtIndex(index));
13 TestRunner.addResult(`Resulting list: [${all.join(', ')}]`);
14 TestRunner.addResult('');
15 });
16
17 TestRunner.addResult('Adding 0, 1, 2');
18 list.replaceAllItems([0, 1, 2]);
19
20 TestRunner.addResult('Replacing 0 with 5, 6, 7');
21 list.replaceItemsInRange(0, 1, [5, 6, 7]);
22
23 TestRunner.addResult('Pushing 10');
24 list.pushItem(10);
25
26 TestRunner.addResult('Popping 10');
27 list.popItem();
28
29 TestRunner.addResult('Removing 2');
30 list.removeItemAtIndex(4);
31
32 TestRunner.addResult('Inserting 8');
33 list.insertItemAtIndex(1, 8);
34
35 TestRunner.addResult('Replacing with 0...20');
36 list.replaceAllItems([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]);
37
38 TestRunner.addResult('Replacing 7 with 27');
39 list.replaceItemsInRange(7, 8, [27]);
40
41 TestRunner.addResult('Replacing 18, 19 with 28, 29');
42 list.replaceItemsInRange(18, 20, [28, 29]);
43
44 TestRunner.addResult('Replacing 1, 2, 3 with [31-43]');
45 list.replaceItemsInRange(1, 4, [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]);
46
47 TestRunner.addResult('Replacing all but 29 with []');
48 list.replaceItemsInRange(0, 29, []);
49
50 TestRunner.completeTest();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698