<commit_before>// Copyright (c) 2013, the polymer_elements.dart project authors.  Please see 
// the AUTHORS file for details. All rights reserved. Use of this source code is 
// governed by a BSD-style license that can be found in the LICENSE file.
// This work is a port of the polymer-elements from the Polymer project, 
// http://www.polymer-project.org/. 


library polymer_collapse;

import "dart:html" show document, HtmlElement, Node, NodeTreeSanitizer;
import "dart:async" show Future, Timer;
import "package:polymer/polymer.dart" show initMethod, initPolymer;
import "package:unittest/unittest.dart" show equals, expect, expectAsync0, isFalse, isNot, test;
import "package:unittest/html_enhanced_config.dart" show useHtmlEnhancedConfiguration;
import "package:polymer_elements/polymer_collapse/polymer_collapse.dart" show PolymerCollapse;

/**
 * Sanitizer which does nothing.
 */
class NullTreeSanitizer implements NodeTreeSanitizer {
  void sanitizeTree(Node node) {}
}

void main() { 
  useHtmlEnhancedConfiguration();

  initPolymer();
  
  test("polymer-collapse", () {
    Duration delay = new Duration(milliseconds: 300);
    var done = expectAsync0((){});
    Timer.run(() {
      var c = document.querySelector('#collapse') as PolymerCollapse;
      expect(c.closed, isFalse);
      new Future.delayed(delay,() {
        var origH = getBoxComputedHeight();
        expect(origH, isNot(equals(0)));
        c.closed = true;
        c.deliverChanges();
        new Future.delayed(delay, () {
          // after closed, height is 0
          expect(getBoxComputedHeight(), equals(0));
          // should be set to display: none
          expect(getBoxComputedStyle().display, equals('none'));
          c.closed = false;
          c.deliverChanges();
          new Future.delayed(delay, () {
            // verify computed height
            expect(getBoxComputedHeight(), equals(origH));
            // after opened, height is set to 'auto'
            expect(document.querySelector('#box').style.height, equals('auto'));
            done();
          });
        });
      });
    });
  });
}

  
dynamic getBoxComputedStyle() {
  HtmlElement b = document.querySelector('#box');
  return b.getComputedStyle();
}

int getBoxComputedHeight() {
  String h = getBoxComputedStyle().height;
  String digits = new RegExp(r"^(\d+).*$").firstMatch(h).group(1);
  return int.parse(digits);
}<commit_msg>fix test to run in polymer zone #93<commit_after>// Copyright (c) 2013, the polymer_elements.dart project authors.  Please see 
// the AUTHORS file for details. All rights reserved. Use of this source code is 
// governed by a BSD-style license that can be found in the LICENSE file.
// This work is a port of the polymer-elements from the Polymer project, 
// http://www.polymer-project.org/. 


library polymer_collapse;

import "dart:html" show document, HtmlElement, Node, NodeTreeSanitizer;
import "dart:async" show Future, Timer;
import "package:polymer/polymer.dart" show initMethod, initPolymer;
import "package:unittest/unittest.dart" show equals, expect, expectAsync0, isFalse, isNot, test;
import "package:unittest/html_enhanced_config.dart" show useHtmlEnhancedConfiguration;
import "package:polymer_elements/polymer_collapse/polymer_collapse.dart" show PolymerCollapse;

/**
 * Sanitizer which does nothing.
 */
class NullTreeSanitizer implements NodeTreeSanitizer {
  void sanitizeTree(Node node) {}
}

void main() { 
  useHtmlEnhancedConfiguration();

  initPolymer().run(() {
  
    test("polymer-collapse", () {
      Duration delay = new Duration(milliseconds: 300);
      var done = expectAsync0((){});
      Timer.run(() {
        var c = document.querySelector('#collapse') as PolymerCollapse;
        expect(c.closed, isFalse);
        new Future.delayed(delay,() {
          var origH = getBoxComputedHeight();
          expect(origH, isNot(equals(0)));
          c.closed = true;
          //c.deliverChanges();
          new Future.delayed(delay, () {
            // after closed, height is 0
            expect(getBoxComputedHeight(), equals(0));
            // should be set to display: none
            expect(getBoxComputedStyle().display, equals('none'));
            c.closed = false;
            //c.deliverChanges();
            new Future.delayed(delay, () {
              // verify computed height
              expect(getBoxComputedHeight(), equals(origH));
              // after opened, height is set to 'auto'
              expect(document.querySelector('#box').style.height, equals('auto'));
              done();
            });
          });
        });
      });
    });
  });
}

  
dynamic getBoxComputedStyle() {
  HtmlElement b = document.querySelector('#box');
  return b.getComputedStyle();
}

int getBoxComputedHeight() {
  String h = getBoxComputedStyle().height;
  String digits = new RegExp(r"^(\d+).*$").firstMatch(h).group(1);
  return int.parse(digits);
}
{'fraction_non_alphanumeric': 0.12637139374238116, 'fraction_numerical': 0.005688744412840309, 'mean_word_length': 3.112781954887218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1849983', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1397, 'n_words': 373}