Index: third_party/polymer/components/core-list/test/core-list-data.html |
diff --git a/third_party/polymer/components/core-list/test/core-list-data.html b/third_party/polymer/components/core-list/test/core-list-data.html |
deleted file mode 100644 |
index ebba3cbfc0925bf939755c3f3f4fd4455886f725..0000000000000000000000000000000000000000 |
--- a/third_party/polymer/components/core-list/test/core-list-data.html |
+++ /dev/null |
@@ -1,191 +0,0 @@ |
-<!doctype html> |
-<!-- |
-Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
-This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
-The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
-The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
-Code distributed by Google as part of the polymer project is also |
-subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
---> |
-<html> |
-<head> |
- <title>core-list</title> |
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> |
- <script src="../../webcomponentsjs/webcomponents.js"></script> |
- <script src="../../web-component-tester/browser.js"></script> |
- <link rel="import" href="../core-list.html"> |
- <style> |
- body { |
- margin: 0; |
- height: 100%; |
- } |
- core-list { |
- display: block; |
- height: 100%; |
- margin: 0 auto; |
- } |
- input { |
- width: 20px; |
- } |
- .item { |
- height: 80px; |
- background: lightblue; |
- } |
- .item.selected { |
- background: orange; |
- } |
- </style> |
-</head> |
-<body fit> |
- |
-<core-list id="list"> |
- <template> |
- <div class="item {{ selected ? 'selected' : '' }}"> |
- <span id="index">{{index}}</span><br> |
- <span id="id">{{model.id}}</span><br> |
- <input id="checkbox" type="checkbox" checked="{{model.checked}}"> |
- <input id="input" type="number" _value="{{model.value}}" class="narrow"> |
- <select id="select" selectedIndex="{{model.type}}"><option>a</option><option>b</option><option>c</option></select> |
- </div> |
- </template> |
-</core-list> |
- |
-<script> |
- test('core-list-data', function(done) { |
- // Initial setup |
- var list = document.querySelector('core-list'); |
- var height = 80; |
- var physicalCount = Math.ceil(list.offsetHeight / height); |
- var index = 0; |
- // Helper to create random items |
- var generateItem = function() { |
- return { |
- id: Math.floor(Math.random()*10000), |
- checked: !!Math.floor(Math.random()*2), |
- value: Math.floor(Math.random()*10000), |
- type: Math.floor(Math.random()*3) |
- }; |
- }; |
- // Helper to populate the list |
- var populateList = function(next) { |
- var more = physicalCount * 20; |
- list.data = []; |
- while (more--) { |
- list.data.push(generateItem()); |
- } |
- waitFor(function() { |
- chai.assert(list.children.length > physicalCount + 1, // (+1 for template) |
- 'children.length should be > ' + physicalCount + ' (1 template + max number of elements) after populating list'); |
- for (i=1; i<list.children.length - 1; i++) { |
- chai.assert(list.children[i].getAttribute('hidden') === null, |
- 'all items should be visible after populating list; item ' + i + ' was hidden'); |
- } |
- }, next); |
- }; |
- async.series([ |
- // Set data to null |
- function(next) { |
- populateList(function() { |
- list.children[1].listHasNotReRendered = true; |
- list.data = null; |
- waitFor(function() { |
- chai.assert(list.children[1].listHasNotReRendered, |
- 'list should not re-render when setting list.data to null'); |
- chai.assert(list.children.length > physicalCount + 1, // (+1 for template) |
- 'children.length should be > ' + physicalCount + ' (1 template + max number of elements'); |
- for (i=1; i<list.children.length - 1; i++) { |
- chai.assert(list.children[i].getAttribute('hidden') !== null, |
- 'all items should be hidden after setting list.data to null; item ' + i + ' was not hidden'); |
- } |
- }, next); |
- }); |
- }, |
- // Splice all items from data |
- function(next) { |
- populateList(function() { |
- list.data.splice(0, list.data.length); |
- waitFor(function() { |
- chai.assert(list.children[1].listHasNotReRendered, |
- 'list should not re-render when splicing all items from list.data'); |
- chai.assert(list.children.length > physicalCount + 1, // (+1 for template) |
- 'children.length should be > ' + physicalCount + ' (1 template + max number of elements'); |
- for (i=1; i<list.children.length - 1; i++) { |
- chai.assert(list.children[i].getAttribute('hidden') !== null, |
- 'all items should be hidden; item after splicing all items from list.data' + i + ' was not hidden'); |
- } |
- }, next); |
- }); |
- }, |
- // Set data to empty array |
- function(next) { |
- populateList(function() { |
- list.data = []; |
- waitFor(function() { |
- chai.assert(list.children[1].listHasNotReRendered, |
- 'list should not re-render when initializing list.data to []'); |
- chai.assert(list.children.length > physicalCount + 1, // (+1 for template) |
- 'children.length should be > ' + physicalCount + ' (1 template + max number of elements'); |
- for (i=1; i<list.children.length - 1; i++) { |
- chai.assert(list.children[i].getAttribute('hidden') !== null, |
- 'all items should be hidden; item after initializing list.data to []' + i + ' was not hidden'); |
- } |
- }, next); |
- }); |
- }, |
- // Push one item |
- function(next) { |
- list.data.push(generateItem()); |
- waitFor(function() { |
- chai.assert(list.children[1].listHasNotReRendered, |
- 'list should not re-render when adding items to list'); |
- chai.assert(list.children.length > physicalCount + 1, // (+1 for template) |
- 'children.length should be > ' + physicalCount + ' (1 template + max number of elements'); |
- chai.assert(list.children[1].querySelector('#index').textContent == '0', |
- 'first item index content should be ' + index + ' after adding item to list'); |
- chai.assert(list.children[1].querySelector('#id').textContent == list.data[0].id, |
- 'first item id content should be ' + list.data[0].id + ' after adding item to list'); |
- for (var i=1; i<list.children.length - 1; i++) { |
- if (i < 2) { |
- chai.assert(list.children[i].getAttribute('hidden') === null, |
- 'first 1 item should not be hidden after adding an item'); |
- } else { |
- chai.assert(list.children[i].getAttribute('hidden') !== null, |
- 'remaining items should be hidden after adding an item'); |
- } |
- } |
- }, next); |
- }, |
- // Push another item |
- function(next) { |
- list.data.push(generateItem()); |
- waitFor(function() { |
- chai.assert(list.children[1].listHasNotReRendered, |
- 'list should not re-render when adding items to list'); |
- chai.assert(list.children.length > physicalCount + 1, // (+1 for template) |
- 'children.length should be ' + physicalCount + ' (1 template + max number of elements'); |
- chai.assert(list.children[1].querySelector('#index').textContent == '0', |
- 'first item index content should be 0 after adding item to list'); |
- chai.assert(list.children[1].querySelector('#id').textContent == list.data[0].id, |
- 'first item id content should be ' + list.data[0].id + ' after adding item to list'); |
- chai.assert(list.children[2].querySelector('#index').textContent == '1', |
- 'second item index content should be 1 after adding item to list'); |
- chai.assert(list.children[2].querySelector('#id').textContent == list.data[1].id, |
- 'second item id content should be ' + list.data[1].id + ' after adding item to list'); |
- for (var i=1; i<list.children.length - 1; i++) { |
- if (i < 3) { |
- chai.assert(list.children[i].getAttribute('hidden') === null, |
- 'first 1 item should not be hidden after adding an item'); |
- } else { |
- chai.assert(list.children[i].getAttribute('hidden') !== null, |
- 'remaining items should be hidden after adding an item'); |
- } |
- } |
- }, next); |
- } |
- ], done); |
- }); |
- |
-</script> |
- |
-</body> |
-</html> |