| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library polymer.test.unbind_test; | 5 library polymer.test.unbind_test; |
| 6 | 6 |
| 7 import 'dart:async' show Future, scheduleMicrotask; | 7 import 'dart:async' show Future, scheduleMicrotask; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 | 9 |
| 10 @MirrorsUsed(targets: const [Polymer], override: 'polymer.test.unbind_test') | 10 @MirrorsUsed(targets: const [Polymer], override: 'polymer.test.unbind_test') |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // extra beat. | 62 // extra beat. |
| 63 delay(x) => new Future.delayed(new Duration(milliseconds: 50), () => x); | 63 delay(x) => new Future.delayed(new Duration(milliseconds: 50), () => x); |
| 64 | 64 |
| 65 // TODO(jmesserly): fix this when it's easier to get a private symbol. | 65 // TODO(jmesserly): fix this when it's easier to get a private symbol. |
| 66 final unboundSymbol = reflectClass(Polymer).declarations.keys | 66 final unboundSymbol = reflectClass(Polymer).declarations.keys |
| 67 .firstWhere((s) => MirrorSystem.getName(s) == '_unbound'); | 67 .firstWhere((s) => MirrorSystem.getName(s) == '_unbound'); |
| 68 | 68 |
| 69 _unbound(node) => reflect(node).getField(unboundSymbol).reflectee; | 69 _unbound(node) => reflect(node).getField(unboundSymbol).reflectee; |
| 70 | 70 |
| 71 unbindTests() { | 71 unbindTests() { |
| 72 var xTest = document.query('x-test'); | 72 var xTest = document.querySelector('x-test'); |
| 73 xTest.foo = 'bar'; | 73 xTest.foo = 'bar'; |
| 74 scheduleMicrotask(Observable.dirtyCheck); | 74 scheduleMicrotask(Observable.dirtyCheck); |
| 75 | 75 |
| 76 return delay(null).then((_) { | 76 return delay(null).then((_) { |
| 77 expect(_unbound(xTest), null, reason: | 77 expect(_unbound(xTest), null, reason: |
| 78 'element is bound when inserted'); | 78 'element is bound when inserted'); |
| 79 expect(xTest.fooWasChanged, true, reason: | 79 expect(xTest.fooWasChanged, true, reason: |
| 80 'element is actually bound'); | 80 'element is actually bound'); |
| 81 xTest.remove(); | 81 xTest.remove(); |
| 82 }).then(delay).then((_) { | 82 }).then(delay).then((_) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 }).then(delay).then((node) { | 106 }).then(delay).then((node) { |
| 107 expect(_unbound(node), null, reason: | 107 expect(_unbound(node), null, reason: |
| 108 'element is bound when manually inserted'); | 108 'element is bound when manually inserted'); |
| 109 node.remove(); | 109 node.remove(); |
| 110 return node; | 110 return node; |
| 111 }).then(delay).then((node) { | 111 }).then(delay).then((node) { |
| 112 expect(_unbound(node), true, reason: | 112 expect(_unbound(node), true, reason: |
| 113 'element is unbound when manually removed is called'); | 113 'element is unbound when manually removed is called'); |
| 114 }); | 114 }); |
| 115 } | 115 } |
| OLD | NEW |