OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 element_types; | 5 library element_types; |
6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
7 import 'package:unittest/html_individual_config.dart'; | 7 import 'package:unittest/html_individual_config.dart'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 expect(TemplateElement.supported, true); | 75 expect(TemplateElement.supported, true); |
76 }); | 76 }); |
77 }); | 77 }); |
78 | 78 |
79 group('supported_track', () { | 79 group('supported_track', () { |
80 test('supported', () { | 80 test('supported', () { |
81 expect(TrackElement.supported, true); | 81 expect(TrackElement.supported, true); |
82 }); | 82 }); |
83 }); | 83 }); |
84 | 84 |
| 85 check(String name, bool fn(), [bool supported = true]) { |
| 86 test(name, () { |
| 87 var expectation = supported ? returnsNormally : throws; |
| 88 expect(() { |
| 89 expect(fn(), isTrue); |
| 90 }, expectation); |
| 91 }); |
| 92 |
| 93 } |
85 | 94 |
86 group('constructors', () { | 95 group('constructors', () { |
87 check(String name, bool fn(), [bool supported = true]) { | |
88 test(name, () { | |
89 var expectation = supported ? returnsNormally : throws; | |
90 expect(() { | |
91 expect(fn(), isTrue); | |
92 }, expectation); | |
93 }); | |
94 } | |
95 | |
96 check('a', () => new AnchorElement() is AnchorElement); | 96 check('a', () => new AnchorElement() is AnchorElement); |
97 check('area', () => new AreaElement() is AreaElement); | 97 check('area', () => new AreaElement() is AreaElement); |
98 check('audio', () => new AudioElement() is AudioElement); | 98 check('audio', () => new AudioElement() is AudioElement); |
99 check('body', () => new BodyElement() is BodyElement); | 99 check('body', () => new BodyElement() is BodyElement); |
100 check('br', () => new BRElement() is BRElement); | 100 check('br', () => new BRElement() is BRElement); |
101 check('base', () => new BaseElement() is BaseElement); | 101 check('base', () => new BaseElement() is BaseElement); |
102 check('button', () => new ButtonElement() is ButtonElement); | 102 check('button', () => new ButtonElement() is ButtonElement); |
103 check('canvas', () => new CanvasElement() is CanvasElement); | 103 check('canvas', () => new CanvasElement() is CanvasElement); |
104 check('caption', () => new TableCaptionElement() is TableCaptionElement); | 104 check('caption', () => new TableCaptionElement() is TableCaptionElement); |
105 check('content', () => new ContentElement() is ContentElement, | 105 check('content', () => new ContentElement() is ContentElement, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 test('accepts li', () { | 179 test('accepts li', () { |
180 var ul = new UListElement(); | 180 var ul = new UListElement(); |
181 var li = new LIElement(); | 181 var li = new LIElement(); |
182 ul.append(li); | 182 ul.append(li); |
183 }); | 183 }); |
184 }); | 184 }); |
185 check('video', () => new VideoElement() is VideoElement); | 185 check('video', () => new VideoElement() is VideoElement); |
186 check('unknown', () => new Element.tag('someunknown') is UnknownElement); | 186 check('unknown', () => new Element.tag('someunknown') is UnknownElement); |
187 }); | 187 }); |
188 | |
189 group('constructors_dynamic', () { | |
190 check(String name, create(), bool typeTest(e), [bool supported = true]) { | |
191 test(name, () { | |
192 var expectation = supported ? returnsNormally : throws; | |
193 expect(() { | |
194 expect(typeTest(create()), isTrue); | |
195 }, expectation); | |
196 }); | |
197 } | |
198 | |
199 check('a', () => new AnchorElement(), (e) => e is AnchorElement); | |
200 check('area', () => new AreaElement(), (e) => e is AreaElement); | |
201 check('audio', () => new AudioElement(), (e) => e is AudioElement); | |
202 check('body', () => new BodyElement(), (e) => e is BodyElement); | |
203 check('br', () => new BRElement(), (e) => e is BRElement); | |
204 check('base', () => new BaseElement(), (e) => e is BaseElement); | |
205 check('button', () => new ButtonElement(), (e) => e is ButtonElement); | |
206 check('canvas', () => new CanvasElement(), (e) => e is CanvasElement); | |
207 check('caption', () => new TableCaptionElement(), | |
208 (e) => e is TableCaptionElement); | |
209 check('content', () => new ContentElement(), (e) => e is ContentElement, | |
210 ContentElement.supported); | |
211 check('details', () => new DetailsElement(), (e) => e is DetailsElement, | |
212 DetailsElement.supported); | |
213 check('datalist', () => new DataListElement(), (e) => e is DataListElement, | |
214 DataListElement.supported); | |
215 check('dl', () => new DListElement(), (e) => e is DListElement); | |
216 check('div', () => new DivElement(), (e) => e is DivElement); | |
217 check('embed', () => new EmbedElement(), (e) => e is EmbedElement, | |
218 EmbedElement.supported); | |
219 check('fieldset', () => new FieldSetElement(), (e) => e is FieldSetElement); | |
220 check('form', () => new FormElement(), (e) => e is FormElement); | |
221 check('head', () => new HeadElement(), (e) => e is HeadElement); | |
222 check('hr', () => new HRElement(), (e) => e is HRElement); | |
223 check('html', () => new HtmlHtmlElement(), (e) => e is HtmlHtmlElement); | |
224 check('h1', () => new HeadingElement.h1(), (e) => e is HeadingElement); | |
225 check('h2', () => new HeadingElement.h2(), (e) => e is HeadingElement); | |
226 check('h3', () => new HeadingElement.h3(), (e) => e is HeadingElement); | |
227 check('h4', () => new HeadingElement.h4(), (e) => e is HeadingElement); | |
228 check('h5', () => new HeadingElement.h5(), (e) => e is HeadingElement); | |
229 check('h6', () => new HeadingElement.h6(), (e) => e is HeadingElement); | |
230 check('iframe', () => new IFrameElement(), (e) => e is IFrameElement); | |
231 check('img', () => new ImageElement(), (e) => e is ImageElement); | |
232 check('input', () => new InputElement(), (e) => e is InputElement); | |
233 check('keygen', () => new KeygenElement(), (e) => e is KeygenElement, | |
234 KeygenElement.supported); | |
235 check('li', () => new LIElement(), (e) => e is LIElement); | |
236 check('label', () => new LabelElement(), (e) => e is LabelElement); | |
237 check('legen', () => new LegendElement(), (e) => e is LegendElement); | |
238 check('link', () => new LinkElement(), (e) => e is LinkElement); | |
239 check('map', () => new MapElement(), (e) => e is MapElement); | |
240 check('menu', () => new MenuElement(), (e) => e is MenuElement); | |
241 check('meta', () => new MetaElement(), (e) => e is MetaElement); | |
242 check('meter', () => new MeterElement(), (e) => e is MeterElement, | |
243 MeterElement.supported); | |
244 check('del', () => new Element.tag('del'), (e) => e is ModElement); | |
245 check('ins', () => new Element.tag('ins'), (e) => e is ModElement); | |
246 check('object', () => new ObjectElement(), (e) => e is ObjectElement, | |
247 ObjectElement.supported); | |
248 check('ol', () => new OListElement(), (e) => e is OListElement); | |
249 check('optgroup', () => new OptGroupElement(), (e) => e is OptGroupElement); | |
250 check('option', () => new OptionElement(), (e) => e is OptionElement); | |
251 check('output', () => new OutputElement(), (e) => e is OutputElement, | |
252 OutputElement.supported); | |
253 check('p', () => new ParagraphElement(), (e) => e is ParagraphElement); | |
254 check('param', () => new ParamElement(), (e) => e is ParamElement); | |
255 check('pre', () => new PreElement(), (e) => e is PreElement); | |
256 check('progress', () => new ProgressElement(), (e) => e is ProgressElement, | |
257 ProgressElement.supported); | |
258 check('q', () => new QuoteElement(), (e) => e is QuoteElement); | |
259 check('script', () => new ScriptElement(), (e) => e is ScriptElement); | |
260 check('select', () => new SelectElement(), (e) => e is SelectElement); | |
261 check('shadow', () => new ShadowElement(), (e) => e is ShadowElement, | |
262 ShadowElement.supported); | |
263 check('source', () => new SourceElement(), (e) => e is SourceElement); | |
264 check('span', () => new SpanElement(), (e) => e is SpanElement); | |
265 check('style', () => new StyleElement(), (e) => e is StyleElement); | |
266 check('table', () => new TableElement(), (e) => e is TableElement); | |
267 check('template', () => new TemplateElement(), (e) => e is TemplateElement, | |
268 TemplateElement.supported); | |
269 check('textarea', () => new TextAreaElement(), (e) => e is TextAreaElement); | |
270 check('title', () => new TitleElement(), (e) => e is TitleElement); | |
271 check('td', () => new TableCellElement(), (e) => e is TableCellElement); | |
272 check('col', () => new TableColElement(), (e) => e is TableColElement); | |
273 check('colgroup', () => new Element.tag('colgroup'), | |
274 (e) => e is TableColElement); | |
275 check('tr', () => new TableRowElement(), (e) => e is TableRowElement); | |
276 check('tbody', () => new Element.tag('tbody'), | |
277 (e) => e is TableSectionElement); | |
278 check('tfoot', () => new Element.tag('tfoot'), | |
279 (e) => e is TableSectionElement); | |
280 check('thead', () => new Element.tag('thead'), | |
281 (e) => e is TableSectionElement); | |
282 check('track', () => new TrackElement(), (e) => e is TrackElement, | |
283 TrackElement.supported); | |
284 group('ul', () { | |
285 check('ul', () => new UListElement(), (e) => e is UListElement); | |
286 | |
287 test('accepts li', () { | |
288 var ul = new UListElement(); | |
289 var li = new LIElement(); | |
290 ul.append(li); | |
291 }); | |
292 }); | |
293 check('video', () => new VideoElement(), (e) => e is VideoElement); | |
294 check('unknown', () => new Element.tag('someunknown'), | |
295 (e) => e is UnknownElement); | |
296 }); | |
297 } | 188 } |
OLD | NEW |