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

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

Issue 14619026: dart2js native mixin application should extend 'Interface', not 'Object' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/web_sql/dart2js/web_sql_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('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 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 testUnsupported('fillRange', () { 329 testUnsupported('fillRange', () {
330 makeNodeWithChildren().nodes.fillRange(0, 1, null); 330 makeNodeWithChildren().nodes.fillRange(0, 1, null);
331 }); 331 });
332 332
333 testUnsupported('setAll', () { 333 testUnsupported('setAll', () {
334 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]); 334 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]);
335 }); 335 });
336 }); 336 });
337 337
338 group('_NodeList', () { 338 group('NodeList', () {
339 // Tests for methods on the DOM class 'NodeList'.
340 //
341 // There are two interesting things that are checked here from the viewpoint
342 // of the dart2js implementation of a 'native' class:
343 //
344 // 1. Some methods are implementated from by 'Object' or 'Interceptor';
345 // some of these tests simply check that a method can be called.
346 // 2. Some methods are implemented by mixins.
347
339 List<Node> makeNodeList() => 348 List<Node> makeNodeList() =>
340 makeNodeWithChildren().nodes.where((_) => true).toList(); 349 (new Element.html("<div>Foo<br/><!--baz--><br/><br/></div>"))
350 .$dom_getElementsByTagName('br');
351
352 test('trueNodeList', () {
353 var nodes = makeNodeList();
354 expect(nodes is NodeList, true);
355 });
356
357 test('hashCode', () {
358 var nodes = makeNodeList();
359 var hash = nodes.hashCode;
360 final int N = 1000;
361 int matchCount = 0;
362 for (int i = 0; i < N; i++) {
363 if (makeNodeList().hashCode == hash) matchCount++;
364 }
365 expect(matchCount, lessThan(N));
366 });
367
368 test('operator==', () {
369 var a = [makeNodeList(), makeNodeList(), null];
370 for (int i = 0; i < a.length; i++) {
371 for (int j = 0; j < a.length; j++) {
372 expect(i == j, a[i] == a[j]);
373 }
374 }
375 });
376
377 test('runtimeType', () {
378 var nodes1 = makeNodeList();
379 var nodes2 = makeNodeList();
380 var type1 = nodes1.runtimeType;
381 var type2 = nodes2.runtimeType;
382 expect(type1 == type2, true);
383 String name = '$type1';
384 if (name.length > 3) {
385 expect(name.contains('NodeList'), true);
386 }
387 });
341 388
342 test('first', () { 389 test('first', () {
343 var nodes = makeNodeList(); 390 var nodes = makeNodeList();
344 expect(nodes.first, isText); 391 expect(nodes.first, isBRElement);
392 });
393
394 test('last', () {
395 var nodes = makeNodeList();
396 expect(nodes.last, isBRElement);
345 }); 397 });
346 398
347 test('where', () { 399 test('where', () {
348 var filtered = makeNodeList().where((n) => n is BRElement).toList(); 400 var filtered = makeNodeList().where((n) => n is BRElement).toList();
349 expect(filtered.length, 1); 401 expect(filtered.length, 3);
350 expect(filtered[0], isBRElement); 402 expect(filtered[0], isBRElement);
351 expect(filtered, isNodeList); 403 expect(filtered, isNodeList);
352 }); 404 });
353 405
354 test('sublist', () { 406 test('sublist', () {
355 var range = makeNodeList().sublist(1, 3); 407 var range = makeNodeList().sublist(1, 3);
356 expect(range, isNodeList); 408 expect(range.length, 2);
357 expect(range[0], isBRElement); 409 expect(range[0], isBRElement);
358 expect(range[1], isComment); 410 expect(range[1], isBRElement);
359 }); 411 });
412
360 }); 413 });
361 414
362 group('iterating', () { 415 group('iterating', () {
363 test('NodeIterator', () { 416 test('NodeIterator', () {
364 var root = makeNodeWithChildren(); 417 var root = makeNodeWithChildren();
365 var nodeIterator = new NodeIterator(root, NodeFilter.SHOW_COMMENT); 418 var nodeIterator = new NodeIterator(root, NodeFilter.SHOW_COMMENT);
366 expect(nodeIterator.nextNode(), isComment); 419 expect(nodeIterator.nextNode(), isComment);
367 expect(nodeIterator.nextNode(), isNull); 420 expect(nodeIterator.nextNode(), isNull);
368 }); 421 });
369 422
370 test('TreeWalker', () { 423 test('TreeWalker', () {
371 var root = makeNodeWithChildren(); 424 var root = makeNodeWithChildren();
372 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT); 425 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT);
373 expect(treeWalker.nextNode(), isComment); 426 expect(treeWalker.nextNode(), isComment);
374 expect(treeWalker.nextNode(), isNull); 427 expect(treeWalker.nextNode(), isNull);
375 }); 428 });
376 }); 429 });
377 } 430 }
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dart2js/web_sql_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698