| 1196 | generate("testMaximumRowsOrColumnsVertical", "GridLayout", testMaximumRowsOrColumnsVertical); |
| 1197 | |
| 1198 | function createDataSource(data, requests) { |
| 1199 | var dataSource = { |
| 1200 | itemsFromIndex: function (index, countBefore, countAfter) { |
| 1201 | return new WinJS.Promise(function (complete, error) { |
| 1202 | if (index >= 0 && index < data.length) { |
| 1203 | var startIndex = Math.max(0, index - countBefore), |
| 1204 | endIndex = Math.min(index + countAfter, data.length - 1), |
| 1205 | size = endIndex - startIndex + 1; |
| 1206 | |
| 1207 | var items = []; |
| 1208 | for (var i = startIndex; i < startIndex + size; i++) { |
| 1209 | items.push({ |
| 1210 | key: i.toString(), |
| 1211 | data: data[i] |
| 1212 | }); |
| 1213 | requests.push(i); |
| 1214 | } |
| 1215 | |
| 1216 | var retVal = { |
| 1217 | items: items, |
| 1218 | offset: index - startIndex, |
| 1219 | totalCount: data.length, |
| 1220 | absoluteIndex: index |
| 1221 | }; |
| 1222 | |
| 1223 | complete(retVal); |
| 1224 | } else { |
| 1225 | complete({}); |
| 1226 | } |
| 1227 | }); |
| 1228 | }, |
| 1229 | |
| 1230 | getCount: function () { |
| 1231 | return WinJS.Promise.wrap(data.length); |
| 1232 | } |
| 1233 | }; |
| 1234 | |
| 1235 | return new WinJS.UI.ListDataSource(dataSource); |
| 1236 | } |
| 1237 | |
| 1238 | var generateRecalculateItemPosition = function (layoutName) { |
| 1239 | LayoutTestsExtra.prototype["testRecalculateItemPosition" + (layoutName == "GridLayout" ? "" : layoutName)] = function (complete) { |