OLD | NEW |
1 library DocumentTest; | 1 library DocumentTest; |
2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
3 import '../../pkg/unittest/lib/html_individual_config.dart'; | 3 import '../../pkg/unittest/lib/html_individual_config.dart'; |
4 import 'dart:html'; | 4 import 'dart:html'; |
5 | 5 |
6 main() { | 6 main() { |
7 useHtmlIndividualConfiguration(); | 7 useHtmlIndividualConfiguration(); |
8 | 8 |
9 var isElement = predicate((x) => x is Element, 'is an Element'); | 9 var isElement = predicate((x) => x is Element, 'is an Element'); |
10 var isDivElement = predicate((x) => x is DivElement, 'is a DivElement'); | 10 var isDivElement = predicate((x) => x is DivElement, 'is a DivElement'); |
11 var isAnchorElement = | 11 var isAnchorElement = |
12 predicate((x) => x is AnchorElement, 'is an AnchorElement'); | 12 predicate((x) => x is AnchorElement, 'is an AnchorElement'); |
13 var isUnknownElement = | 13 var isUnknownElement = |
14 predicate((x) => x is UnknownElement, 'is UnknownElement'); | 14 predicate((x) => x is UnknownElement, 'is UnknownElement'); |
15 | 15 |
16 test('CreateElement', () { | 16 group('getCssCanvasContext', () { |
17 // FIXME: nifty way crashes, do it boring way. | 17 test('getCssCanvasContext 2d', () { |
18 expect(new Element.tag('span'), isElement); | 18 var context = document.getCssCanvasContext('2d', 'testContext', 10, 20); |
19 expect(new Element.tag('div'), isDivElement); | 19 expect(context is CanvasRenderingContext2D, true); |
20 expect(new Element.tag('a'), isAnchorElement); | 20 expect(context.canvas.width, 10); |
21 expect(new Element.tag('bad_name'), isUnknownElement); | 21 expect(context.canvas.height, 20); |
22 }); | |
23 | |
24 group('supports_cssCanvasContext', () { | |
25 test('supports_cssCanvasContext', () { | |
26 expect(HtmlDocument.supportsCssCanvasContext, true); | |
27 }); | 22 }); |
28 }); | 23 }); |
29 | 24 |
30 group('getCssCanvasContext', () { | |
31 test('getCssCanvasContext 2d', () { | |
32 var expectation = HtmlDocument.supportsCssCanvasContext ? | |
33 returnsNormally : throws; | |
34 | |
35 expect(() { | |
36 var context = document.getCssCanvasContext('2d', 'testContext', 10, 20); | |
37 expect(context is CanvasRenderingContext2D, true); | |
38 expect(context.canvas.width, 10); | |
39 expect(context.canvas.height, 20); | |
40 }, expectation); | |
41 }); | |
42 }); | |
43 | |
44 group('document', () { | 25 group('document', () { |
45 test('Document.query', () { | 26 test('Document.query', () { |
46 Document doc = new DomParser().parseFromString( | 27 Document doc = new DomParser().parseFromString( |
47 '''<ResultSet> | 28 '''<ResultSet> |
48 <Row>A</Row> | 29 <Row>A</Row> |
49 <Row>B</Row> | 30 <Row>B</Row> |
50 <Row>C</Row> | 31 <Row>C</Row> |
51 </ResultSet>''','text/xml'); | 32 </ResultSet>''','text/xml'); |
52 | 33 |
53 var rs = doc.query('ResultSet'); | 34 var rs = doc.query('ResultSet'); |
54 expect(rs, isNotNull); | 35 expect(rs, isNotNull); |
55 }); | 36 }); |
56 | 37 |
57 test('CreateElement', () { | 38 test('CreateElement', () { |
58 // FIXME: nifty way crashes, do it boring way. | 39 // FIXME: nifty way crashes, do it boring way. |
59 expect(new Element.tag('span'), isElement); | 40 expect(new Element.tag('span'), isElement); |
60 expect(new Element.tag('div'), isDivElement); | 41 expect(new Element.tag('div'), isDivElement); |
61 expect(new Element.tag('a'), isAnchorElement); | 42 expect(new Element.tag('a'), isAnchorElement); |
62 expect(new Element.tag('bad_name'), isUnknownElement); | 43 expect(new Element.tag('bad_name'), isUnknownElement); |
63 }); | 44 }); |
64 }); | 45 }); |
65 } | 46 } |
OLD | NEW |