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

Unified Diff: tests/html/query_test.dart

Issue 10544111: Some HTML API cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add new template Created 8 years, 6 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
Index: tests/html/query_test.dart
diff --git a/tests/html/query_test.dart b/tests/html/query_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2d5d6203b83e1a538eed01d6ee77ebeb25b046ef
--- /dev/null
+++ b/tests/html/query_test.dart
@@ -0,0 +1,53 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('QueryTest');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+
+main() {
+ useHtmlConfiguration();
+
+ final div = new DivElement();
+ final canvas = new CanvasElement(200,200);
+ canvas.id = 'testcanvas';
+ final element =
+ new Element.html("<div><br/><img/><input/><img/></div>");
+ document.body.nodes.addAll([div, canvas, element]);
+
+
+ test('query', () {
+ Element e = query('#testcanvas');
+ Expect.isNotNull(e);
+ Expect.stringEquals('testcanvas', e.id);
+ Expect.isTrue(e is CanvasElement);
+ Expect.equals(canvas, e);
+ });
+
+ test('query (None)', () {
+ Element e = query('#nothere');
+ Expect.isNull(e);
+ });
+
+ test('queryAll (One)', () {
+ List l = queryAll('canvas');
+ Expect.equals(1, l.length);
+ Expect.equals(canvas, l[0]);
+ });
+
+
+ test('queryAll (Multiple)', () {
+ List l = queryAll('img');
+ Expect.equals(2, l.length);
+ Expect.isTrue(l[0] is ImageElement);
+ Expect.isTrue(l[1] is ImageElement);
+ Expect.notEquals(l[0], l[1]);
+ });
+
+ test('queryAll (None)', () {
+ List l = queryAll('video');
+ Expect.isTrue(l.isEmpty());
+ });
+}
« lib/dom/templates/html/frog/impl_CanvasElement.darttemplate ('K') | « tests/html/canvas_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698