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

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

Issue 16374007: First rev of Safe DOM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « tests/html/safe_dom_test.dart ('k') | tests/html/svgelement_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 6 import 'dart:html';
9 import 'dart:svg' as svg; 7 import 'dart:svg' as svg;
8 import 'package:unittest/html_individual_config.dart';
9 import 'package:unittest/unittest.dart';
10 10
11 main() { 11 main() {
12 useHtmlIndividualConfiguration(); 12 useHtmlIndividualConfiguration();
13 13
14 group('svgPresence', () { 14 group('svgPresence', () {
15 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement'); 15 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
16 16
17 test('simpleRect', () { 17 test('simpleRect', () {
18 var div = new Element.tag('div'); 18 var div = new Element.tag('div');
19 document.body.append(div); 19 document.body.append(div);
20 div.innerHtml = r''' 20 div.setInnerHtml(r'''
21 <svg id='svg1' width='200' height='100'> 21 <svg id='svg1' width='200' height='100'>
22 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> 22 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
23 </svg> 23 </svg>
24 24 ''', validator: new NodeValidatorBuilder()..allowSvg());
25 ''';
26 25
27 var e = document.query('#svg1'); 26 var e = document.query('#svg1');
28 expect(e, isNotNull); 27 expect(e, isNotNull);
29 28
30 svg.RectElement r = document.query('#rect1'); 29 svg.RectElement r = document.query('#rect1');
31 expect(r.x.baseVal.value, 10); 30 expect(r.x.baseVal.value, 10);
32 expect(r.y.baseVal.value, 20); 31 expect(r.y.baseVal.value, 20);
33 expect(r.height.baseVal.value, 40); 32 expect(r.height.baseVal.value, 40);
34 expect(r.width.baseVal.value, 130); 33 expect(r.width.baseVal.value, 130);
35 expect(r.rx.baseVal.value, 5); 34 expect(r.rx.baseVal.value, 5);
(...skipping 10 matching lines...) Expand all
46 expect(logo, isSvgElement); 45 expect(logo, isSvgElement);
47 46
48 }); 47 });
49 }); 48 });
50 49
51 group('svgInterfaceMatch', () { 50 group('svgInterfaceMatch', () {
52 // Test that SVG elements explicitly implement the IDL interfaces (is-checks 51 // Test that SVG elements explicitly implement the IDL interfaces (is-checks
53 // only, see SVGTest3 for behavioural tests). 52 // only, see SVGTest3 for behavioural tests).
54 insertTestDiv() { 53 insertTestDiv() {
55 var element = new Element.tag('div'); 54 var element = new Element.tag('div');
56 element.innerHtml = r''' 55 element.setInnerHtml(r'''
57 <svg id='svg1' width='200' height='100'> 56 <svg id='svg1' width='200' height='100'>
58 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect> 57 <rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
59 </svg> 58 </svg>
60 '''; 59 ''', validator: new NodeValidatorBuilder()..allowSvg());
61 document.body.append(element); 60 document.body.append(element);
62 return element; 61 return element;
63 } 62 }
64 63
65 64
66 var isElement = predicate((x) => x is Element, 'is an Element'); 65 var isElement = predicate((x) => x is Element, 'is an Element');
67 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement'); 66 var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
68 var isSvgSvgElement = 67 var isSvgSvgElement =
69 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement'); 68 predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
70 var isNode = predicate((x) => x is Node, 'is a Node'); 69 var isNode = predicate((x) => x is Node, 'is a Node');
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 test(name, () { 124 test(name, () {
126 var div = insertTestDiv(); 125 var div = insertTestDiv();
127 var r = document.query('#rect1'); 126 var r = document.query('#rect1');
128 checker(r); 127 checker(r);
129 div.remove(); 128 div.remove();
130 }); 129 });
131 } 130 }
132 }); 131 });
133 132
134 } 133 }
OLDNEW
« no previous file with comments | « tests/html/safe_dom_test.dart ('k') | tests/html/svgelement_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698