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

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

Issue 2604013003: [DevTools] Support variable height in ListControl. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/list-control-variable-height-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 TestRunner.addResult('Test ListControl rendering for variable height case.');
2
3 class Delegate {
4 constructor() {
5 }
6
7 createElementForItem(item) {
8 TestRunner.addResult('Creating element for ' + item);
9 var element = document.createElement('div');
10 element.style.height = this.heightForItem(item) + 'px';
11 element.textContent = item;
12 return element;
13 }
14
15 heightForItem(item) {
16 return 7 + item % 10;
17 }
18
19 isItemSelectable(item) {
20 return (item % 5 === 0) || (item % 5 === 2);
21 }
22
23 selectedItemChanged(from, to, fromElement, toElement) {
24 TestRunner.addResult('Selection changed from ' + from + ' to ' + to);
25 if (fromElement)
26 fromElement.classList.remove('selected');
27 if (toElement)
28 toElement.classList.add('selected');
29 }
30 }
31
32 var delegate = new Delegate();
33 var list = new UI.ListControl(delegate);
34 list.setHeightMode(UI.ListHeightMode.Variable);
35 list.element.style.height = '73px';
36 UI.inspectorView.element.appendChild(list.element);
37
38 function dumpList()
39 {
40 var height = list.element.offsetHeight;
41 TestRunner.addResult(`----list[length=${list.length()}][height=${height}]----` );
42 for (var child of list.element.children) {
43 var offsetTop = child.getBoundingClientRect().top - list.element.getBounding ClientRect().top;
44 var offsetBottom = child.getBoundingClientRect().bottom - list.element.getBo undingClientRect().top;
45 var visible = (offsetBottom <= 0 || offsetTop >= height) ? ' ' :
46 (offsetTop >= 0 && offsetBottom <= height ? '*' : '+');
47 var selected = child.classList.contains('selected') ? ' (selected)' : '';
48 var text = child === list._topElement ? 'top' : (child === list._bottomEleme nt ? 'bottom' : child.textContent);
49 TestRunner.addResult(`${visible}[${offsetTop}] ${text}${selected}`);
50 }
51 TestRunner.addResult('offsets: ' + list._variableOffsets.join(' '));
52 TestRunner.addResult('');
53 }
54
55 TestRunner.addResult('Adding 0, 1, 2');
56 list.replaceAllItems([0, 1, 2]);
57 dumpList();
58
59 TestRunner.addResult('Scrolling to 0');
60 list.scrollItemAtIndexIntoView(0);
61 dumpList();
62
63 TestRunner.addResult('Scrolling to 2');
64 list.scrollItemAtIndexIntoView(2);
65 dumpList();
66
67 TestRunner.addResult('Adding 3-20');
68 list.replaceItemsInRange(3, 3, [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]);
69 dumpList();
70
71 TestRunner.addResult('Scrolling to 11');
72 list.scrollItemAtIndexIntoView(11);
73 dumpList();
74
75 TestRunner.addResult('Scrolling to 19');
76 list.scrollItemAtIndexIntoView(19);
77 dumpList();
78
79 TestRunner.addResult('Scrolling to 16');
80 list.scrollItemAtIndexIntoView(16);
81 dumpList();
82
83 TestRunner.addResult('Scrolling to 3');
84 list.scrollItemAtIndexIntoView(3);
85 dumpList();
86
87 TestRunner.addResult('Replacing 0, 1 with 25-36');
88 list.replaceItemsInRange(0, 2, [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]) ;
89 dumpList();
90
91 TestRunner.addResult('Scrolling to 18');
92 list.scrollItemAtIndexIntoView(28);
93 dumpList();
94
95 TestRunner.addResult('Replacing 25-36 with 0-1');
96 list.replaceItemsInRange(0, 12, [0, 1]);
97 dumpList();
98
99 TestRunner.addResult('Replacing 16-18 with 45');
100 list.replaceItemsInRange(16, 19, [45]);
101 dumpList();
102
103 TestRunner.addResult('Scrolling to 4');
104 list.scrollItemAtIndexIntoView(4);
105 dumpList();
106
107 TestRunner.addResult('Replacing 45 with 16-18');
108 list.replaceItemsInRange(16, 17, [16, 17, 18]);
109 dumpList();
110
111 TestRunner.addResult('Resizing');
112 list.element.style.height = '190px';
113 list.viewportResized();
114 dumpList();
115
116 TestRunner.completeTest();
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/list-control-variable-height-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698