~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-list/test/dynamic-item-size.html

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.github.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/CONTRIBUTORS
 
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/PATENTS
 
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="../../iron-test-helpers/mock-interactions.js"></script>
 
20
 
 
21
  <link rel="import" href="helpers.html">
 
22
  <link rel="import" href="x-list.html">
 
23
 
 
24
</head>
 
25
<body>
 
26
 
 
27
  <test-fixture id="trivialList">
 
28
    <template>
 
29
      <x-list item-height="0" pre></x-list>
 
30
    </template>
 
31
  </test-fixture>
 
32
 
 
33
  <script>
 
34
 
 
35
    suite('Dynamic item size', function() {
 
36
      var list, container;
 
37
 
 
38
      setup(function() {
 
39
        container = fixture('trivialList');
 
40
        list = container.list;
 
41
      });
 
42
 
 
43
      test('update size using item index', function(done) {
 
44
        list.items = buildDataSet(100);
 
45
 
 
46
        flush(function() {
 
47
          var firstItem = getFirstItemFromList(list);
 
48
          var initHeight = firstItem.offsetHeight;
 
49
 
 
50
          list.set('items.0.index', '1\n2\n3\n4');
 
51
          list.updateSizeForItem(0);
 
52
          assert.isAbove(firstItem.offsetHeight, initHeight*3);
 
53
 
 
54
          list.set('items.0.index', '1');
 
55
          list.updateSizeForItem(0);
 
56
          assert.equal(firstItem.offsetHeight, initHeight);
 
57
 
 
58
          done();
 
59
        });
 
60
      });
 
61
 
 
62
      test('update size using item object', function(done) {
 
63
        list.items = buildDataSet(100);
 
64
 
 
65
        flush(function() {
 
66
          var firstItem = getFirstItemFromList(list);
 
67
          var initHeight = firstItem.offsetHeight;
 
68
 
 
69
          list.set('items.0.index', '1\n2\n3\n4');
 
70
          list.updateSizeForItem(list.items[0]);
 
71
          assert.isAbove(firstItem.offsetHeight, initHeight*3);
 
72
 
 
73
          list.set('items.0.index', '1');
 
74
          list.updateSizeForItem(list.items[0]);
 
75
          assert.equal(firstItem.offsetHeight, initHeight);
 
76
 
 
77
          done();
 
78
        });
 
79
      });
 
80
 
 
81
      test('ignore items that are not rendered', function(done) {
 
82
        list.items = buildDataSet(100);
 
83
 
 
84
        flush(function() {
 
85
          list.updateSizeForItem(list.items[list.items.length - 1]);
 
86
          done();
 
87
        });
 
88
      });
 
89
 
 
90
 
 
91
      test('throw if the item is invalid', function(done) {
 
92
        list.items = buildDataSet(100);
 
93
 
 
94
        flush(function() {
 
95
          var firstItem = getFirstItemFromList(list);
 
96
          var initHeight = firstItem.offsetHeight;
 
97
          var throws = 0;
 
98
 
 
99
          try {
 
100
            list.updateSizeForItem(100);
 
101
          } catch (error) {
 
102
            throws++;
 
103
          }
 
104
 
 
105
          try {
 
106
            list.updateSizeForItem({});
 
107
          } catch (error) {
 
108
            throws++;
 
109
          }
 
110
 
 
111
          assert.equal(throws, 2);
 
112
          done();
 
113
        });
 
114
      });
 
115
 
 
116
    });
 
117
 
 
118
  </script>
 
119
 
 
120
</body>
 
121
</html>