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

Unified Diff: tests/html/element_test.dart

Issue 23055008: Making almost all dom_ methods private. Exceptions will be addressed in a later CL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/web_audio/dartium/web_audio_dartium.dart ('k') | tests/html/node_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/element_test.dart
diff --git a/tests/html/element_test.dart b/tests/html/element_test.dart
index 71dd4eaa7df469ddd30b1c22568981474672ef83..d9f186c7eab1d417e9178c748dc576202f62a41c 100644
--- a/tests/html/element_test.dart
+++ b/tests/html/element_test.dart
@@ -820,4 +820,75 @@ main() {
expect(firedEvent5, true);
});
});
+
+ group('ElementList', () {
+ // Tests for methods on the DOM class 'NodeList'.
+ //
+ // There are two interesting things that are checked here from the viewpoint
+ // of the dart2js implementation of a 'native' class:
+ //
+ // 1. Some methods are implementated from by 'Object' or 'Interceptor';
+ // some of these tests simply check that a method can be called.
+ // 2. Some methods are implemented by mixins.
+
+ ElementList makeElementList() =>
+ (new Element.html("<div>Foo<br/><!--baz--><br/><br/></div>"))
+ .queryAll('br');
+
+ test('hashCode', () {
+ var nodes = makeElementList();
+ var hash = nodes.hashCode;
+ final int N = 1000;
+ int matchCount = 0;
+ for (int i = 0; i < N; i++) {
+ if (makeElementList().hashCode == hash) matchCount++;
+ }
+ expect(matchCount, lessThan(N));
+ });
+
+ test('operator==', () {
+ var a = [makeElementList(), makeElementList(), null];
+ for (int i = 0; i < a.length; i++) {
+ for (int j = 0; j < a.length; j++) {
+ expect(i == j, a[i] == a[j]);
+ }
+ }
+ });
+
+ test('runtimeType', () {
+ var nodes1 = makeElementList();
+ var nodes2 = makeElementList();
+ var type1 = nodes1.runtimeType;
+ var type2 = nodes2.runtimeType;
+ expect(type1 == type2, true);
+ String name = '$type1';
+ if (name.length > 3) {
+ expect(name.contains('ElementList'), true);
+ }
+ });
+
+ test('first', () {
+ var nodes = makeElementList();
+ expect(nodes.first, isBRElement);
+ });
+
+ test('last', () {
+ var nodes = makeElementList();
+ expect(nodes.last, isBRElement);
+ });
+
+ test('where', () {
+ var filtered = makeElementList().where((n) => n is BRElement).toList();
+ expect(filtered.length, 3);
+ expect(filtered[0], isBRElement);
+ });
+
+ test('sublist', () {
+ var range = makeElementList().sublist(1, 3);
+ expect(range.length, 2);
+ expect(range[0], isBRElement);
+ expect(range[1], isBRElement);
+ });
+
+ });
}
« no previous file with comments | « sdk/lib/web_audio/dartium/web_audio_dartium.dart ('k') | tests/html/node_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698