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

Side by Side Diff: client/tests/client/html/ElementTests.dart

Issue 9930008: Fix issue http://code.google.com/p/dart/issues/detail?id=1877 without degrading performance. Impro… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review fixes Created 8 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 | « no previous file | lib/dom/templates/html/impl/impl_Element.darttemplate » ('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 5
6 expectLargeRect(ClientRect rect) { 6 expectLargeRect(ClientRect rect) {
7 Expect.equals(rect.top, 0); 7 Expect.equals(rect.top, 0);
8 Expect.equals(rect.left, 0); 8 Expect.equals(rect.left, 0);
9 Expect.isTrue(rect.width > 100); 9 Expect.isTrue(rect.width > 100);
10 Expect.isTrue(rect.height > 100); 10 Expect.isTrue(rect.height > 100);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 (listener) => Testing.addEventListener( 405 (listener) => Testing.addEventListener(
406 element, 'touchmove', listener, true)); 406 element, 'touchmove', listener, true));
407 testEventHelper(on.touchStart, 'touchstart', 407 testEventHelper(on.touchStart, 'touchstart',
408 (listener) => Testing.addEventListener( 408 (listener) => Testing.addEventListener(
409 element, 'touchstart', listener, true)); 409 element, 'touchstart', listener, true));
410 testEventHelper(on.transitionEnd, 'webkitTransitionEnd'); 410 testEventHelper(on.transitionEnd, 'webkitTransitionEnd');
411 testEventHelper(on.fullscreenChange, 'webkitfullscreenchange', 411 testEventHelper(on.fullscreenChange, 'webkitfullscreenchange',
412 (listener) => Testing.addEventListener(element, 412 (listener) => Testing.addEventListener(element,
413 'webkitfullscreenchange', listener, true)); 413 'webkitfullscreenchange', listener, true));
414 }); 414 });
415
416 group('attributes', () {
417 test('manipulation', () {
418 final element = new Element.html(
419 '''<div class="foo" style="overflow: hidden" data-foo="bar"
420 data-foo2="bar2" dir="rtl">
421 </div>''');
422 final attributes = element.attributes;
423 Expect.equals(attributes['class'], 'foo');
424 Expect.equals(attributes['style'], 'overflow: hidden');
425 Expect.equals(attributes['data-foo'], 'bar');
426 Expect.equals(attributes['data-foo2'], 'bar2');
427 Expect.equals(attributes.length, 5);
428 Expect.equals(element.dataAttributes.length, 2);
429 element.dataAttributes['foo'] = 'baz';
430 Expect.equals(element.dataAttributes['foo'], 'baz');
431 Expect.equals(attributes['data-foo'], 'baz');
432 attributes['data-foo2'] = 'baz2';
433 Expect.equals(attributes['data-foo2'], 'baz2');
434 Expect.equals(element.dataAttributes['foo2'], 'baz2');
435 Expect.equals(attributes['dir'], 'rtl');
415 436
416 test('attributes', () { 437 final dataAttributes = element.dataAttributes;
417 final element = new Element.html( 438 dataAttributes.remove('foo2');
418 '''<div class="foo" style="overflow: hidden" data-foo="bar" 439 Expect.equals(attributes.length, 4);
419 data-foo2="bar2" dir="rtl"> 440 Expect.equals(dataAttributes.length, 1);
420 </div>'''); 441 attributes.remove('style');
421 final attributes = element.attributes; 442 Expect.equals(attributes.length, 3);
422 Expect.equals(attributes['class'], 'foo'); 443 dataAttributes['foo3'] = 'baz3';
423 Expect.equals(attributes['style'], 'overflow: hidden'); 444 Expect.equals(dataAttributes.length, 2);
424 Expect.equals(attributes['data-foo'], 'bar'); 445 Expect.equals(attributes.length, 4);
425 Expect.equals(attributes['data-foo2'], 'bar2'); 446 attributes['style'] = 'width: 300px;';
426 Expect.equals(attributes.length, 5); 447 Expect.equals(attributes.length, 5);
427 Expect.equals(element.dataAttributes.length, 2); 448 });
428 element.dataAttributes['foo'] = 'baz';
429 Expect.equals(element.dataAttributes['foo'], 'baz');
430 Expect.equals(attributes['data-foo'], 'baz');
431 attributes['data-foo2'] = 'baz2';
432 Expect.equals(attributes['data-foo2'], 'baz2');
433 Expect.equals(element.dataAttributes['foo2'], 'baz2');
434 Expect.equals(attributes['dir'], 'rtl');
435 449
436 // TODO(jacobr): determine why these tests are causing segfaults in dartium 450 test('coercion', () {
437 // element.dataAttributes.remove('foo2'); 451 final element = new Element.tag('div');
438 // Expect.equals(attributes.length, 4); 452 element.attributes['foo'] = 42;
439 // Expect.equals(dataAttributes.length, 1); 453 element.attributes['bar'] = 3.1;
440 // attributes.remove('style'); 454 Expect.equals(element.attributes['foo'], '42');
441 // Expect.equals(attributes.length, 3); 455 Expect.equals(element.attributes['bar'], '3.1');
442 // element.dataAttributes['foo3'] = 'baz3'; 456 });
443 // Expect.equals(dataAttributes.length, 2);
444 // Expect.equals(attributes.length, 4);
445 // attributes['style'] = 'width: 300px;';
446 // Expect.equals(attributes.length, 5);*/
447 }); 457 });
448 458
449 group('elements', () { 459 group('elements', () {
450 test('is a subset of nodes', () { 460 test('is a subset of nodes', () {
451 var el = new Element.html("<div>Foo<br/><img/></div>"); 461 var el = new Element.html("<div>Foo<br/><img/></div>");
452 Expect.equals(3, el.nodes.length); 462 Expect.equals(3, el.nodes.length);
453 Expect.equals(2, el.elements.length); 463 Expect.equals(2, el.elements.length);
454 Expect.equals(el.nodes[1], el.elements[0]); 464 Expect.equals(el.nodes[1], el.elements[0]);
455 Expect.equals(el.nodes[2], el.elements[1]); 465 Expect.equals(el.nodes[2], el.elements[1]);
456 }); 466 });
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 classes.intersection(['foo', 'qux', 'baz'])); 884 classes.intersection(['foo', 'qux', 'baz']));
875 }); 885 });
876 886
877 test('clear', () { 887 test('clear', () {
878 final classes = makeClassSet(); 888 final classes = makeClassSet();
879 classes.clear(); 889 classes.clear();
880 Expect.setEquals([], classes); 890 Expect.setEquals([], classes);
881 }); 891 });
882 }); 892 });
883 } 893 }
OLDNEW
« no previous file with comments | « no previous file | lib/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698