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

Side by Side Diff: pkg/mdv/test/node_bindings_test.dart

Issue 19593006: [mdv] Implement two-way binding to HTMLTextArea.value (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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 node_bindings_test; 5 library node_bindings_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:mdv/mdv.dart' as mdv; 9 import 'package:mdv/mdv.dart' as mdv;
10 import 'package:observe/observe.dart'; 10 import 'package:observe/observe.dart';
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 expect(element.attributes, isNot(contains('hidden'))); 77 expect(element.attributes, isNot(contains('hidden')));
78 78
79 model[sym('a')] = 'foo'; 79 model[sym('a')] = 'foo';
80 model[sym('b')] = 'x'; 80 model[sym('b')] = 'x';
81 performMicrotaskCheckpoint(); 81 performMicrotaskCheckpoint();
82 expect(element.attributes, contains('hidden')); 82 expect(element.attributes, contains('hidden'));
83 expect(element.attributes['hidden'], ''); 83 expect(element.attributes['hidden'], '');
84 expect(element.id, 'x'); 84 expect(element.id, 'x');
85 }); 85 });
86 86
87 observeTest('Text Input', () { 87 inputTextAreaValueTest(String tagName) {
88 var input = new InputElement(); 88 var el = new Element.tag(tagName);
89 testDiv.nodes.add(el);
89 var model = toSymbolMap({'x': 42}); 90 var model = toSymbolMap({'x': 42});
90 input.bind('value', model, 'x'); 91 el.bind('value', model, 'x');
91 expect(input.value, '42'); 92 expect(el.value, '42');
92 93
93 model[sym('x')] = 'Hi'; 94 model[sym('x')] = 'Hi';
94 expect(input.value, '42', reason: 'changes delivered async'); 95 expect(el.value, '42', reason: 'changes delivered async');
95 performMicrotaskCheckpoint(); 96 performMicrotaskCheckpoint();
96 expect(input.value, 'Hi'); 97 expect(el.value, 'Hi');
97 98
98 input.value = 'changed'; 99 el.value = 'changed';
99 dispatchEvent('input', input); 100 dispatchEvent('input', el);
100 expect(model[sym('x')], 'changed'); 101 expect(model[sym('x')], 'changed');
101 102
102 input.unbind('value'); 103 el.unbind('value');
103 104
104 input.value = 'changed again'; 105 el.value = 'changed again';
105 dispatchEvent('input', input); 106 dispatchEvent('input', el);
106 expect(model[sym('x')], 'changed'); 107 expect(model[sym('x')], 'changed');
107 108
108 input.bind('value', model, 'x'); 109 el.bind('value', model, 'x');
109 model[sym('x')] = null; 110 model[sym('x')] = null;
110 performMicrotaskCheckpoint(); 111 performMicrotaskCheckpoint();
111 expect(input.value, ''); 112 expect(el.value, '');
112 }); 113 }
114
115 observeTest('Input.value', () => inputTextAreaValueTest('input'));
116 observeTest('TextArea.value', () => inputTextAreaValueTest('textarea'));
113 117
114 observeTest('Radio Input', () { 118 observeTest('Radio Input', () {
115 var input = new InputElement(); 119 var input = new InputElement();
116 input.type = 'radio'; 120 input.type = 'radio';
117 var model = toSymbolMap({'x': true}); 121 var model = toSymbolMap({'x': true});
118 input.bind('checked', model, 'x'); 122 input.bind('checked', model, 'x');
119 expect(input.checked, true); 123 expect(input.checked, true);
120 124
121 model[sym('x')] = false; 125 model[sym('x')] = false;
122 expect(input.checked, true); 126 expect(input.checked, true);
(...skipping 26 matching lines...) Expand all
149 expect(input.checked, false); 153 expect(input.checked, false);
150 154
151 input.click(); 155 input.click();
152 expect(model[sym('x')], true); 156 expect(model[sym('x')], true);
153 performMicrotaskCheckpoint(); 157 performMicrotaskCheckpoint();
154 158
155 input.click(); 159 input.click();
156 expect(model[sym('x')], false); 160 expect(model[sym('x')], false);
157 }); 161 });
158 } 162 }
OLDNEW
« pkg/mdv/lib/src/input_bindings.dart ('K') | « pkg/mdv/lib/src/text_area_element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698