OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS |
| 8 Code distributed by Google as part of the polymer project is also |
| 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <meta charset="UTF-8"> |
| 14 <title>iron-list test</title> |
| 15 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> |
| 16 |
| 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 18 <script src="../../web-component-tester/browser.js"></script> |
| 19 <script src="../../test-fixture/test-fixture-mocha.js"></script> |
| 20 <script src="../../iron-test-helpers/mock-interactions.js"></script> |
| 21 |
| 22 <link rel="import" href="../../test-fixture/test-fixture.html"> |
| 23 <link rel="import" href="../../paper-styles/paper-styles.html"> |
| 24 <link rel="import" href="helpers.html"> |
| 25 <link rel="import" href="x-list.html"> |
| 26 |
| 27 </head> |
| 28 <body> |
| 29 |
| 30 <test-fixture id="trivialList"> |
| 31 <template> |
| 32 <x-list></x-list> |
| 33 </template> |
| 34 </test-fixture> |
| 35 |
| 36 <script> |
| 37 |
| 38 suite('Different heights', function() { |
| 39 var list, container; |
| 40 |
| 41 setup(function() { |
| 42 container = fixture('trivialList'); |
| 43 list = container.list; |
| 44 }); |
| 45 |
| 46 test('render without gaps 1', function(done) { |
| 47 list.items = [ |
| 48 {index: 0, height: 791}, |
| 49 {index: 1, height: 671} |
| 50 ]; |
| 51 |
| 52 flush(function() { |
| 53 list.push('items', |
| 54 {index: 2, height: 251}, |
| 55 {index: 3, height: 191}, |
| 56 {index: 4, height: 151}, |
| 57 {index: 5, height: 191}, |
| 58 {index: 6, height: 51}, |
| 59 {index: 7, height: 51}, |
| 60 {index: 8, height: 51} |
| 61 ); |
| 62 |
| 63 list.addEventListener('scroll', function() { |
| 64 assert.isTrue(isFullOfItems(list)); |
| 65 }); |
| 66 |
| 67 simulateScroll({ |
| 68 list: list, |
| 69 contribution: 15, |
| 70 target: 100000 |
| 71 }, function() { |
| 72 done(); |
| 73 }); |
| 74 }); |
| 75 }); |
| 76 |
| 77 test('render without gaps 2', function(done) { |
| 78 var height = 2, items = []; |
| 79 |
| 80 while (items.length < 15) { |
| 81 items.push({height: height}); |
| 82 height *= 1.5; |
| 83 } |
| 84 list.items = items; |
| 85 |
| 86 flush(function() { |
| 87 list.addEventListener('scroll', function() { |
| 88 assert.isTrue(isFullOfItems(list)); |
| 89 }); |
| 90 |
| 91 simulateScroll({ |
| 92 list: list, |
| 93 contribution: 20, |
| 94 target: 100000 |
| 95 }, function() { |
| 96 done(); |
| 97 }); |
| 98 }); |
| 99 }); |
| 100 |
| 101 test('render without gaps 3', function(done) { |
| 102 var heights = [20, 100, 140, 117, 800, 50, 15, 80, 90, 255, 20, 15, 19,
250, 314]; |
| 103 |
| 104 list.items = heights.map(function(height) { |
| 105 return {height: height}; |
| 106 }); |
| 107 |
| 108 flush(function() { |
| 109 list.addEventListener('scroll', function() { |
| 110 assert.isTrue(isFullOfItems(list)); |
| 111 }); |
| 112 |
| 113 simulateScroll({ |
| 114 list: list, |
| 115 contribution: 20, |
| 116 target: 100000 |
| 117 }, function() { |
| 118 done(); |
| 119 }); |
| 120 }); |
| 121 }); |
| 122 |
| 123 }); |
| 124 |
| 125 </script> |
| 126 |
| 127 </body> |
| 128 </html> |
OLD | NEW |