Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 ElementTest; | 5 library ElementTest; |
| 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 import 'dart:svg' as svg; | 9 import 'dart:svg' as svg; |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 final event = new Event(type); | 38 final event = new Event(type); |
| 39 listenerList.dispatch(event); | 39 listenerList.dispatch(event); |
| 40 } | 40 } |
| 41 | 41 |
| 42 expect(firedWhenAddedToListenerList, isTrue); | 42 expect(firedWhenAddedToListenerList, isTrue); |
| 43 if (registerOnEventListener != null) { | 43 if (registerOnEventListener != null) { |
| 44 expect(firedOnEvent, isTrue); | 44 expect(firedOnEvent, isTrue); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 void testConstructorHelper(String tag, String htmlSnippet, | 48 void testConstructorHelper(String tag, String htmlSnippet, |
|
Emily Fortuna
2012/12/27 23:06:49
this function is no longer called in this test. Re
blois
2012/12/28 00:43:27
Done.
| |
| 49 String expectedText, Function isExpectedClass) { | 49 String expectedText, Function isExpectedClass) { |
| 50 expect(isExpectedClass(new Element.tag(tag)), isTrue); | 50 expect(isExpectedClass(new Element.tag(tag)), isTrue); |
| 51 final elementFromSnippet = new Element.html(htmlSnippet); | 51 final elementFromSnippet = new Element.html(htmlSnippet); |
| 52 expect(isExpectedClass(elementFromSnippet), isTrue); | 52 expect(isExpectedClass(elementFromSnippet), isTrue); |
| 53 expect(elementFromSnippet.text, expectedText); | 53 expect(elementFromSnippet.text, expectedText); |
| 54 } | 54 } |
| 55 | 55 |
| 56 main() { | 56 main() { |
| 57 useHtmlIndividualConfiguration(); | 57 useHtmlIndividualConfiguration(); |
| 58 | 58 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 expect(element.clientHeight, greaterThan(100)); | 97 expect(element.clientHeight, greaterThan(100)); |
| 98 expect(element.offsetWidth, greaterThan(100)); | 98 expect(element.offsetWidth, greaterThan(100)); |
| 99 expect(element.offsetHeight, greaterThan(100)); | 99 expect(element.offsetHeight, greaterThan(100)); |
| 100 expect(element.scrollWidth, greaterThan(100)); | 100 expect(element.scrollWidth, greaterThan(100)); |
| 101 expect(element.scrollHeight, greaterThan(100)); | 101 expect(element.scrollHeight, greaterThan(100)); |
| 102 expect(element.getBoundingClientRect().left, 8); | 102 expect(element.getBoundingClientRect().left, 8); |
| 103 expect(element.getBoundingClientRect().top, 8); | 103 expect(element.getBoundingClientRect().top, 8); |
| 104 container.remove(); | 104 container.remove(); |
| 105 }); | 105 }); |
| 106 | 106 |
| 107 group('additionalConstructors', () { | |
| 108 test('blockquote', () => testConstructorHelper('blockquote', | |
| 109 '<blockquote>foo</blockquote>', 'foo', | |
| 110 (element) => element is QuoteElement)); | |
| 111 test('body', () => testConstructorHelper('body', | |
| 112 '<body><div>foo</div></body>', 'foo', | |
| 113 (element) => element is BodyElement)); | |
| 114 test('head', () => testConstructorHelper('head', | |
| 115 '<head><script>foo;</script></head>', 'foo;', | |
| 116 (element) => element is HeadElement)); | |
| 117 test('optgroup', () => testConstructorHelper('optgroup', | |
| 118 '<optgroup>foo</optgroup>', 'foo', | |
| 119 (element) => element is OptGroupElement)); | |
| 120 test('option', () => testConstructorHelper('option', | |
| 121 '<option>foo</option>', 'foo', | |
| 122 (element) => element is OptionElement)); | |
| 123 test('output', () => testConstructorHelper('output', | |
| 124 '<output>foo</output>', 'foo', | |
| 125 (element) => element is OutputElement)); | |
| 126 test('progress', () => testConstructorHelper('progress', | |
| 127 '<progress>foo</progress>', 'foo', | |
| 128 (element) => element is ProgressElement)); | |
| 129 test('caption', () => testConstructorHelper('caption', | |
| 130 '<caption>foo</caption>', 'foo', | |
| 131 (element) => element is TableCaptionElement)); | |
| 132 test('td', () => testConstructorHelper('td', '<td>foo</td>', 'foo', | |
| 133 (element) => element is TableCellElement)); | |
| 134 test('colgroup', () => testConstructorHelper('colgroup', | |
| 135 '<colgroup></colgroup>', '', | |
| 136 (element) => element is TableColElement)); | |
| 137 test('col', () => testConstructorHelper('col', '<col></col>', '', | |
| 138 (element) => element is TableColElement)); | |
| 139 test('tr', () => testConstructorHelper('tr', | |
| 140 '<tr><td>foo</td></tr>', 'foo', | |
| 141 (element) => element is TableRowElement)); | |
| 142 test('tbody', () => testConstructorHelper('tbody', | |
| 143 '<tbody><tr><td>foo</td></tr></tbody>', 'foo', | |
| 144 (element) => element is TableSectionElement)); | |
| 145 test('tfoot', () => testConstructorHelper('tfoot', | |
| 146 '<tfoot><tr><td>foo</td></tr></tfoot>', 'foo', | |
| 147 (element) => element is TableSectionElement)); | |
| 148 test('thead', () => testConstructorHelper('thead', | |
| 149 '<thead><tr><td>foo</td></tr></thead>', 'foo', | |
| 150 (element) => element is TableSectionElement)); | |
| 151 }); | |
| 152 | |
| 153 group('constructors', () { | 107 group('constructors', () { |
| 154 test('error', () { | 108 test('error', () { |
| 155 expect(() => new Element.html('<br/><br/>'), throwsArgumentError); | 109 expect(() => new Element.html('<br/><br/>'), throwsArgumentError); |
| 156 }); | 110 }); |
| 157 | 111 |
| 158 test('.html has no parent', () => | 112 test('.html has no parent', () => |
| 159 expect(new Element.html('<br/>').parent, isNull)); | 113 expect(new Element.html('<br/>').parent, isNull)); |
| 160 | |
| 161 test('a', () => testConstructorHelper('a', '<a>foo</a>', 'foo', | |
| 162 (element) => element is AnchorElement)); | |
| 163 test('area', () => testConstructorHelper('area', '<area>foo</area>', '', | |
| 164 (element) => element is AreaElement)); | |
| 165 // TODO(jacobr): audio tags cause tests to segfault when using dartium. | |
| 166 // b/5522106. | |
| 167 // test('audio', () => testConstructorHelper('audio', | |
| 168 // '<audio>foo</audio>', 'foo', | |
| 169 // (element) => element is AudioElement)); | |
| 170 test('br', () => testConstructorHelper('br', '<br>', '', | |
| 171 (element) => element is BRElement)); | |
| 172 test('base', () => testConstructorHelper('base', '<base>foo</base>', '', | |
| 173 (element) => element is BaseElement)); | |
| 174 test('button', () => testConstructorHelper('button', | |
| 175 '<button>foo</button>', 'foo', | |
| 176 (element) => element is ButtonElement)); | |
| 177 test('canvas', () => testConstructorHelper('canvas', | |
| 178 '<canvas>foo</canvas>', 'foo', | |
| 179 (element) => element is CanvasElement)); | |
| 180 test('dl', () => testConstructorHelper('dl', '<dl>foo</dl>', 'foo', | |
| 181 (element) => element is DListElement)); | |
| 182 // TODO(jacobr): WebKit doesn't yet support the DataList class. | |
| 183 // test('datalist', () => testConstructorHelper('datalist', | |
| 184 // '<datalist>foo</datalist>', 'foo', | |
| 185 // (element) => element is DataListElement)); | |
| 186 test('div', () => testConstructorHelper('div', '<div>foo</div>', 'foo', | |
| 187 (element) => element is DivElement)); | |
| 188 test('fieldset', () => testConstructorHelper('fieldset', | |
| 189 '<fieldset>foo</fieldset>', 'foo', | |
| 190 (element) => element is FieldSetElement)); | |
| 191 test('font', () => testConstructorHelper('font', '<font>foo</font>', 'foo', | |
| 192 (element) => element is FontElement)); | |
| 193 test('form', () => testConstructorHelper('form', '<form>foo</form>', 'foo', | |
| 194 (element) => element is FormElement)); | |
| 195 test('hr', () => testConstructorHelper('hr', '<hr>', '', | |
| 196 (element) => element is HRElement)); | |
| 197 test('h1', () => testConstructorHelper('h1', '<h1>foo</h1>', 'foo', | |
| 198 (element) => element is HeadingElement)); | |
| 199 test('h2', () => testConstructorHelper('h2', '<h2>foo</h2>', 'foo', | |
| 200 (element) => element is HeadingElement)); | |
| 201 test('h3', () => testConstructorHelper('h3', '<h3>foo</h3>', 'foo', | |
| 202 (element) => element is HeadingElement)); | |
| 203 test('h4', () => testConstructorHelper('h4', '<h4>foo</h4>', 'foo', | |
| 204 (element) => element is HeadingElement)); | |
| 205 test('h5', () => testConstructorHelper('h5', '<h5>foo</h5>', 'foo', | |
| 206 (element) => element is HeadingElement)); | |
| 207 test('h6', () => testConstructorHelper('h6', '<h6>foo</h6>', 'foo', | |
| 208 (element) => element is HeadingElement)); | |
| 209 test('iframe', () => testConstructorHelper('iframe', | |
| 210 '<iframe>foo</iframe>', 'foo', | |
| 211 (element) => element is IFrameElement)); | |
| 212 test('img', () => testConstructorHelper('img', '<img>', '', | |
| 213 (element) => element is ImageElement)); | |
| 214 test('input', () => testConstructorHelper('input', '<input/>', '', | |
| 215 (element) => element is InputElement)); | |
| 216 test('li', () => testConstructorHelper('li', '<li>foo</li>', 'foo', | |
| 217 (element) => element is LIElement)); | |
| 218 test('label', () => testConstructorHelper('label', | |
| 219 '<label>foo</label>', 'foo', | |
| 220 (element) => element is LabelElement)); | |
| 221 test('legend', () => testConstructorHelper('legend', | |
| 222 '<legend>foo</legend>', 'foo', | |
| 223 (element) => element is LegendElement)); | |
| 224 test('link', () => testConstructorHelper('link', '<link>', '', | |
| 225 (element) => element is LinkElement)); | |
| 226 test('map', () => testConstructorHelper('map', '<map>foo</map>', 'foo', | |
| 227 (element) => element is MapElement)); | |
| 228 test('menu', () => testConstructorHelper('menu', '<menu>foo</menu>', 'foo', | |
| 229 (element) => element is MenuElement)); | |
| 230 test('meta', () => testConstructorHelper('meta', '<meta>', '', | |
| 231 (element) => element is MetaElement)); | |
| 232 test('del', () => testConstructorHelper('del', '<del>foo</del>', 'foo', | |
| 233 (element) => element is ModElement)); | |
| 234 test('ins', () => testConstructorHelper('ins', '<ins>foo</ins>', 'foo', | |
| 235 (element) => element is ModElement)); | |
| 236 test('ol', () => testConstructorHelper('ol', '<ol>foo</ol>', 'foo', | |
| 237 (element) => element is OListElement)); | |
| 238 test('p', () => testConstructorHelper('p', '<p>foo</p>', 'foo', | |
| 239 (element) => element is ParagraphElement)); | |
| 240 test('param', () => testConstructorHelper('param', '<param>', '', | |
| 241 (element) => element is ParamElement)); | |
| 242 test('pre', () => testConstructorHelper('pre', '<pre>foo</pre>', 'foo', | |
| 243 (element) => element is PreElement)); | |
| 244 test('q', () => testConstructorHelper('q', '<q>foo</q>', 'foo', | |
| 245 (element) => element is QuoteElement)); | |
| 246 test('script', () => testConstructorHelper('script', | |
| 247 '<script>foo</script>', 'foo', | |
| 248 (element) => element is ScriptElement)); | |
| 249 test('select', () => testConstructorHelper('select', | |
| 250 '<select>foo</select>', 'foo', | |
| 251 (element) => element is SelectElement)); | |
| 252 // TODO(jacobr): audio tags cause tests to segfault when using dartium. | |
| 253 // b/5522106. | |
| 254 // test('source', () => testConstructorHelper('source', '<source>', '', | |
| 255 // (element) => element is SourceElement)); | |
| 256 test('span', () => testConstructorHelper('span', '<span>foo</span>', 'foo', | |
| 257 (element) => element is SpanElement)); | |
| 258 test('style', () => testConstructorHelper('style', | |
| 259 '<style>foo</style>', 'foo', | |
| 260 (element) => element is StyleElement)); | |
| 261 test('table', () => testConstructorHelper('table', | |
| 262 '<table><caption>foo</caption></table>', 'foo', | |
| 263 (element) => element is TableElement)); | |
| 264 test('textarea', () => testConstructorHelper('textarea', | |
| 265 '<textarea>foo</textarea>', 'foo', | |
| 266 (element) => element is TextAreaElement)); | |
| 267 test('title', () => testConstructorHelper('title', | |
| 268 '<title>foo</title>', 'foo', | |
| 269 (element) => element is TitleElement)); | |
| 270 // TODO(jacobr): audio tags cause tests to segfault when using dartium. | |
| 271 // b/5522106. | |
| 272 // test('track', () => testConstructorHelper('track', '<track>', '', | |
| 273 // (element) => element is TrackElement)); | |
| 274 test('ul', () => testConstructorHelper('ul', '<ul>foo</ul>', 'foo', | |
| 275 (element) => element is UListElement)); | |
| 276 // TODO(jacobr): video tags cause tests to segfault when using dartium. | |
| 277 // b/5522106. | |
| 278 // test('video', () => testConstructorHelper('video', | |
| 279 // '<video>foo</video>', 'foo', | |
| 280 // (element) => element is VideoElement)); | |
| 281 // TODO(jacobr): this test is broken until Dartium fixes b/5521083 | |
| 282 // test('someunknown', () => testConstructorHelper('someunknown', | |
| 283 // '<someunknown>foo</someunknown>', 'foo', | |
| 284 // (element) => element is UnknownElement)); | |
| 285 }); | 114 }); |
| 286 | 115 |
| 287 group('eventListening', () { | 116 group('eventListening', () { |
| 288 test('eventListeners', () { | 117 test('eventListeners', () { |
| 289 final element = new Element.tag('div'); | 118 final element = new Element.tag('div'); |
| 290 final on = element.on; | 119 final on = element.on; |
| 291 | 120 |
| 292 testEventHelper(on.abort, 'abort', | 121 testEventHelper(on.abort, 'abort', |
| 293 (listener) => Testing.addEventListener( | 122 (listener) => Testing.addEventListener( |
| 294 element, 'abort', listener, true)); | 123 element, 'abort', listener, true)); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 }); | 602 }); |
| 774 | 603 |
| 775 test('getRange', () { | 604 test('getRange', () { |
| 776 var range = makeElList().getRange(1, 2); | 605 var range = makeElList().getRange(1, 2); |
| 777 expect(range, isElementList); | 606 expect(range, isElementList); |
| 778 expect(range[0], isImageElement); | 607 expect(range[0], isImageElement); |
| 779 expect(range[1], isInputElement); | 608 expect(range[1], isInputElement); |
| 780 }); | 609 }); |
| 781 }); | 610 }); |
| 782 } | 611 } |
| OLD | NEW |