OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 @TestOn('browser') |
| 5 library polymer_elements.test.iron_list_different_heights_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:js'; |
| 9 import 'package:polymer_elements/iron_list.dart'; |
| 10 import 'package:polymer/polymer.dart'; |
| 11 import 'package:test/test.dart'; |
| 12 import 'package:web_components/web_components.dart'; |
| 13 import 'common.dart'; |
| 14 import 'iron_list_test_helpers.dart'; |
| 15 import 'fixtures/x_list.dart'; |
| 16 |
| 17 /// Uses [XList]. |
| 18 main() async { |
| 19 await initPolymer(); |
| 20 |
| 21 group('Different heights', () { |
| 22 IronList list; |
| 23 XList container; |
| 24 |
| 25 setUp(() { |
| 26 container = fixture('trivialList'); |
| 27 list = container.list; |
| 28 }); |
| 29 |
| 30 test('render without gaps 1', () async { |
| 31 list.items = [ |
| 32 {'index': 0, 'height': 791}, |
| 33 {'index': 1, 'height': 671} |
| 34 ]; |
| 35 |
| 36 await wait(1); |
| 37 list.addAll('items', [ |
| 38 {'index': 2, 'height': 251}, |
| 39 {'index': 3, 'height': 191}, |
| 40 {'index': 4, 'height': 151}, |
| 41 {'index': 5, 'height': 191}, |
| 42 {'index': 6, 'height': 51}, |
| 43 {'index': 7, 'height': 51}, |
| 44 {'index': 8, 'height': 51}, |
| 45 ]); |
| 46 |
| 47 list.on['scroll'].first.then((_) { |
| 48 expect(isFullOfItems(list), isTrue); |
| 49 }); |
| 50 |
| 51 var done = new Completer(); |
| 52 simulateScroll({'list': list, 'contribution': 15, 'target': 100000}, (_) { |
| 53 done.complete(); |
| 54 }); |
| 55 |
| 56 return done.future; |
| 57 }); |
| 58 |
| 59 test('render without gaps 2', () async { |
| 60 var height = 2, items = []; |
| 61 |
| 62 while (items.length < 15) { |
| 63 items.add({'height': height}); |
| 64 height *= 1.5; |
| 65 } |
| 66 list.items = items; |
| 67 |
| 68 await wait(1); |
| 69 list.on['scroll'].first.then((_) { |
| 70 expect(isFullOfItems(list), isTrue); |
| 71 }); |
| 72 |
| 73 var done = new Completer(); |
| 74 simulateScroll({'list': list, 'contribution': 20, 'target': 100000}, (_) { |
| 75 done.complete(); |
| 76 }); |
| 77 |
| 78 return done.future; |
| 79 }); |
| 80 |
| 81 test('render without gaps 3', () async { |
| 82 var heights = [ |
| 83 20, |
| 84 100, |
| 85 140, |
| 86 117, |
| 87 800, |
| 88 50, |
| 89 15, |
| 90 80, |
| 91 90, |
| 92 255, |
| 93 20, |
| 94 15, |
| 95 19, |
| 96 250, |
| 97 314 |
| 98 ]; |
| 99 |
| 100 list.items = heights.map((height) { |
| 101 return {'height': height}; |
| 102 }).toList(); |
| 103 |
| 104 await wait(1); |
| 105 list.on['scroll'].first.then((_) { |
| 106 expect(isFullOfItems(list), isTrue); |
| 107 }); |
| 108 |
| 109 var done = new Completer(); |
| 110 simulateScroll({'list': list, 'contribution': 20, 'target': 100000}, (_) { |
| 111 done.complete(); |
| 112 }); |
| 113 |
| 114 return done.future; |
| 115 }); |
| 116 }); |
| 117 } |
OLD | NEW |