OLD | NEW |
1 library DocumentTest; | 1 library DocumentTest; |
2 import 'package:unittest/unittest.dart'; | 2 import 'package:unittest/unittest.dart'; |
3 import 'package:unittest/html_individual_config.dart'; | 3 import 'package:unittest/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 var inscrutable; | 16 var inscrutable; |
17 | 17 |
18 test('CreateElement', () { | 18 test('CreateElement', () { |
19 // FIXME: nifty way crashes, do it boring way. | 19 // FIXME: nifty way crashes, do it boring way. |
20 expect(new Element.tag('span'), isElement); | 20 expect(new Element.tag('span'), isElement); |
21 expect(new Element.tag('div'), isDivElement); | 21 expect(new Element.tag('div'), isDivElement); |
22 expect(new Element.tag('a'), isAnchorElement); | 22 expect(new Element.tag('a'), isAnchorElement); |
23 expect(new Element.tag('bad_name'), isUnknownElement); | 23 expect(new Element.tag('bad_name'), isUnknownElement); |
24 }); | 24 }); |
25 | 25 |
26 group('supports_cssCanvasContext', () { | |
27 test('supports_cssCanvasContext', () { | |
28 expect(HtmlDocument.supportsCssCanvasContext, true); | |
29 }); | |
30 }); | |
31 | |
32 group('getCssCanvasContext', () { | |
33 test('getCssCanvasContext 2d', () { | |
34 var expectation = HtmlDocument.supportsCssCanvasContext ? | |
35 returnsNormally : throws; | |
36 | |
37 expect(() { | |
38 var context = document.getCssCanvasContext('2d', 'testContext', 10, 20); | |
39 expect(context is CanvasRenderingContext2D, true); | |
40 expect(context.canvas.width, 10); | |
41 expect(context.canvas.height, 20); | |
42 }, expectation); | |
43 }); | |
44 }); | |
45 | |
46 group('document', () { | 26 group('document', () { |
47 inscrutable = (x) => x; | 27 inscrutable = (x) => x; |
48 | 28 |
49 test('Document.query', () { | 29 test('Document.query', () { |
50 Document doc = new DomParser().parseFromString( | 30 Document doc = new DomParser().parseFromString( |
51 '''<ResultSet> | 31 '''<ResultSet> |
52 <Row>A</Row> | 32 <Row>A</Row> |
53 <Row>B</Row> | 33 <Row>B</Row> |
54 <Row>C</Row> | 34 <Row>C</Row> |
55 </ResultSet>''','text/xml'); | 35 </ResultSet>''','text/xml'); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 77 |
98 test('typeTest2', () { | 78 test('typeTest2', () { |
99 inscrutable = inscrutable(inscrutable); | 79 inscrutable = inscrutable(inscrutable); |
100 // XML document. | 80 // XML document. |
101 var doc3 = document.implementation.createDocument(null, 'report', null); | 81 var doc3 = document.implementation.createDocument(null, 'report', null); |
102 expect(doc3 is HtmlDocument, false); | 82 expect(doc3 is HtmlDocument, false); |
103 expect(inscrutable(doc3) is HtmlDocument, false); | 83 expect(inscrutable(doc3) is HtmlDocument, false); |
104 }); | 84 }); |
105 }); | 85 }); |
106 } | 86 } |
OLD | NEW |