Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: pkg/polymer/test/event_binding_release_handler_test.dart

Issue 507653004: update polymer to 0.3.5 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review updates Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/polymer/test/event_binding_release_handler_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/event_binding_release_handler_test.dart
diff --git a/pkg/polymer/test/event_binding_release_handler_test.dart b/pkg/polymer/test/event_binding_release_handler_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..784683a39f68100972f04e7cf41084ffdfb33e22
--- /dev/null
+++ b/pkg/polymer/test/event_binding_release_handler_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2013, the 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.
+
+library polymer.test.event_binding_release_handler_test;
+
+import 'dart:async';
+import 'dart:html';
+import 'package:polymer/polymer.dart';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'package:template_binding/template_binding.dart';
+
+@CustomTag('x-foo')
+class XFoo extends PolymerElement {
+ @PublishedProperty(reflect: true)
+ int count = 1;
+
+ XFoo.created() : super.created();
+
+ increment() { ++count; }
+}
+
+main() {
+ // Do not run the test in the zone so the future does not trigger a
+ // dirtyCheck. We want to verify that event bindings trigger dirty checks on
+ // their own.
+ initPolymer();
+
+ useHtmlConfiguration();
+
+ setUp(() => Polymer.onReady);
+
+ test('event handlers can be released', () {
+ XFoo element = querySelector('x-foo');
+ expect(element, isNotNull);
+ ButtonElement button = element.shadowRoot.querySelector('button');
+ expect(button, isNotNull);
+
+ button.click();
+ return new Future(() {}).then((_) {
+ expect(element.shadowRoot.querySelector('p').text, 'Count: 2');
+ // Remove and detach the element so the binding is invalidated.
+ element.remove();
+ element.detached();
+ }).then((_) => new Future(() {})).then((_) {
+ // Clicks should no longer affect the elements count.
+ button.click();
+ // TODO(jakemac): This is flaky so its commented out, (the rest of the
+ // test is not flaky). Figure out how to make this not flaky.
+// expect(element.count, 2);
+ });
+ });
+}
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/polymer/test/event_binding_release_handler_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698