OLD | NEW |
1 library CssTest; | 1 library CssTest; |
| 2 |
2 import 'package:unittest/unittest.dart'; | 3 import 'package:unittest/unittest.dart'; |
3 import 'package:unittest/html_individual_config.dart'; | 4 import 'package:unittest/html_individual_config.dart'; |
4 import 'dart:html'; | 5 import 'dart:html'; |
5 | 6 |
6 main() { | 7 main() { |
7 useHtmlIndividualConfiguration(); | 8 useHtmlIndividualConfiguration(); |
8 | 9 |
9 group('supportsPointConversions', () { | 10 group('supportsPointConversions', () { |
10 test('supported', () { | 11 test('supported', () { |
11 expect(Window.supportsPointConversions, true); | 12 expect(Window.supportsPointConversions, true); |
12 }); | 13 }); |
13 }); | 14 }); |
14 | 15 |
15 group('functional', () { | 16 group('functional', () { |
16 test('DomPoint', () { | 17 test('DomPoint', () { |
17 var expectation = Window.supportsPointConversions ? | 18 Element element = new Element.tag('div'); |
18 returnsNormally : throws; | 19 element.attributes['style'] = ''' |
19 expect(() { | |
20 Element element = new Element.tag('div'); | |
21 element.attributes['style'] = | |
22 ''' | |
23 position: absolute; | 20 position: absolute; |
24 width: 60px; | 21 width: 60px; |
25 height: 100px; | 22 height: 100px; |
26 left: 0px; | 23 left: 0px; |
27 top: 0px; | 24 top: 0px; |
28 background-color: red; | 25 background-color: red; |
29 -webkit-transform: translate3d(250px, 100px, 0px); | 26 -webkit-transform: translate3d(250px, 100px, 0px); |
30 -moz-transform: translate3d(250px, 100px, 0px); | 27 -moz-transform: translate3d(250px, 100px, 0px); |
31 '''; | 28 '''; |
32 document.body.append(element); | 29 document.body.append(element); |
33 | 30 |
34 var elemRect = element.getBoundingClientRect(); | 31 var elemRect = element.getBoundingClientRect(); |
35 | 32 |
36 checkPoint(250, 100, new Point(elemRect.left, elemRect.top)); | 33 checkPoint(250, 100, new Point(elemRect.left, elemRect.top)); |
37 checkPoint(310, 200, new Point(elemRect.right, elemRect.bottom)); | 34 checkPoint(310, 200, new Point(elemRect.right, elemRect.bottom)); |
38 }, expectation); | |
39 }); | 35 }); |
40 }); | 36 }); |
41 } | 37 } |
42 | 38 |
43 void checkPoint(expectedX, expectedY, Point point) { | 39 void checkPoint(expectedX, expectedY, Point point) { |
44 expect(point.x.round(), equals(expectedX), reason: 'Wrong point.x'); | 40 expect(point.x.round(), equals(expectedX), reason: 'Wrong point.x'); |
45 expect(point.y.round(), equals(expectedY), reason: 'Wrong point.y'); | 41 expect(point.y.round(), equals(expectedY), reason: 'Wrong point.y'); |
46 } | 42 } |
OLD | NEW |