OLD | NEW |
1 TestRunner.addResult('Test ListControl rendering and selection for fixed height
case.'); | 1 TestRunner.addResult('Test ListControl rendering and selection for fixed height
case.'); |
2 | 2 |
3 class Delegate { | 3 class Delegate { |
4 constructor() { | 4 constructor() { |
5 this.height = 10; | 5 this.height = 10; |
6 } | 6 } |
7 | 7 |
8 createElementForItem(item) { | 8 createElementForItem(item) { |
9 TestRunner.addResult('Creating element for ' + item); | 9 TestRunner.addResult('Creating element for ' + item); |
10 var element = document.createElement('div'); | 10 var element = document.createElement('div'); |
(...skipping 14 matching lines...) Expand all Loading... |
25 TestRunner.addResult('Selection changed from ' + from + ' to ' + to); | 25 TestRunner.addResult('Selection changed from ' + from + ' to ' + to); |
26 if (fromElement) | 26 if (fromElement) |
27 fromElement.classList.remove('selected'); | 27 fromElement.classList.remove('selected'); |
28 if (toElement) | 28 if (toElement) |
29 toElement.classList.add('selected'); | 29 toElement.classList.add('selected'); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 var delegate = new Delegate(); | 33 var delegate = new Delegate(); |
34 var list = new UI.ListControl(delegate); | 34 var list = new UI.ListControl(delegate); |
35 list.setHeightMode(UI.ListHeightMode.Fixed); | 35 list.setMode(UI.ListMode.ViewportFixedItems); |
36 list.element.style.height = '73px'; | 36 list.element.style.height = '73px'; |
37 UI.inspectorView.element.appendChild(list.element); | 37 UI.inspectorView.element.appendChild(list.element); |
38 | 38 |
39 function dumpList() | 39 function dumpList() |
40 { | 40 { |
41 var height = list.element.offsetHeight; | 41 var height = list.element.offsetHeight; |
42 TestRunner.addResult(`----list[length=${list.length()}][height=${height}]----`
); | 42 TestRunner.addResult(`----list[length=${list.length()}][height=${height}]----`
); |
43 for (var child of list.element.children) { | 43 for (var child of list.element.children) { |
44 var offsetTop = child.getBoundingClientRect().top - list.element.getBounding
ClientRect().top; | 44 var offsetTop = child.getBoundingClientRect().top - list.element.getBounding
ClientRect().top; |
45 var offsetBottom = child.getBoundingClientRect().bottom - list.element.getBo
undingClientRect().top; | 45 var offsetBottom = child.getBoundingClientRect().bottom - list.element.getBo
undingClientRect().top; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 TestRunner.addResult('Scrolling to 12'); | 132 TestRunner.addResult('Scrolling to 12'); |
133 list.scrollItemAtIndexIntoView(12); | 133 list.scrollItemAtIndexIntoView(12); |
134 dumpList(); | 134 dumpList(); |
135 | 135 |
136 TestRunner.addResult('Scrolling to 13'); | 136 TestRunner.addResult('Scrolling to 13'); |
137 list.scrollItemAtIndexIntoView(13); | 137 list.scrollItemAtIndexIntoView(13); |
138 dumpList(); | 138 dumpList(); |
139 | 139 |
140 TestRunner.addResult('Changing the item height, switching to measure'); | 140 TestRunner.addResult('Changing the item height, switching to measure'); |
141 delegate.height = 15; | 141 delegate.height = 15; |
142 list.setHeightMode(UI.ListHeightMode.Measured); | 142 list.setMode(UI.ListMode.ViewportFixedItemsMeasured); |
143 dumpList(); | 143 dumpList(); |
144 | 144 |
145 TestRunner.addResult('Selecting 7'); | 145 TestRunner.addResult('Selecting 7'); |
146 list.selectItemAtIndex(7); | 146 list.selectItemAtIndex(7); |
147 dumpList(); | 147 dumpList(); |
148 | 148 |
149 TestRunner.addResult('Replacing 7 with 27'); | 149 TestRunner.addResult('Replacing 7 with 27'); |
150 list.replaceItemsInRange(7, 8, [27]); | 150 list.replaceItemsInRange(7, 8, [27]); |
151 dumpList(); | 151 dumpList(); |
152 | 152 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 TestRunner.addResult('Replacing all but 29 with []'); | 193 TestRunner.addResult('Replacing all but 29 with []'); |
194 list.replaceItemsInRange(0, 29, []); | 194 list.replaceItemsInRange(0, 29, []); |
195 dumpList(); | 195 dumpList(); |
196 | 196 |
197 TestRunner.addResult('ArrowDown'); | 197 TestRunner.addResult('ArrowDown'); |
198 list.onKeyDown(TestRunner.createKeyEvent('ArrowDown')); | 198 list.onKeyDown(TestRunner.createKeyEvent('ArrowDown')); |
199 dumpList(); | 199 dumpList(); |
200 | 200 |
201 TestRunner.completeTest(); | 201 TestRunner.completeTest(); |
OLD | NEW |