| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 SvgElementTest; | 5 library SvgElementTest; |
| 6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
| 7 import '../../pkg/unittest/lib/html_individual_config.dart'; | 7 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:svg' as svg; | 9 import 'dart:svg' as svg; |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 testConstructor('text', (e) => e is svg.TextElement); | 145 testConstructor('text', (e) => e is svg.TextElement); |
| 146 testConstructor('textPath', (e) => e is svg.TextPathElement); | 146 testConstructor('textPath', (e) => e is svg.TextPathElement); |
| 147 testConstructor('title', (e) => e is svg.TitleElement); | 147 testConstructor('title', (e) => e is svg.TitleElement); |
| 148 testConstructor('use', (e) => e is svg.UseElement); | 148 testConstructor('use', (e) => e is svg.UseElement); |
| 149 testConstructor('view', (e) => e is svg.ViewElement); | 149 testConstructor('view', (e) => e is svg.ViewElement); |
| 150 }); | 150 }); |
| 151 | 151 |
| 152 group('outerHTML', () { | 152 group('outerHTML', () { |
| 153 test('outerHTML', () { | 153 test('outerHTML', () { |
| 154 final el = new svg.SvgSvgElement(); | 154 final el = new svg.SvgSvgElement(); |
| 155 el.elements.add(new svg.CircleElement()); | 155 el.children.add(new svg.CircleElement()); |
| 156 el.elements.add(new svg.PathElement()); | 156 el.children.add(new svg.PathElement()); |
| 157 expect(el.outerHTML, | 157 expect(el.outerHTML, |
| 158 '<svg version="1.1"><circle></circle><path></path></svg>'); | 158 '<svg version="1.1"><circle></circle><path></path></svg>'); |
| 159 }); | 159 }); |
| 160 }); | 160 }); |
| 161 | 161 |
| 162 group('innerHTML', () { | 162 group('innerHTML', () { |
| 163 test('get', () { | 163 test('get', () { |
| 164 final el = new svg.SvgSvgElement(); | 164 final el = new svg.SvgSvgElement(); |
| 165 el.elements.add(new svg.CircleElement()); | 165 el.children.add(new svg.CircleElement()); |
| 166 el.elements.add(new svg.PathElement()); | 166 el.children.add(new svg.PathElement()); |
| 167 expect(el.innerHTML, '<circle></circle><path></path>'); | 167 expect(el.innerHTML, '<circle></circle><path></path>'); |
| 168 }); | 168 }); |
| 169 | 169 |
| 170 test('set', () { | 170 test('set', () { |
| 171 final el = new svg.SvgSvgElement(); | 171 final el = new svg.SvgSvgElement(); |
| 172 el.elements.add(new svg.CircleElement()); | 172 el.children.add(new svg.CircleElement()); |
| 173 el.elements.add(new svg.PathElement()); | 173 el.children.add(new svg.PathElement()); |
| 174 el.innerHTML = '<rect></rect><a></a>'; | 174 el.innerHTML = '<rect></rect><a></a>'; |
| 175 expect(_nodeStrings(el.elements), ["rect", "a"]); | 175 expect(_nodeStrings(el.children), ["rect", "a"]); |
| 176 }); | 176 }); |
| 177 }); | 177 }); |
| 178 | 178 |
| 179 group('elementget', () { | 179 group('elementget', () { |
| 180 test('get', () { | 180 test('get', () { |
| 181 final el = new svg.SvgElement.svg(""" | 181 final el = new svg.SvgElement.svg(""" |
| 182 <svg version="1.1"> | 182 <svg version="1.1"> |
| 183 <circle></circle> | 183 <circle></circle> |
| 184 <path></path> | 184 <path></path> |
| 185 text | 185 text |
| 186 </svg>"""); | 186 </svg>"""); |
| 187 expect(_nodeStrings(el.elements), ["circle", "path"]); | 187 expect(_nodeStrings(el.children), ["circle", "path"]); |
| 188 }); | 188 }); |
| 189 }); | 189 }); |
| 190 | 190 |
| 191 group('elementset', () { | 191 group('elementset', () { |
| 192 test('set', () { | 192 test('set', () { |
| 193 final el = new svg.SvgSvgElement(); | 193 final el = new svg.SvgSvgElement(); |
| 194 el.elements = [new svg.SvgElement.tag("circle"), new svg.SvgElement.tag("p
ath")]; | 194 el.children = [new svg.SvgElement.tag("circle"), new svg.SvgElement.tag("p
ath")]; |
| 195 expect(el.innerHTML, '<circle></circle><path></path>'); | 195 expect(el.innerHTML, '<circle></circle><path></path>'); |
| 196 }); | 196 }); |
| 197 }); | 197 }); |
| 198 | 198 |
| 199 group('css', () { | 199 group('css', () { |
| 200 test('classes', () { | 200 test('classes', () { |
| 201 var el = new svg.CircleElement(); | 201 var el = new svg.CircleElement(); |
| 202 var classes = el.classes; | 202 var classes = el.classes; |
| 203 expect(el.classes.length, 0); | 203 expect(el.classes.length, 0); |
| 204 classes.toggle('foo'); | 204 classes.toggle('foo'); |
| 205 expect(el.classes.length, 1); | 205 expect(el.classes.length, 1); |
| 206 classes.toggle('foo'); | 206 classes.toggle('foo'); |
| 207 expect(el.classes.length, 0); | 207 expect(el.classes.length, 0); |
| 208 }); | 208 }); |
| 209 }); | 209 }); |
| 210 } | 210 } |
| OLD | NEW |