<commit_before><!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>

  <link rel="import" href="helpers.html">
  <link rel="import" href="x-list.html">

</head>
<body>

  <test-fixture id="trivialList">
    <template>
      <x-list list-height="100" item-height="20"></x-list>
    </template>
  </test-fixture>

  <test-fixture id="trivialListSmall">
    <template>
      <x-list list-height="2" item-height="2"></x-list>
    </template>
  </test-fixture>

  <script>

    suite('dynamic physical count', function() {
      var list, container;

      setup(function() {
        container = fixture('trivialList');
        list = container.list;
        list.size = 200;
      });

      test('increase pool size', function(done) {
        setTimeout(function() {
          list.scrollTop = 0;

          var lastItem = list._physicalItems[list.lastVisibleIndex];
          var lastItemHeight = lastItem.offsetHeight;
          var expectedFinalItem = Math.ceil(container.listHeight / list._physicalAverage) - 1;

          assert.equal(list.offsetHeight, container.listHeight);
          assert.isTrue(isFullOfItems(list));
          assert.equal(getCellContent(lastItem).textContent, expectedFinalItem);
          done();
        }, 100);
      });
    });

    suite('iron-resize', function() {
      var list, container;

      setup(function() {
        container = fixture('trivialListSmall');
        list = container.list;
        container.style.display = 'none';
        list.size = 200;
      });

      test('increase pool size after resizing the list', function(done) {
        container.listHeight = 1000;

        flush(function() {
          expect(list._physicalItems.length).to.eql(25);

          container.style.display = '';
          list.fire('iron-resize');

          flush(function() {
            expect(list._physicalItems.length).to.be.greaterThan(25);
            done();
          });
        });
      });

      test('pool should not increase if the list has no size', function(done) {
        container.style.display = 'none';
        list.fire('iron-resize');

        flush(function() {
          assert.isFalse(list._increasePoolIfNeeded());
          done();
        });
      });
    });

  </script>

</body>
</html><commit_msg>Cleaned up physical-count tests<commit_after><!doctype html>

<html>

<head>
  <meta charset="UTF-8">
  <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>

  <link rel="import" href="helpers.html">
  <link rel="import" href="../vaadin-grid.html">

  <style is="custom-style">
    vaadin-grid {
      border: none;
    }

    vaadin-grid.small {
      --vaadin-grid-cell: {
        line-height: 10px;
        padding: 0;
      }
    }
  </style>

</head>

<body>

  <test-fixture id="default">
    <template>
      <vaadin-grid style="width: 200px; height: 200px;" size="200">
        <vaadin-grid-column>
          <template>[[index]]</template>
        </vaadin-grid-column>
      </vaadin-grid>
    </template>
  </test-fixture>

  <script>
    describe('dynamic physical count', function() {
      var scroller, grid;

      beforeEach(function() {
        grid = fixture('default');
        grid.dataSource = infiniteDataSource;
        scroller = grid.$.scroller;
      });

      it('increase pool size', function(done) {
        Polymer.RenderStatus.afterNextRender(grid, function() {
          var lastItem = scroller._physicalItems[scroller.lastVisibleIndex];
          var lastItemHeight = lastItem.offsetHeight;
          var expectedFinalItem = Math.ceil(grid.offsetHeight / scroller._physicalAverage) - 1;

          expect(scroller.offsetHeight).to.equal(grid.offsetHeight);
          expect(isFullOfItems(scroller)).to.be.true;
          expect(getCellContent(lastItem).textContent).to.equal(String(expectedFinalItem));
          done();
        });
      });

      it('increase pool size after resizing the scroller', function() {
        grid.classList.add('small');
        Polymer.updateStyles();
        grid.style.display = 'none';
        expect(scroller._physicalItems.length).to.eql(25);

        grid.style.display = '';
        scroller._update();
        Polymer.dom.flush();
        expect(scroller._physicalItems.length).to.be.greaterThan(25);
      });

      it('pool should not increase if the scroller has no size', function() {
        grid.style.display = 'none';

        grid.classList.add('small');
        Polymer.updateStyles();
        Polymer.dom.flush();

        // grid.style.display = ''; // Displaying the grid here would make
        // _increasePoolIfNeeded return truthy
        scroller._update();
        expect(scroller._increasePoolIfNeeded()).to.be.false;
      });
    });
  </script>

</body>

</html>
{'fraction_non_alphanumeric': 0.1500265064499028, 'fraction_numerical': 0.01007245096306768, 'mean_word_length': 2.6258808456117873, 'pattern_counts': {'":': 0, '<': 64, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1427944', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1647, 'n_words': 335}