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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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/element_classes_test.dart ('k') | tests/html/htmlcollection_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:html'; 8 import 'dart:html';
9 import 'dart:svg' as svg; 9 import 'dart:svg' as svg;
10 10
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 361
362 test('forEach', () { 362 test('forEach', () {
363 var els = []; 363 var els = [];
364 var el = makeElementWithChildren(); 364 var el = makeElementWithChildren();
365 el.children.forEach((n) => els.add(n)); 365 el.children.forEach((n) => els.add(n));
366 expect(els[0], isBRElement); 366 expect(els[0], isBRElement);
367 expect(els[1], isImageElement); 367 expect(els[1], isImageElement);
368 expect(els[2], isInputElement); 368 expect(els[2], isInputElement);
369 }); 369 });
370 370
371 test('filter', () { 371 test('where', () {
372 var filtered = makeElementWithChildren().children. 372 var filtered = makeElementWithChildren().children.
373 filter((n) => n is ImageElement); 373 where((n) => n is ImageElement);
374 expect(1, filtered.length); 374 expect(1, filtered.length);
375 expect(filtered[0], isImageElement); 375 expect(filtered[0], isImageElement);
376 expect(filtered, isElementList); 376 expect(filtered, isElementList);
377 }); 377 });
378 378
379 test('every', () { 379 test('every', () {
380 var el = makeElementWithChildren(); 380 var el = makeElementWithChildren();
381 expect(el.children.every((n) => n is Element), isTrue); 381 expect(el.children.every((n) => n is Element), isTrue);
382 expect(el.children.every((n) => n is InputElement), isFalse); 382 expect(el.children.every((n) => n is InputElement), isFalse);
383 }); 383 });
384 384
385 test('some', () { 385 test('any', () {
386 var el = makeElementWithChildren(); 386 var el = makeElementWithChildren();
387 expect(el.children.some((n) => n is InputElement), isTrue); 387 expect(el.children.any((n) => n is InputElement), isTrue);
388 expect(el.children.some((n) => n is svg.SvgElement), isFalse); 388 expect(el.children.any((n) => n is svg.SvgElement), isFalse);
389 }); 389 });
390 390
391 test('isEmpty', () { 391 test('isEmpty', () {
392 expect(makeElement().children.isEmpty, isTrue); 392 expect(makeElement().children.isEmpty, isTrue);
393 expect(makeElementWithChildren().children.isEmpty, isFalse); 393 expect(makeElementWithChildren().children.isEmpty, isFalse);
394 }); 394 });
395 395
396 test('length', () { 396 test('length', () {
397 expect(makeElement().children.length, 0); 397 expect(makeElement().children.length, 0);
398 expect(makeElementWithChildren().children.length, 3); 398 expect(makeElementWithChildren().children.length, 3);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 }); 499 });
500 500
501 test('forEach', () { 501 test('forEach', () {
502 var els = []; 502 var els = [];
503 getQueryAll().forEach((el) => els.add(el)); 503 getQueryAll().forEach((el) => els.add(el));
504 expect(els[0], isAnchorElement); 504 expect(els[0], isAnchorElement);
505 expect(els[1], isSpanElement); 505 expect(els[1], isSpanElement);
506 expect(els[2], isHRElement); 506 expect(els[2], isHRElement);
507 }); 507 });
508 508
509 test('map', () { 509 test('mappedBy', () {
510 var texts = getQueryAll().map((el) => el.text); 510 var texts = getQueryAll().mappedBy((el) => el.text).toList();
511 expect(texts, equals(['Dart!', 'Hello', ''])); 511 expect(texts, equals(['Dart!', 'Hello', '']));
512 }); 512 });
513 513
514 test('filter', () { 514 test('where', () {
515 var filtered = getQueryAll().filter((n) => n is SpanElement); 515 var filtered = getQueryAll().where((n) => n is SpanElement).toList();
516 expect(filtered.length, 1); 516 expect(filtered.length, 1);
517 expect(filtered[0], isSpanElement); 517 expect(filtered[0], isSpanElement);
518 expect(filtered, isElementList); 518 expect(filtered, isElementList);
519 }); 519 });
520 520
521 test('every', () { 521 test('every', () {
522 var el = getQueryAll(); 522 var el = getQueryAll();
523 expect(el.every((n) => n is Element), isTrue); 523 expect(el.every((n) => n is Element), isTrue);
524 expect(el.every((n) => n is SpanElement), isFalse); 524 expect(el.every((n) => n is SpanElement), isFalse);
525 }); 525 });
526 526
527 test('some', () { 527 test('any', () {
528 var el = getQueryAll(); 528 var el = getQueryAll();
529 expect(el.some((n) => n is SpanElement), isTrue); 529 expect(el.any((n) => n is SpanElement), isTrue);
530 expect(el.some((n) => n is svg.SvgElement), isFalse); 530 expect(el.any((n) => n is svg.SvgElement), isFalse);
531 }); 531 });
532 532
533 test('isEmpty', () { 533 test('isEmpty', () {
534 expect(getEmptyQueryAll().isEmpty, isTrue); 534 expect(getEmptyQueryAll().isEmpty, isTrue);
535 expect(getQueryAll().isEmpty, isFalse); 535 expect(getQueryAll().isEmpty, isFalse);
536 }); 536 });
537 537
538 test('length', () { 538 test('length', () {
539 expect(getEmptyQueryAll().length, 0); 539 expect(getEmptyQueryAll().length, 0);
540 expect(getQueryAll().length, 3); 540 expect(getQueryAll().length, 3);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 testUnsupported('insertangeRange', () => getQueryAll().insertRange(0, 1)); 583 testUnsupported('insertangeRange', () => getQueryAll().insertRange(0, 1));
584 584
585 testUnsupported('clear', () => getQueryAll().clear()); 585 testUnsupported('clear', () => getQueryAll().clear());
586 586
587 testUnsupported('removeLast', () => getQueryAll().removeLast()); 587 testUnsupported('removeLast', () => getQueryAll().removeLast());
588 }); 588 });
589 589
590 group('_ElementList', () { 590 group('_ElementList', () {
591 List<Element> makeElList() => makeElementWithChildren().children; 591 List<Element> makeElList() => makeElementWithChildren().children;
592 592
593 test('filter', () { 593 test('where', () {
594 var filtered = makeElList().filter((n) => n is ImageElement); 594 var filtered = makeElList().where((n) => n is ImageElement);
595 expect(filtered.length, 1); 595 expect(filtered.length, 1);
596 expect(filtered[0], isImageElement); 596 expect(filtered[0], isImageElement);
597 expect(filtered, isElementList); 597 expect(filtered, isElementList);
598 }); 598 });
599 599
600 test('getRange', () { 600 test('getRange', () {
601 var range = makeElList().getRange(1, 2); 601 var range = makeElList().getRange(1, 2);
602 expect(range, isElementList); 602 expect(range, isElementList);
603 expect(range[0], isImageElement); 603 expect(range[0], isImageElement);
604 expect(range[1], isInputElement); 604 expect(range[1], isInputElement);
605 }); 605 });
606 }); 606 });
607 } 607 }
OLDNEW
« no previous file with comments | « tests/html/element_classes_test.dart ('k') | tests/html/htmlcollection_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698