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 var expectation = |
18 returnsNormally : throws; | 19 Window.supportsPointConversions ? returnsNormally : throws; |
19 expect(() { | 20 expect(() { |
20 Element element = new Element.tag('div'); | 21 Element element = new Element.tag('div'); |
21 element.attributes['style'] = | 22 element.attributes['style'] = ''' |
22 ''' | |
23 position: absolute; | 23 position: absolute; |
24 width: 60px; | 24 width: 60px; |
25 height: 100px; | 25 height: 100px; |
26 left: 0px; | 26 left: 0px; |
27 top: 0px; | 27 top: 0px; |
28 background-color: red; | 28 background-color: red; |
29 -webkit-transform: translate3d(250px, 100px, 0px); | 29 -webkit-transform: translate3d(250px, 100px, 0px); |
30 -moz-transform: translate3d(250px, 100px, 0px); | 30 -moz-transform: translate3d(250px, 100px, 0px); |
31 '''; | 31 '''; |
32 document.body.append(element); | 32 document.body.append(element); |
33 | 33 |
34 var elemRect = element.getBoundingClientRect(); | 34 var elemRect = element.getBoundingClientRect(); |
35 | 35 |
36 checkPoint(250, 100, new Point(elemRect.left, elemRect.top)); | 36 checkPoint(250, 100, new Point(elemRect.left, elemRect.top)); |
37 checkPoint(310, 200, new Point(elemRect.right, elemRect.bottom)); | 37 checkPoint(310, 200, new Point(elemRect.right, elemRect.bottom)); |
38 }, expectation); | 38 }, expectation); |
39 }); | 39 }); |
40 }); | 40 }); |
41 } | 41 } |
42 | 42 |
43 void checkPoint(expectedX, expectedY, Point point) { | 43 void checkPoint(expectedX, expectedY, Point point) { |
44 expect(point.x.round(), equals(expectedX), reason: 'Wrong point.x'); | 44 expect(point.x.round(), equals(expectedX), reason: 'Wrong point.x'); |
45 expect(point.y.round(), equals(expectedY), reason: 'Wrong point.y'); | 45 expect(point.y.round(), equals(expectedY), reason: 'Wrong point.y'); |
46 } | 46 } |
OLD | NEW |