Chromium Code Reviews| 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 NodeTest; | 5 library NodeTest; |
| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 | 317 |
| 318 testUnsupported('fillRange', () { | 318 testUnsupported('fillRange', () { |
| 319 makeNodeWithChildren().nodes.fillRange(0, 1, null); | 319 makeNodeWithChildren().nodes.fillRange(0, 1, null); |
| 320 }); | 320 }); |
| 321 | 321 |
| 322 testUnsupported('setAll', () { | 322 testUnsupported('setAll', () { |
| 323 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]); | 323 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]); |
| 324 }); | 324 }); |
| 325 }); | 325 }); |
| 326 | 326 |
| 327 group('NodeList', () { | |
|
blois
2013/05/10 00:34:30
Why not put it in group('_NodeList')?
Names are t
sra1
2013/05/10 22:13:26
Done.
| |
| 328 // Tests for methods on the DOM class 'NodeList' that get their | |
| 329 // implementation from 'Object' and/or 'Interceptor'. Some of these tests | |
| 330 // simply check that a method can be called. | |
| 331 List<Node> makeNodeList() => | |
| 332 makeNodeWithChildren().$dom_getElementsByTagName('br'); | |
| 333 | |
| 334 test('trueNodeList', () { | |
| 335 var nodes = makeNodeList(); | |
| 336 expect(nodes is NodeList, true); | |
| 337 }); | |
| 338 | |
| 339 test('hashCode', () { | |
| 340 var nodes = makeNodeList(); | |
| 341 var hash = nodes.hashCode; | |
| 342 final int N = 1000; | |
| 343 int matchCount = 0; | |
| 344 for (int i = 0; i < N; i++) { | |
| 345 if (makeNodeList().hashCode == hash) matchCount++; | |
| 346 } | |
| 347 expect(matchCount, lessThan(N)); | |
| 348 }); | |
| 349 | |
| 350 test('operator==', () { | |
| 351 var a = [makeNodeList(), makeNodeList(), null]; | |
| 352 for (int i = 0; i < a.length; i++) { | |
| 353 for (int j = 0; j < a.length; j++) { | |
| 354 expect(i == j, a[i] == a[j]); | |
| 355 } | |
| 356 } | |
| 357 }); | |
| 358 | |
| 359 test('runtimeType', () { | |
| 360 var nodes1 = makeNodeList(); | |
| 361 var nodes2 = makeNodeList(); | |
| 362 var type1 = nodes1.runtimeType; | |
| 363 var type2 = nodes2.runtimeType; | |
| 364 expect(type1 == type2, true); | |
| 365 String name = '$type1'; | |
| 366 if (name.length > 3) { | |
| 367 expect(name, 'NodeList'); | |
| 368 } | |
| 369 }); | |
| 370 }); | |
| 371 | |
| 327 group('_NodeList', () { | 372 group('_NodeList', () { |
| 328 List<Node> makeNodeList() => | 373 List<Node> makeNodeList() => |
| 329 makeNodeWithChildren().nodes.where((_) => true).toList(); | 374 makeNodeWithChildren().nodes.where((_) => true).toList(); |
| 330 | 375 |
| 331 test('first', () { | 376 test('first', () { |
| 332 var nodes = makeNodeList(); | 377 var nodes = makeNodeList(); |
| 333 expect(nodes.first, isText); | 378 expect(nodes.first, isText); |
| 334 }); | 379 }); |
| 335 | 380 |
| 336 test('where', () { | 381 test('where', () { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 357 }); | 402 }); |
| 358 | 403 |
| 359 test('TreeWalker', () { | 404 test('TreeWalker', () { |
| 360 var root = makeNodeWithChildren(); | 405 var root = makeNodeWithChildren(); |
| 361 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT); | 406 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT); |
| 362 expect(treeWalker.nextNode(), isComment); | 407 expect(treeWalker.nextNode(), isComment); |
| 363 expect(treeWalker.nextNode(), isNull); | 408 expect(treeWalker.nextNode(), isNull); |
| 364 }); | 409 }); |
| 365 }); | 410 }); |
| 366 } | 411 } |
| OLD | NEW |