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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/list-model.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/list-model.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/list-model.js
new file mode 100644
index 0000000000000000000000000000000000000000..9fbf6c885dc8dd92d94bfadd55b48826815e75f1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/list-model.js
@@ -0,0 +1,50 @@
+TestRunner.addResult('Test ListModel API.');
+
+var list = new UI.ListModel();
+list.addEventListener(UI.ListModel.Events.ItemsReplaced, event => {
+ var data = event.data;
+ var inserted = [];
+ for (var index = data.index; index < data.index + data.inserted; index++)
+ inserted.push(list.itemAtIndex(index));
+ TestRunner.addResult(`Replaced [${data.removed.join(', ')}] at index ${data.index} with [${inserted.join(', ')}]`);
+ var all = [];
+ for (var index = 0; index < list.length(); index++)
+ all.push(list.itemAtIndex(index));
+ TestRunner.addResult(`Resulting list: [${all.join(', ')}]`);
+ TestRunner.addResult('');
+});
+
+TestRunner.addResult('Adding 0, 1, 2');
+list.replaceAllItems([0, 1, 2]);
+
+TestRunner.addResult('Replacing 0 with 5, 6, 7');
+list.replaceItemsInRange(0, 1, [5, 6, 7]);
+
+TestRunner.addResult('Pushing 10');
+list.pushItem(10);
+
+TestRunner.addResult('Popping 10');
+list.popItem();
+
+TestRunner.addResult('Removing 2');
+list.removeItemAtIndex(4);
+
+TestRunner.addResult('Inserting 8');
+list.insertItemAtIndex(1, 8);
+
+TestRunner.addResult('Replacing with 0...20');
+list.replaceAllItems([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]);
+
+TestRunner.addResult('Replacing 7 with 27');
+list.replaceItemsInRange(7, 8, [27]);
+
+TestRunner.addResult('Replacing 18, 19 with 28, 29');
+list.replaceItemsInRange(18, 20, [28, 29]);
+
+TestRunner.addResult('Replacing 1, 2, 3 with [31-43]');
+list.replaceItemsInRange(1, 4, [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]);
+
+TestRunner.addResult('Replacing all but 29 with []');
+list.replaceItemsInRange(0, 29, []);
+
+TestRunner.completeTest();

Powered by Google App Engine
This is Rietveld 408576698