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

Unified Diff: tests/html/element_add_test.dart

Issue 10854208: Adding Element.AddHTML and Element.addText methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updating CL to the latest committed version. Created 8 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
Index: tests/html/element_add_test.dart
diff --git a/tests/html/element_add_test.dart b/tests/html/element_add_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0937ffea321b6c7c8a544d61829ac1bc481cee23
--- /dev/null
+++ b/tests/html/element_add_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
vsm 2012/08/22 18:22:27 s/2011/2012/
blois 2012/08/22 20:06:13 Done.
+// 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.
+
+// Put universally passing event constructors in this file.
vsm 2012/08/22 18:22:27 This comment doesn't seem to match this test.
blois 2012/08/22 20:06:13 D'oh. Copy paste :(
+// Move constructors that fail on some configuration to their own
+// element_constructor_foo_test.dart file.
+
+#library('ElementAddTest');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+#source('util.dart');
+
+main() {
+ useHtmlConfiguration();
+
+ void expectNoSuchMethod(void fn()) =>
+ Expect.throws(fn, (e) => e is NoSuchMethodException);
+
+ group('addHTML', () {
+ test('htmlelement', () {
+ // Adding a <tr/> to a table should auto-wrap it into a tbody element.
+ var el = new TableElement();
+ el.addHTML('<tr>test</tr>');
+ Expect.equals(1, el.elements.length);
vsm 2012/08/22 18:22:27 Sorry this isn't clear anywhere, but the old Expec
blois 2012/08/22 20:06:13 Done.
+ var section = el.elements[0];
+ Expect.isTrue(section is TableSectionElement);
vsm 2012/08/22 18:22:27 expect(section is TableSectionElement);
blois 2012/08/22 20:06:13 Done.
+ Expect.equals(1, section.elements.length);
+ Expect.isTrue(section.elements[0] is TableRowElement);
vsm 2012/08/22 18:22:27 How about testing a second add to ensure that it's
blois 2012/08/22 20:06:13 Done.
+ });
+
+ test('documentFragment', () {
+ var fragment = new DocumentFragment();
+ fragment.addHTML('<span>something</span>');
+ Expect.equals(1, fragment.elements.length);
+ Expect.isTrue(fragment.elements[0] is SpanElement);
+ });
+
+ test('svg', () {
+ var svg = new SVGElement.tag('g');
+ expectNoSuchMethod(() => svg.addHTML('<rect/>'));;
+ });
+ });
+
+ group('addText', () {
+ test('htmlelement', () {
+ var el = new DivElement();
+ el.addText('foo');
+ // No elements were created.
+ Expect.equals(0, el.elements.length);
+ // One text node was added.
+ Expect.equals(1, el.nodes.length);
+ });
+
+ test('documentFragment', () {
+ var fragment = new DocumentFragment();
+ fragment.addText('foo');
+ // No elements were created.
+ Expect.equals(0, fragment.elements.length);
+ // One text node was added.
+ Expect.equals(1, fragment.nodes.length);
+ });
+
+ test('svg', () {
+ var svg = new SVGElement.tag('g');
+ expectNoSuchMethod(() => svg.addText('foo'));
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698