Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: tests/html/svg_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 SVGTest; 5 library SVGTest;
6
6 import 'dart:html'; 7 import 'dart:html';
7 import 'dart:svg' as svg; 8 import 'dart:svg' as svg;
8 import 'package:unittest/html_individual_config.dart'; 9 import 'package:unittest/html_individual_config.dart';
9 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
10 11
11 main() { 12 main() {
12 useHtmlIndividualConfiguration(); 13 useHtmlIndividualConfiguration();
13 14
14 group('svgPresence', () { 15 group('svgPresence', () {
15 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement'); 16 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
16 17
17 test('simpleRect', () { 18 test('simpleRect', () {
18 var div = new Element.tag('div'); 19 var div = new Element.tag('div');
19 document.body.append(div); 20 document.body.append(div);
20 div.setInnerHtml(r''' 21 div.setInnerHtml(
22 r'''
21 <svg id='svg1' width='200' height='100'> 23 <svg id='svg1' width='200' height='100'>
22 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> 24 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
23 </svg> 25 </svg>
24 ''', validator: new NodeValidatorBuilder()..allowSvg()); 26 ''',
27 validator: new NodeValidatorBuilder()..allowSvg());
25 28
26 var e = document.query('#svg1'); 29 var e = document.query('#svg1');
27 expect(e, isNotNull); 30 expect(e, isNotNull);
28 31
29 svg.RectElement r = document.query('#rect1'); 32 svg.RectElement r = document.query('#rect1');
30 expect(r.x.baseVal.value, 10); 33 expect(r.x.baseVal.value, 10);
31 expect(r.y.baseVal.value, 20); 34 expect(r.y.baseVal.value, 20);
32 expect(r.height.baseVal.value, 40); 35 expect(r.height.baseVal.value, 40);
33 expect(r.width.baseVal.value, 130); 36 expect(r.width.baseVal.value, 130);
34 expect(r.rx.baseVal.value, 5); 37 expect(r.rx.baseVal.value, 5);
35 }); 38 });
36 39
37 test('trailing newline', () { 40 test('trailing newline', () {
38 // Ensures that we handle SVG with trailing newlines. 41 // Ensures that we handle SVG with trailing newlines.
39 var logo = new svg.SvgElement.svg(""" 42 var logo = new svg.SvgElement.svg("""
40 <svg xmlns='http://www.w3.org/2000/svg' version='1.1'> 43 <svg xmlns='http://www.w3.org/2000/svg' version='1.1'>
41 <path/> 44 <path/>
42 </svg> 45 </svg>
43 """); 46 """);
44 47
45 expect(logo, isSvgElement); 48 expect(logo, isSvgElement);
46
47 }); 49 });
48 }); 50 });
49 51
50 group('svgInterfaceMatch', () { 52 group('svgInterfaceMatch', () {
51 // Test that SVG elements explicitly implement the IDL interfaces (is-checks 53 // Test that SVG elements explicitly implement the IDL interfaces (is-checks
52 // only, see SVGTest3 for behavioural tests). 54 // only, see SVGTest3 for behavioural tests).
53 insertTestDiv() { 55 insertTestDiv() {
54 var element = new Element.tag('div'); 56 var element = new Element.tag('div');
55 element.setInnerHtml(r''' 57 element.setInnerHtml(
58 r'''
56 <svg id='svg1' width='200' height='100'> 59 <svg id='svg1' width='200' height='100'>
57 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> 60 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
58 </svg> 61 </svg>
59 ''', validator: new NodeValidatorBuilder()..allowSvg()); 62 ''',
63 validator: new NodeValidatorBuilder()..allowSvg());
60 document.body.append(element); 64 document.body.append(element);
61 return element; 65 return element;
62 } 66 }
63 67
64
65 var isElement = predicate((x) => x is Element, 'is an Element'); 68 var isElement = predicate((x) => x is Element, 'is an Element');
66 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement'); 69 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
67 var isSvgSvgElement = 70 var isSvgSvgElement =
68 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement'); 71 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
69 var isNode = predicate((x) => x is Node, 'is a Node'); 72 var isNode = predicate((x) => x is Node, 'is a Node');
70 var isSvgNumber = predicate((x) => x is svg.Number, 'is a svg.Number'); 73 var isSvgNumber = predicate((x) => x is svg.Number, 'is a svg.Number');
71 var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect'); 74 var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
72 75
73 test('rect_isChecks', () { 76 test('rect_isChecks', () {
74 var div = insertTestDiv(); 77 var div = insertTestDiv();
75 var r = document.query('#rect1'); 78 var r = document.query('#rect1');
76 79
77 // Direct inheritance chain 80 // Direct inheritance chain
78 expect(r, isSvgElement); 81 expect(r, isSvgElement);
79 expect(r, isElement); 82 expect(r, isElement);
80 expect(r, isNode); 83 expect(r, isNode);
81 84
82 // Interfaces not implemented. 85 // Interfaces not implemented.
83 expect(r, isNot(isSvgNumber)); 86 expect(r, isNot(isSvgNumber));
84 expect(r, isNot(isSvgRect)); 87 expect(r, isNot(isSvgRect));
85 expect(r, isNot(isSvgSvgElement)); 88 expect(r, isNot(isSvgSvgElement));
86 89
87 div.remove(); 90 div.remove();
88 });
89 }); 91 });
92 });
90 93
91 insertTestDiv() { 94 insertTestDiv() {
92 var element = new Element.tag('div'); 95 var element = new Element.tag('div');
93 element.innerHtml = r''' 96 element.innerHtml = r'''
94 <svg id='svg1' width='200' height='100'> 97 <svg id='svg1' width='200' height='100'>
95 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> 98 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
96 </svg> 99 </svg>
97 '''; 100 ''';
98 document.body.append(element); 101 document.body.append(element);
99 return element; 102 return element;
100 } 103 }
101 104
102 group('svgBehavioral', () { 105 group('svgBehavioral', () {
103
104 // Test that SVG elements have the operations advertised through all the IDL 106 // Test that SVG elements have the operations advertised through all the IDL
105 // interfaces. This is a 'duck typing' test, and does not explicitly use 107 // interfaces. This is a 'duck typing' test, and does not explicitly use
106 // 'is' checks on the expected interfaces (that is in the test group above). 108 // 'is' checks on the expected interfaces (that is in the test group above).
107 109
108 var isString = predicate((x) => x is String, 'is a String'); 110 var isString = predicate((x) => x is String, 'is a String');
109 var isStringList = predicate((x) => x is List<String>, 'is a List<String>'); 111 var isStringList = predicate((x) => x is List<String>, 'is a List<String>');
110 var isSvgMatrix = predicate((x) => x is svg.Matrix, 'is a svg.Matrix'); 112 var isSvgMatrix = predicate((x) => x is svg.Matrix, 'is a svg.Matrix');
111 var isSvgAnimatedBoolean = 113 var isSvgAnimatedBoolean =
112 predicate((x) => x is svg.AnimatedBoolean, 'is an svg.AnimatedBoolean'); 114 predicate((x) => x is svg.AnimatedBoolean, 'is an svg.AnimatedBoolean');
113 var isSvgAnimatedString = 115 var isSvgAnimatedString =
114 predicate((x) => x is svg.AnimatedString, 'is an svg.AnimatedString'); 116 predicate((x) => x is svg.AnimatedString, 'is an svg.AnimatedString');
115 var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect'); 117 var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
116 var isSvgAnimatedTransformList = 118 var isSvgAnimatedTransformList = predicate(
117 predicate((x) => x is svg.AnimatedTransformList, 119 (x) => x is svg.AnimatedTransformList,
118 'is an svg.AnimatedTransformList'); 120 'is an svg.AnimatedTransformList');
119 var isCssStyleDeclaration = 121 var isCssStyleDeclaration =
120 predicate((x) => x is CssStyleDeclaration, 'is a CssStyleDeclaration'); 122 predicate((x) => x is CssStyleDeclaration, 'is a CssStyleDeclaration');
121 123
122
123 testRect(name, checker) { 124 testRect(name, checker) {
124 test(name, () { 125 test(name, () {
125 var div = insertTestDiv(); 126 var div = insertTestDiv();
126 var r = document.query('#rect1'); 127 var r = document.query('#rect1');
127 checker(r); 128 checker(r);
128 div.remove(); 129 div.remove();
129 }); 130 });
130 } 131 }
131 }); 132 });
132
133 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698