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 ElementTest; | 5 library ElementTest; |
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:async'; | 8 import 'dart:async'; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 import 'dart:svg' as svg; | 10 import 'dart:svg' as svg; |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 }); | 472 }); |
473 | 473 |
474 test('removeLast', () { | 474 test('removeLast', () { |
475 var el = makeElementWithChildren(); | 475 var el = makeElementWithChildren(); |
476 expect(el.children.removeLast(), isInputElement); | 476 expect(el.children.removeLast(), isInputElement); |
477 expect(el.children.length, 2); | 477 expect(el.children.length, 2); |
478 expect(el.children.removeLast(), isImageElement); | 478 expect(el.children.removeLast(), isImageElement); |
479 expect(el.children.length, 1); | 479 expect(el.children.length, 1); |
480 }); | 480 }); |
481 | 481 |
482 test('getRange', () { | 482 test('sublist', () { |
483 var el = makeElementWithChildren(); | 483 var el = makeElementWithChildren(); |
484 expect(el.children.getRange(1, 1), isElementList); | 484 expect(el.children.sublist(1, 2), isElementList); |
485 }); | 485 }); |
486 }); | 486 }); |
487 | 487 |
488 group('matches', () { | 488 group('matches', () { |
489 test('matches', () { | 489 test('matches', () { |
490 var element = new DivElement(); | 490 var element = new DivElement(); |
491 element.classes.add('test'); | 491 element.classes.add('test'); |
492 | 492 |
493 expect(element.matches('div'), true); | 493 expect(element.matches('div'), true); |
494 expect(element.matches('span'), false); | 494 expect(element.matches('span'), false); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 test('iterator', () { | 575 test('iterator', () { |
576 var els = []; | 576 var els = []; |
577 for (var subel in getQueryAll()) { | 577 for (var subel in getQueryAll()) { |
578 els.add(subel); | 578 els.add(subel); |
579 } | 579 } |
580 expect(els[0], isAnchorElement); | 580 expect(els[0], isAnchorElement); |
581 expect(els[1], isSpanElement); | 581 expect(els[1], isSpanElement); |
582 expect(els[2], isHRElement); | 582 expect(els[2], isHRElement); |
583 }); | 583 }); |
584 | 584 |
585 test('getRange', () { | 585 test('sublist', () { |
586 expect(getQueryAll().getRange(1, 1) is List<Element>, isTrue); | 586 expect(getQueryAll().sublist(1, 2) is List<Element>, isTrue); |
587 }); | 587 }); |
588 | 588 |
589 testUnsupported('[]=', () => getQueryAll()[1] = new Element.tag('br')); | 589 testUnsupported('[]=', () => getQueryAll()[1] = new Element.tag('br')); |
590 testUnsupported('add', () => getQueryAll().add(new Element.tag('br'))); | 590 testUnsupported('add', () => getQueryAll().add(new Element.tag('br'))); |
591 | 591 |
592 testUnsupported('addAll', () { | 592 testUnsupported('addAll', () { |
593 getQueryAll().addAll([ | 593 getQueryAll().addAll([ |
594 new Element.tag('span'), | 594 new Element.tag('span'), |
595 new Element.tag('a'), | 595 new Element.tag('a'), |
596 new Element.tag('h1') | 596 new Element.tag('h1') |
(...skipping 28 matching lines...) Expand all Loading... |
625 group('_ElementList', () { | 625 group('_ElementList', () { |
626 List<Element> makeElList() => makeElementWithChildren().children; | 626 List<Element> makeElList() => makeElementWithChildren().children; |
627 | 627 |
628 test('where', () { | 628 test('where', () { |
629 var filtered = makeElList().where((n) => n is ImageElement); | 629 var filtered = makeElList().where((n) => n is ImageElement); |
630 expect(filtered.length, 1); | 630 expect(filtered.length, 1); |
631 expect(filtered.first, isImageElement); | 631 expect(filtered.first, isImageElement); |
632 expect(filtered, isElementIterable); | 632 expect(filtered, isElementIterable); |
633 }); | 633 }); |
634 | 634 |
635 test('getRange', () { | 635 test('sublist', () { |
636 var range = makeElList().getRange(1, 2); | 636 var range = makeElList().sublist(1, 3); |
637 expect(range, isElementList); | 637 expect(range, isElementList); |
638 expect(range[0], isImageElement); | 638 expect(range[0], isImageElement); |
639 expect(range[1], isInputElement); | 639 expect(range[1], isInputElement); |
640 }); | 640 }); |
641 }); | 641 }); |
642 } | 642 } |
OLD | NEW |