Blame view

bower_components/iron-list/test/physical-count.html 2.7 KB
e619a3b0   Luigi Serra   Controllet cross ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  <!doctype html>
  <!--
  @license
  Copyright (c) 2015 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
  The complete set of authors may be found at http://polymer.github.io/AUTHORS
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
  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
  -->
  <html>
  <head>
    <meta charset="UTF-8">
    <title>iron-list test</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  
    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
    <script src="../../web-component-tester/browser.js"></script>
e619a3b0   Luigi Serra   Controllet cross ...
19
  
e619a3b0   Luigi Serra   Controllet cross ...
20
21
22
23
24
25
26
27
    <link rel="import" href="helpers.html">
    <link rel="import" href="x-list.html">
  
  </head>
  <body>
  
    <test-fixture id="trivialList">
      <template>
a53fbbed   Renato De Donato   select-dataset ne...
28
29
30
31
32
33
34
        <x-list list-height="100" item-height="2"></x-list>
      </template>
    </test-fixture>
  
    <test-fixture id="trivialListSmall">
      <template>
        <x-list list-height="2" item-height="2"></x-list>
e619a3b0   Luigi Serra   Controllet cross ...
35
36
37
      </template>
    </test-fixture>
  
e619a3b0   Luigi Serra   Controllet cross ...
38
39
40
41
42
43
44
45
    <script>
  
      suite('dynamic physical count', function() {
        var list, container;
  
        setup(function() {
          container = fixture('trivialList');
          list = container.list;
a53fbbed   Renato De Donato   select-dataset ne...
46
          list.items = buildDataSet(200);
e619a3b0   Luigi Serra   Controllet cross ...
47
48
49
        });
  
        test('increase pool size', function(done) {
a53fbbed   Renato De Donato   select-dataset ne...
50
51
          setTimeout(function() {
            list.scrollTop = 0;
c5169e0e   Renato De Donato   a new hope
52
  
e619a3b0   Luigi Serra   Controllet cross ...
53
54
            var lastItem = getLastItemFromList(list);
            var lastItemHeight = lastItem.offsetHeight;
a53fbbed   Renato De Donato   select-dataset ne...
55
            var expectedFinalItem = container.listHeight/lastItemHeight - 1;
e619a3b0   Luigi Serra   Controllet cross ...
56
  
a53fbbed   Renato De Donato   select-dataset ne...
57
            assert.equal(list.offsetHeight, container.listHeight);
e619a3b0   Luigi Serra   Controllet cross ...
58
            assert.equal(lastItemHeight, 2);
a53fbbed   Renato De Donato   select-dataset ne...
59
60
            assert.isTrue(isFullOfItems(list));
            assert.equal(lastItem.textContent, expectedFinalItem);
e619a3b0   Luigi Serra   Controllet cross ...
61
            done();
a53fbbed   Renato De Donato   select-dataset ne...
62
          }, 100);
e619a3b0   Luigi Serra   Controllet cross ...
63
        });
a53fbbed   Renato De Donato   select-dataset ne...
64
      });
e619a3b0   Luigi Serra   Controllet cross ...
65
  
a53fbbed   Renato De Donato   select-dataset ne...
66
67
      suite('iron-resize', function() {
        var list, container;
e619a3b0   Luigi Serra   Controllet cross ...
68
  
a53fbbed   Renato De Donato   select-dataset ne...
69
70
71
72
73
74
75
76
        setup(function() {
          container = fixture('trivialListSmall');
          list = container.list;
          list.style.display = 'none';
          list.items = buildDataSet(200);
        });
  
        test('increase pool size after resizing the list', function(done) {
e619a3b0   Luigi Serra   Controllet cross ...
77
          flush(function() {
a53fbbed   Renato De Donato   select-dataset ne...
78
79
80
            list.style.display = '';
            assert.notEqual(getFirstItemFromList(list).textContent, '0', 'Item should not be rendered');
  
f748e9cf   Luigi Serra   new controllet an...
81
            list.fire('iron-resize');
c5169e0e   Renato De Donato   a new hope
82
83
  
            flush(function() {
a53fbbed   Renato De Donato   select-dataset ne...
84
              assert.equal(getFirstItemFromList(list).textContent, '0', 'Item should be rendered');
e619a3b0   Luigi Serra   Controllet cross ...
85
              done();
c5169e0e   Renato De Donato   a new hope
86
            });
e619a3b0   Luigi Serra   Controllet cross ...
87
88
          });
        });
c5169e0e   Renato De Donato   a new hope
89
  
e619a3b0   Luigi Serra   Controllet cross ...
90
      });
c5169e0e   Renato De Donato   a new hope
91
  
e619a3b0   Luigi Serra   Controllet cross ...
92
93
94
95
    </script>
  
  </body>
  </html>