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

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

Issue 13934019: Revert "With the collections deriving from ListBase, we no longer need to implement a number of boi… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « sdk/lib/html/html_common/filtered_element_list.dart ('k') | tests/html/node_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) 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;
11 11
12 expectLargeRect(Rect rect) { 12 expectLargeRect(Rect rect) {
13 expect(rect.top, 0); 13 expect(rect.top, 0);
14 expect(rect.left, 0); 14 expect(rect.left, 0);
15 expect(rect.width, greaterThan(100)); 15 expect(rect.width, greaterThan(100));
16 expect(rect.height, greaterThan(100)); 16 expect(rect.height, greaterThan(100));
17 expect(rect.bottom, rect.top + rect.height); 17 expect(rect.bottom, rect.top + rect.height);
18 expect(rect.right, rect.left + rect.width); 18 expect(rect.right, rect.left + rect.width);
19 } 19 }
20 20
21 void testUnsupported(String name, void f()) {
22 test(name, () {
23 expect(f, throwsUnsupportedError);
24 });
25 }
26
27 main() { 21 main() {
28 useHtmlIndividualConfiguration(); 22 useHtmlIndividualConfiguration();
29 23
30 var isHRElement = predicate((x) => x is HRElement, 'is a HRElement'); 24 var isHRElement = predicate((x) => x is HRElement, 'is a HRElement');
31 var isBRElement = predicate((x) => x is BRElement, 'is a BRElement'); 25 var isBRElement = predicate((x) => x is BRElement, 'is a BRElement');
32 var isInputElement = 26 var isInputElement =
33 predicate((x) => x is InputElement, 'is an InputElement'); 27 predicate((x) => x is InputElement, 'is an InputElement');
34 var isImageElement = 28 var isImageElement =
35 predicate((x) => x is ImageElement, 'is an ImageElement'); 29 predicate((x) => x is ImageElement, 'is an ImageElement');
36 var isSpanElement = predicate((x) => x is SpanElement, 'is a SpanElement'); 30 var isSpanElement = predicate((x) => x is SpanElement, 'is a SpanElement');
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 expect(el.children.removeLast(), isInputElement); 481 expect(el.children.removeLast(), isInputElement);
488 expect(el.children.length, 2); 482 expect(el.children.length, 2);
489 expect(el.children.removeLast(), isImageElement); 483 expect(el.children.removeLast(), isImageElement);
490 expect(el.children.length, 1); 484 expect(el.children.length, 1);
491 }); 485 });
492 486
493 test('sublist', () { 487 test('sublist', () {
494 var el = makeElementWithChildren(); 488 var el = makeElementWithChildren();
495 expect(el.children.sublist(1, 2), isElementList); 489 expect(el.children.sublist(1, 2), isElementList);
496 }); 490 });
497
498 test('getRange', () {
499 var el = makeElementWithChildren();
500 expect(el.children.getRange(1, 2).length, 1);
501 });
502
503 testUnsupported('sort', () {
504 var l = makeElementWithChildren().children;
505 l.sort();
506 });
507
508 testUnsupported('setRange', () {
509 var l = makeElementWithChildren().children;
510 l.setRange(0, 0, []);
511 });
512
513 testUnsupported('replaceRange', () {
514 var l = makeElementWithChildren().children;
515 l.replaceRange(0, 0, []);
516 });
517
518 testUnsupported('removeRange', () {
519 var l = makeElementWithChildren().children;
520 l.removeRange(0, 1);
521 });
522
523 testUnsupported('insertAll', () {
524 var l = makeElementWithChildren().children;
525 l.insertAll(0, []);
526 });
527 }); 491 });
528 492
529 group('matches', () { 493 group('matches', () {
530 test('matches', () { 494 test('matches', () {
531 var element = new DivElement(); 495 var element = new DivElement();
532 element.classes.add('test'); 496 element.classes.add('test');
533 497
534 expect(element.matches('div'), true); 498 expect(element.matches('div'), true);
535 expect(element.matches('span'), false); 499 expect(element.matches('span'), false);
536 expect(element.matches('.test'), true); 500 expect(element.matches('.test'), true);
(...skipping 10 matching lines...) Expand all
547 <span class='q'>Hello</span>, 511 <span class='q'>Hello</span>,
548 <em>world</em>! 512 <em>world</em>!
549 </p> 513 </p>
550 <hr class='q'/> 514 <hr class='q'/>
551 </div> 515 </div>
552 """).queryAll('.q'); 516 """).queryAll('.q');
553 } 517 }
554 518
555 List<Element> getEmptyQueryAll() => new Element.tag('div').queryAll('img'); 519 List<Element> getEmptyQueryAll() => new Element.tag('div').queryAll('img');
556 520
521 void testUnsupported(String name, void f()) {
522 test(name, () {
523 expect(f, throwsUnsupportedError);
524 });
525 }
526
557 test('last', () { 527 test('last', () {
558 expect(getQueryAll().last, isHRElement); 528 expect(getQueryAll().last, isHRElement);
559 }); 529 });
560 530
561 test('forEach', () { 531 test('forEach', () {
562 var els = []; 532 var els = [];
563 getQueryAll().forEach((el) => els.add(el)); 533 getQueryAll().forEach((el) => els.add(el));
564 expect(els[0], isAnchorElement); 534 expect(els[0], isAnchorElement);
565 expect(els[1], isSpanElement); 535 expect(els[1], isSpanElement);
566 expect(els[2], isHRElement); 536 expect(els[2], isHRElement);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 testUnsupported('addAll', () { 597 testUnsupported('addAll', () {
628 getQueryAll().addAll([ 598 getQueryAll().addAll([
629 new Element.tag('span'), 599 new Element.tag('span'),
630 new Element.tag('a'), 600 new Element.tag('a'),
631 new Element.tag('h1') 601 new Element.tag('h1')
632 ]); 602 ]);
633 }); 603 });
634 604
635 testUnsupported('sort', () => getQueryAll().sort((a1, a2) => true)); 605 testUnsupported('sort', () => getQueryAll().sort((a1, a2) => true));
636 606
637 testUnsupported('setRange', () { 607 testUnsupported('setRange', () => getQueryAll().setRange(0, 0, []));
638 getQueryAll().setRange(0, 1, [new BRElement()]);
639 });
640 608
641 testUnsupported('removeRange', () => getQueryAll().removeRange(0, 1)); 609 testUnsupported('removeRange', () => getQueryAll().removeRange(0, 1));
642 610
643 testUnsupported('clear', () => getQueryAll().clear()); 611 testUnsupported('clear', () => getQueryAll().clear());
644 612
645 testUnsupported('removeLast', () => getQueryAll().removeLast()); 613 testUnsupported('removeLast', () => getQueryAll().removeLast());
646 }); 614 });
647 615
648 group('functional', () { 616 group('functional', () {
649 test('toString', () { 617 test('toString', () {
(...skipping 25 matching lines...) Expand all
675 }); 643 });
676 644
677 test('sublist', () { 645 test('sublist', () {
678 var range = makeElList().sublist(1, 3); 646 var range = makeElList().sublist(1, 3);
679 expect(range, isElementList); 647 expect(range, isElementList);
680 expect(range[0], isImageElement); 648 expect(range[0], isImageElement);
681 expect(range[1], isInputElement); 649 expect(range[1], isInputElement);
682 }); 650 });
683 }); 651 });
684 } 652 }
OLDNEW
« no previous file with comments | « sdk/lib/html/html_common/filtered_element_list.dart ('k') | tests/html/node_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698