| 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 '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
| 7 import '../../pkg/unittest/lib/html_individual_config.dart'; | 7 import '../../pkg/unittest/lib/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 } |
| 94 |
| 85 group('constructors', () { | 95 group('constructors', () { |
| 86 test('a', () { | 96 check('a', () => new AnchorElement() is AnchorElement); |
| 87 expect((new AnchorElement()) is AnchorElement, true); | 97 check('area', () => new AreaElement() is AreaElement); |
| 98 check('audio', () => new AudioElement() is AudioElement); |
| 99 check('body', () => new BodyElement() is BodyElement); |
| 100 check('br', () => new BRElement() is BRElement); |
| 101 check('base', () => new BaseElement() is BaseElement); |
| 102 check('button', () => new ButtonElement() is ButtonElement); |
| 103 check('canvas', () => new CanvasElement() is CanvasElement); |
| 104 check('caption', () => new TableCaptionElement() is TableCaptionElement); |
| 105 check('content', () => new ContentElement() is ContentElement, |
| 106 ContentElement.supported); |
| 107 check('details', () => new DetailsElement() is DetailsElement, |
| 108 DetailsElement.supported); |
| 109 check('datalist', () => new DataListElement() is DataListElement, |
| 110 DataListElement.supported); |
| 111 check('dl', () => new DListElement() is DListElement); |
| 112 check('div', () => new DivElement() is DivElement); |
| 113 check('embed', () => new EmbedElement() is EmbedElement, |
| 114 EmbedElement.supported); |
| 115 check('fieldset', () => new FieldSetElement() is FieldSetElement); |
| 116 check('form', () => new FormElement() is FormElement); |
| 117 check('head', () => new HeadElement() is HeadElement); |
| 118 check('hr', () => new HRElement() is HRElement); |
| 119 check('html', () => new HtmlElement() is HtmlElement); |
| 120 check('h1', () => new HeadingElement.h1() is HeadingElement); |
| 121 check('h2', () => new HeadingElement.h2() is HeadingElement); |
| 122 check('h3', () => new HeadingElement.h3() is HeadingElement); |
| 123 check('h4', () => new HeadingElement.h4() is HeadingElement); |
| 124 check('h5', () => new HeadingElement.h5() is HeadingElement); |
| 125 check('h6', () => new HeadingElement.h6() is HeadingElement); |
| 126 check('iframe', () => new IFrameElement() is IFrameElement); |
| 127 check('img', () => new ImageElement() is ImageElement); |
| 128 check('input', () => new InputElement() is InputElement); |
| 129 check('keygen', () => new KeygenElement() is KeygenElement, |
| 130 KeygenElement.supported); |
| 131 check('li', () => new LIElement() is LIElement); |
| 132 check('label', () => new LabelElement() is LabelElement); |
| 133 check('legen', () => new LegendElement() is LegendElement); |
| 134 check('link', () => new LinkElement() is LinkElement); |
| 135 check('map', () => new MapElement() is MapElement); |
| 136 check('menu', () => new MenuElement() is MenuElement); |
| 137 check('meta', () => new MetaElement() is MetaElement); |
| 138 check('meter', () => new MeterElement() is MeterElement, |
| 139 MeterElement.supported); |
| 140 check('del', () => new Element.tag('del') is ModElement); |
| 141 check('ins', () => new Element.tag('ins') is ModElement); |
| 142 check('object', () => new ObjectElement() is ObjectElement, |
| 143 ObjectElement.supported); |
| 144 check('ol', () => new OListElement() is OListElement); |
| 145 check('optgroup', () => new OptGroupElement() is OptGroupElement); |
| 146 check('option', () => new OptionElement() is OptionElement); |
| 147 check('output', () => new OutputElement() is OutputElement, |
| 148 OutputElement.supported); |
| 149 check('p', () => new ParagraphElement() is ParagraphElement); |
| 150 check('param', () => new ParamElement() is ParamElement); |
| 151 check('pre', () => new PreElement() is PreElement); |
| 152 check('progress', () => new ProgressElement() is ProgressElement, |
| 153 ProgressElement.supported); |
| 154 check('q', () => new QuoteElement() is QuoteElement); |
| 155 check('script', () => new ScriptElement() is ScriptElement); |
| 156 check('select', () => new SelectElement() is SelectElement); |
| 157 check('shadow', () => new ShadowElement() is ShadowElement, |
| 158 ShadowElement.supported); |
| 159 check('source', () => new SourceElement() is SourceElement); |
| 160 check('span', () => new SpanElement() is SpanElement); |
| 161 check('style', () => new StyleElement() is StyleElement); |
| 162 check('table', () => new TableElement() is TableElement); |
| 163 check('template', () => new TemplateElement() is TemplateElement, |
| 164 TemplateElement.supported); |
| 165 check('textarea', () => new TextAreaElement() is TextAreaElement); |
| 166 check('title', () => new TitleElement() is TitleElement); |
| 167 check('td', () => new TableCellElement() is TableCellElement); |
| 168 check('col', () => new TableColElement() is TableColElement); |
| 169 check('colgroup', () => new Element.tag('colgroup') is TableColElement); |
| 170 check('tr', () => new TableRowElement() is TableRowElement); |
| 171 check('tbody', () => new Element.tag('tbody') is TableSectionElement); |
| 172 check('tfoot', () => new Element.tag('tfoot') is TableSectionElement); |
| 173 check('thead', () => new Element.tag('thead') is TableSectionElement); |
| 174 check('track', () => new TrackElement() is TrackElement, |
| 175 TrackElement.supported); |
| 176 group('ul', () { |
| 177 check('ul', () => new UListElement() is UListElement); |
| 178 |
| 179 test('accepts li', () { |
| 180 var ul = new UListElement(); |
| 181 var li = new LIElement(); |
| 182 ul.append(li); |
| 183 }); |
| 88 }); | 184 }); |
| 89 test('area', () { | 185 check('video', () => new VideoElement() is VideoElement); |
| 90 expect((new AreaElement()) is AreaElement, true); | 186 check('unknown', () => new Element.tag('someunknown') is UnknownElement); |
| 91 }); | |
| 92 test('audio', () { | |
| 93 expect((new AudioElement()) is AudioElement, true); | |
| 94 }); | |
| 95 test('body', () { | |
| 96 expect((new BodyElement()) is BodyElement, true); | |
| 97 }); | |
| 98 test('br', () { | |
| 99 expect((new BRElement()) is BRElement, true); | |
| 100 }); | |
| 101 test('base', () { | |
| 102 expect((new BaseElement()) is BaseElement, true); | |
| 103 }); | |
| 104 test('button', () { | |
| 105 expect((new ButtonElement()) is ButtonElement, true); | |
| 106 }); | |
| 107 test('canvas', () { | |
| 108 expect((new CanvasElement()) is CanvasElement, true); | |
| 109 }); | |
| 110 test('caption', () { | |
| 111 expect((new TableCaptionElement()) is TableCaptionElement, true); | |
| 112 }); | |
| 113 test('content', () { | |
| 114 expect((new ContentElement()) is ContentElement, | |
| 115 ContentElement.supported); | |
| 116 }); | |
| 117 test('details', () { | |
| 118 expect((new DetailsElement()) is DetailsElement, | |
| 119 DetailsElement.supported); | |
| 120 }); | |
| 121 test('dl', () { | |
| 122 expect((new DListElement()) is DListElement, true); | |
| 123 }); | |
| 124 test('datalist', () { | |
| 125 expect((new DataListElement()) is DataListElement, | |
| 126 DataListElement.supported); | |
| 127 }); | |
| 128 test('div', () { | |
| 129 expect((new DivElement()) is DivElement, true); | |
| 130 }); | |
| 131 test('embed', () { | |
| 132 expect((new EmbedElement()) is EmbedElement, EmbedElement.supported); | |
| 133 }); | |
| 134 test('fieldset', () { | |
| 135 expect((new FieldSetElement()) is FieldSetElement, true); | |
| 136 }); | |
| 137 test('form', () { | |
| 138 expect((new FormElement()) is FormElement, true); | |
| 139 }); | |
| 140 test('head', () { | |
| 141 expect((new HeadElement()) is HeadElement, true); | |
| 142 }); | |
| 143 test('hr', () { | |
| 144 expect((new HRElement()) is HRElement, true); | |
| 145 }); | |
| 146 test('html', () { | |
| 147 expect((new HtmlElement()) is HtmlElement, true); | |
| 148 }); | |
| 149 test('h1', () { | |
| 150 expect((new HeadingElement.h1()) is HeadingElement, true); | |
| 151 expect(new Element.tag('h1') is HeadingElement, true); | |
| 152 }); | |
| 153 test('h2', () { | |
| 154 expect((new HeadingElement.h2()) is HeadingElement, true); | |
| 155 expect(new Element.tag('h2') is HeadingElement, true); | |
| 156 }); | |
| 157 test('h3', () { | |
| 158 expect((new HeadingElement.h3()) is HeadingElement, true); | |
| 159 expect(new Element.tag('h3') is HeadingElement, true); | |
| 160 }); | |
| 161 test('h4', () { | |
| 162 expect((new HeadingElement.h4()) is HeadingElement, true); | |
| 163 expect(new Element.tag('h4') is HeadingElement, true); | |
| 164 }); | |
| 165 test('h5', () { | |
| 166 expect((new HeadingElement.h5()) is HeadingElement, true); | |
| 167 expect(new Element.tag('h5') is HeadingElement, true); | |
| 168 }); | |
| 169 test('h6', () { | |
| 170 expect((new HeadingElement.h6()) is HeadingElement, true); | |
| 171 expect(new Element.tag('h6') is HeadingElement, true); | |
| 172 }); | |
| 173 test('iframe', () { | |
| 174 expect((new IFrameElement()) is IFrameElement, true); | |
| 175 }); | |
| 176 test('img', () { | |
| 177 expect((new ImageElement()) is ImageElement, true); | |
| 178 }); | |
| 179 test('input', () { | |
| 180 expect((new InputElement()) is InputElement, true); | |
| 181 }); | |
| 182 test('keygen', () { | |
| 183 expect((new KeygenElement()) is KeygenElement, KeygenElement.supported); | |
| 184 }); | |
| 185 test('li', () { | |
| 186 expect((new LIElement()) is LIElement, true); | |
| 187 }); | |
| 188 test('label', () { | |
| 189 expect((new LabelElement()) is LabelElement, true); | |
| 190 }); | |
| 191 test('legend', () { | |
| 192 expect((new LegendElement()) is LegendElement, true); | |
| 193 }); | |
| 194 test('link', () { | |
| 195 expect((new LinkElement()) is LinkElement, true); | |
| 196 }); | |
| 197 test('map', () { | |
| 198 expect((new MapElement()) is MapElement, true); | |
| 199 }); | |
| 200 test('menu', () { | |
| 201 expect((new MenuElement()) is MenuElement, true); | |
| 202 }); | |
| 203 test('meta', () { | |
| 204 expect((new Element.tag('meta')) is MetaElement, true); | |
| 205 }); | |
| 206 test('meter', () { | |
| 207 expect((new Element.tag('meter')) is MeterElement, MeterElement.supported)
; | |
| 208 }); | |
| 209 test('del', () { | |
| 210 expect((new Element.tag('del')) is ModElement, true); | |
| 211 }); | |
| 212 test('ins', () { | |
| 213 expect((new Element.tag('ins')) is ModElement, true); | |
| 214 }); | |
| 215 test('object', () { | |
| 216 expect((new ObjectElement()) is ObjectElement, ObjectElement.supported); | |
| 217 }); | |
| 218 test('ol', () { | |
| 219 expect((new OListElement()) is OListElement, true); | |
| 220 }); | |
| 221 test('optgroup', () { | |
| 222 expect((new OptGroupElement()) is OptGroupElement, true); | |
| 223 }); | |
| 224 test('option', () { | |
| 225 expect((new OptionElement()) is OptionElement, true); | |
| 226 }); | |
| 227 test('output', () { | |
| 228 expect((new OutputElement()) is OutputElement, OutputElement.supported); | |
| 229 }); | |
| 230 test('p', () { | |
| 231 expect((new ParagraphElement()) is ParagraphElement, true); | |
| 232 }); | |
| 233 test('param', () { | |
| 234 expect((new ParamElement()) is ParamElement, true); | |
| 235 }); | |
| 236 test('pre', () { | |
| 237 expect((new PreElement()) is PreElement, true); | |
| 238 }); | |
| 239 test('progress', () { | |
| 240 expect((new ProgressElement()) is ProgressElement, | |
| 241 ProgressElement.supported); | |
| 242 }); | |
| 243 test('q', () { | |
| 244 expect((new Element.tag('q')) is QuoteElement, true); | |
| 245 }); | |
| 246 test('script', () { | |
| 247 expect((new ScriptElement()) is ScriptElement, true); | |
| 248 }); | |
| 249 test('select', () { | |
| 250 expect((new SelectElement()) is SelectElement, true); | |
| 251 }); | |
| 252 test('shadow', () { | |
| 253 expect((new Element.tag('shadow')) is ShadowElement, | |
| 254 ShadowElement.supported); | |
| 255 }); | |
| 256 test('source', () { | |
| 257 expect((new SourceElement()) is SourceElement, true); | |
| 258 }); | |
| 259 test('span', () { | |
| 260 expect((new SpanElement()) is SpanElement, true); | |
| 261 }); | |
| 262 test('style', () { | |
| 263 expect((new StyleElement()) is StyleElement, true); | |
| 264 }); | |
| 265 test('table', () { | |
| 266 expect((new TableElement()) is TableElement, true); | |
| 267 }); | |
| 268 test('template', () { | |
| 269 expect((new TemplateElement()) is TemplateElement, | |
| 270 TemplateElement.supported); | |
| 271 }); | |
| 272 test('textarea', () { | |
| 273 expect((new TextAreaElement()) is TextAreaElement, true); | |
| 274 }); | |
| 275 test('title', () { | |
| 276 expect((new TitleElement()) is TitleElement, true); | |
| 277 }); | |
| 278 test('td', () { | |
| 279 expect((new TableCellElement()) is TableCellElement, true); | |
| 280 }); | |
| 281 test('col', () { | |
| 282 expect((new TableColElement()) is TableColElement, true); | |
| 283 expect((new Element.tag('colgroup')) is TableColElement, true); | |
| 284 }); | |
| 285 test('tr', () { | |
| 286 expect((new TableRowElement()) is TableRowElement, true); | |
| 287 }); | |
| 288 test('table section', () { | |
| 289 expect((new Element.tag('tbody')) is TableSectionElement, true); | |
| 290 expect((new Element.tag('tfoot')) is TableSectionElement, true); | |
| 291 expect((new Element.tag('thead')) is TableSectionElement, true); | |
| 292 }); | |
| 293 test('track', () { | |
| 294 expect((new Element.tag('track')) is TrackElement, | |
| 295 TrackElement.supported); | |
| 296 }); | |
| 297 test('ul', () { | |
| 298 expect((new UListElement()) is UListElement, true); | |
| 299 var ul = new UListElement(); | |
| 300 var li = new LIElement(); | |
| 301 ul.append(li); | |
| 302 }); | |
| 303 test('video', () { | |
| 304 expect((new VideoElement()) is VideoElement, true); | |
| 305 }); | |
| 306 test('unknown', () { | |
| 307 expect((new Element.tag('someunknown')) is UnknownElement, true); | |
| 308 });; | |
| 309 }); | 187 }); |
| 310 } | 188 } |
| OLD | NEW |