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

Side by Side Diff: tests/html/utils.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/svgelement_test.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library TestUtils; 1 library TestUtils;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:html'; 4 import 'dart:html';
5 import 'dart:typed_data'; 5 import 'dart:typed_data';
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 7
8 /** 8 /**
9 * Verifies that [actual] has the same graph structure as [expected]. 9 * Verifies that [actual] has the same graph structure as [expected].
10 * Detects cycles and DAG structure in Maps and Lists. 10 * Detects cycles and DAG structure in Maps and Lists.
11 */ 11 */
12 verifyGraph(expected, actual) { 12 verifyGraph(expected, actual) {
13 var eItems = []; 13 var eItems = [];
14 var aItems = []; 14 var aItems = [];
15 15
16 message(path, reason) => path == '' 16 message(path, reason) => path == ''
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 } 117 }
118 return; 118 return;
119 } 119 }
120 120
121 expect(false, isTrue, reason: 'Unhandled type: $expected'); 121 expect(false, isTrue, reason: 'Unhandled type: $expected');
122 } 122 }
123 123
124 walk('', expected, actual); 124 walk('', expected, actual);
125 } 125 }
126
127
128 /**
129 * Sanitizer which does nothing.
130 */
131 class NullTreeSanitizer implements NodeTreeSanitizer {
132 void sanitizeTree(Node node) {}
133 }
134
135
136 /**
137 * Validate that two DOM trees are equivalent.
138 */
139 void validateNodeTree(Node a, Node b, [String path = '']) {
140 path = '${path}${a.runtimeType}';
141 expect(a.nodeType, b.nodeType, reason: '$path nodeTypes differ');
142 expect(a.nodeValue, b.nodeValue, reason: '$path nodeValues differ');
143 expect(a.text, b.text, reason: '$path texts differ');
144 expect(a.nodes.length, b.nodes.length, reason: '$path nodes.lengths differ');
145
146 if (a is Element) {
147 Element bE = b;
148 Element aE = a;
149
150 expect(aE.tagName, bE.tagName, reason: '$path tagNames differ');
151 expect(aE.attributes.length, bE.attributes.length,
152 reason: '$path attributes.lengths differ');
153 for (var key in aE.attributes.keys) {
154 expect(aE.attributes[key], bE.attributes[key],
155 reason: '$path attribute [$key] values differ');
156 }
157 }
158 for (var i = 0; i < a.nodes.length; ++i) {
159 validateNodeTree(a.nodes[i], b.nodes[i], '$path[$i].');
160 }
161 }
OLDNEW
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698