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

Side by Side Diff: packages/polymer/test/bind_mdv_test.dart

Issue 2312183003: Removed Polymer from Observatory deps (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « packages/polymer/test/auto_binding_test.html ('k') | packages/polymer/test/bind_mdv_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library polymer.test.bind_mdv_test;
6
7 import 'dart:async';
8 import 'dart:html';
9 import 'package:template_binding/template_binding.dart';
10 import 'package:observe/observe.dart';
11 import 'package:observe/mirrors_used.dart'; // make test smaller.
12 import 'package:unittest/html_config.dart';
13 import 'package:unittest/unittest.dart';
14 import 'package:web_components/polyfill.dart';
15
16 main() {
17 useHtmlConfiguration();
18
19 var registered = customElementsReady.then((_) {
20 document.registerElement('my-div', MyDivElement);
21 });
22
23 setUp(() => registered);
24
25 group('bindModel', bindModelTests);
26 }
27
28 bindModelTests() {
29 var div;
30
31 setUp(() {
32 div = new MyDivElement();
33 document.body.append(div);
34 });
35
36 tearDown(() {
37 div.remove();
38 });
39
40 parseAndBindHTML(html, model) => templateBind(new Element.tag('template')
41 ..setInnerHtml(html, treeSanitizer: const NullTreeSanitizer()))
42 .createInstance(model);
43
44 test('bindModel', () {
45 var fragment = parseAndBindHTML('<div id="a" foo="{{bar}}"></div>', div);
46 div.append(fragment);
47 var a = div.query('#a');
48
49 div.bar = 5;
50 return onAttributeChange(a).then((_) {
51 expect(a.attributes['foo'], '5');
52 div.bar = 8;
53 return onAttributeChange(a).then((_) {
54 expect(a.attributes['foo'], '8');
55 });
56 });
57 });
58
59 test('bind input', () {
60 var fragment = parseAndBindHTML('<input value="{{bar}}" />', div);
61 div.append(fragment);
62 var a = div.query('input');
63
64 div.bar = 'hello';
65 // TODO(sorvell): fix this when observe-js lets us explicitly listen for
66 // a change on input.value
67 Observable.dirtyCheck();
68 return new Future.microtask(() {
69 expect(a.value, 'hello');
70 });
71 });
72 }
73
74 class MyDivElement extends HtmlElement with Observable {
75 factory MyDivElement() => new Element.tag('my-div');
76 MyDivElement.created() : super.created();
77 @observable var bar;
78 }
79
80 class NullTreeSanitizer implements NodeTreeSanitizer {
81 const NullTreeSanitizer();
82 void sanitizeTree(Node node) {}
83 }
84
85 Future onAttributeChange(Element node) {
86 var completer = new Completer();
87 new MutationObserver((records, observer) {
88 observer.disconnect();
89 completer.complete();
90 })..observe(node, attributes: true);
91 scheduleMicrotask(Observable.dirtyCheck);
92 return completer.future;
93 }
OLDNEW
« no previous file with comments | « packages/polymer/test/auto_binding_test.html ('k') | packages/polymer/test/bind_mdv_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698