| 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('../../lib/unittest/unittest.dart'); | 6 #import('../../lib/unittest/unittest.dart'); |
| 7 #import('../../lib/unittest/html_config.dart'); | 7 #import('../../lib/unittest/html_config.dart'); |
| 8 #import('dart:html'); | 8 #import('dart:html'); |
| 9 | 9 |
| 10 expectLargeRect(ClientRect rect) { | 10 expectLargeRect(ClientRect rect) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 main() { | 48 main() { |
| 49 useHtmlConfiguration(); | 49 useHtmlConfiguration(); |
| 50 | 50 |
| 51 Element makeElement() => new Element.tag('div'); | 51 Element makeElement() => new Element.tag('div'); |
| 52 | 52 |
| 53 Element makeElementWithChildren() => | 53 Element makeElementWithChildren() => |
| 54 new Element.html("<div><br/><img/><input/></div>"); | 54 new Element.html("<div><br/><img/><input/></div>"); |
| 55 | 55 |
| 56 asyncTest('computedStyle', 1, () { | 56 test('computedStyle', () { |
| 57 final element = document.body; | 57 final element = document.body; |
| 58 element.computedStyle.then((style) { | 58 element.computedStyle.then(expectAsync1((style) { |
| 59 Expect.equals(style.getPropertyValue('left'), 'auto'); | 59 Expect.equals(style.getPropertyValue('left'), 'auto'); |
| 60 callbackDone(); | 60 })); |
| 61 }); | |
| 62 }); | 61 }); |
| 63 | 62 |
| 64 asyncTest('rect', 1, () { | 63 test('rect', () { |
| 65 final container = new Element.tag("div"); | 64 final container = new Element.tag("div"); |
| 66 container.style.position = 'absolute'; | 65 container.style.position = 'absolute'; |
| 67 container.style.top = '8px'; | 66 container.style.top = '8px'; |
| 68 container.style.left = '8px'; | 67 container.style.left = '8px'; |
| 69 final element = new Element.tag("div"); | 68 final element = new Element.tag("div"); |
| 70 element.style.width = '200px'; | 69 element.style.width = '200px'; |
| 71 element.style.height = '200px'; | 70 element.style.height = '200px'; |
| 72 container.elements.add(element); | 71 container.elements.add(element); |
| 73 document.body.elements.add(container); | 72 document.body.elements.add(container); |
| 74 | 73 |
| 75 element.rect.then((rect) { | 74 element.rect.then(expectAsync1((rect) { |
| 76 expectLargeRect(rect.client); | 75 expectLargeRect(rect.client); |
| 77 expectLargeRect(rect.offset); | 76 expectLargeRect(rect.offset); |
| 78 expectLargeRect(rect.scroll); | 77 expectLargeRect(rect.scroll); |
| 79 Expect.equals(rect.bounding.left, 8); | 78 Expect.equals(rect.bounding.left, 8); |
| 80 Expect.equals(rect.bounding.top, 8); | 79 Expect.equals(rect.bounding.top, 8); |
| 81 Expect.isTrue(rect.clientRects.length > 0); | 80 Expect.isTrue(rect.clientRects.length > 0); |
| 82 container.remove(); | 81 container.remove(); |
| 83 callbackDone(); | 82 })); |
| 84 }); | |
| 85 }); | 83 }); |
| 86 | 84 |
| 87 group('constructors', () { | 85 group('constructors', () { |
| 88 test('error', () { | 86 test('error', () { |
| 89 Expect.throws(() => new Element.html('<br/><br/>'), | 87 Expect.throws(() => new Element.html('<br/><br/>'), |
| 90 (e) => e is IllegalArgumentException); | 88 (e) => e is IllegalArgumentException); |
| 91 }); | 89 }); |
| 92 | 90 |
| 93 test('.html has no parent', () => | 91 test('.html has no parent', () => |
| 94 Expect.isNull(new Element.html('<br/>').parent)); | 92 Expect.isNull(new Element.html('<br/>').parent)); |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 classes.intersection(['foo', 'qux', 'baz'])); | 888 classes.intersection(['foo', 'qux', 'baz'])); |
| 891 }); | 889 }); |
| 892 | 890 |
| 893 test('clear', () { | 891 test('clear', () { |
| 894 final classes = makeClassSet(); | 892 final classes = makeClassSet(); |
| 895 classes.clear(); | 893 classes.clear(); |
| 896 Expect.setEquals([], classes); | 894 Expect.setEquals([], classes); |
| 897 }); | 895 }); |
| 898 }); | 896 }); |
| 899 } | 897 } |
| OLD | NEW |