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

Unified Diff: tests/dom/htmlelement_test.dart

Issue 10222026: Migrate dom tests to dart:html. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase & address comments. 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 side-by-side diff with in-line comments
Download patch
Index: tests/dom/htmlelement_test.dart
diff --git a/tests/dom/htmlelement_test.dart b/tests/dom/htmlelement_test.dart
index d17c690e895bbba10310d4f9a06fc2149c90db0e..b114c16df5aaf2725c80981c66a43db926e04926 100644
--- a/tests/dom/htmlelement_test.dart
+++ b/tests/dom/htmlelement_test.dart
@@ -1,49 +1,49 @@
-#library('HTMLElementTest');
+#library('ElementTest');
#import('../../lib/unittest/unittest.dart');
-#import('../../lib/unittest/dom_config.dart');
-#import('dart:dom');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
main() {
- useDomConfiguration();
+ useHtmlConfiguration();
test('InnerHTML', () {
- HTMLElement element = document.createElement('div');
+ Element element = new Element.tag('div');
element.id = 'test';
element.innerHTML = 'Hello World';
- document.body.appendChild(element);
+ document.body.nodes.add(element);
- element = document.getElementById('test');
+ element = document.query('#test');
Expect.stringEquals('Hello World', element.innerHTML);
- document.body.removeChild(element);
+ element.remove();
});
test('HTMLTable', () {
- HTMLElement table = document.createElement('table');
+ Element table = new Element.tag('table');
- HTMLTableRowElement row = document.createElement('tr');
- table.appendChild(row);
+ TableRowElement row = new Element.tag('tr');
+ table.nodes.add(row);
- row.appendChild(document.createElement('td'));
- row.appendChild(document.createElement('td'));
+ row.nodes.add(new Element.tag('td'));
+ row.nodes.add(new Element.tag('td'));
Expect.equals(2, row.cells.length);
- HTMLTableRowElement headerRow = table.rows.item(0);
+ TableRowElement headerRow = table.rows.item(0);
Expect.equals(2, headerRow.cells.length);
});
- test('Dataset', () {
- HTMLElement div = document.createElement('div');
+ test('dataAttributes', () {
+ Element div = new Element.tag('div');
- Expect.isTrue(div.dataset.isEmpty());
- Expect.equals('', div.dataset['foo']);
- Expect.isTrue(div.dataset.isEmpty());
+ Expect.isTrue(div.dataAttributes.isEmpty());
+ Expect.equals(null, div.dataAttributes['foo']);
+ Expect.isTrue(div.dataAttributes.isEmpty());
- div.dataset['foo'] = 'foo-value';
- Expect.equals('foo-value', div.dataset['foo']);
- Expect.isFalse(div.dataset.isEmpty());
+ div.dataAttributes['foo'] = 'foo-value';
+ Expect.equals('foo-value', div.dataAttributes['foo']);
+ Expect.isFalse(div.dataAttributes.isEmpty());
- Expect.isTrue(div.dataset.containsValue('foo-value'));
- Expect.isFalse(div.dataset.containsValue('bar-value'));
- Expect.isTrue(div.dataset.containsKey('foo'));
- Expect.isFalse(div.dataset.containsKey('bar'));
+ Expect.isTrue(div.dataAttributes.containsValue('foo-value'));
+ Expect.isFalse(div.dataAttributes.containsValue('bar-value'));
+ Expect.isTrue(div.dataAttributes.containsKey('foo'));
+ Expect.isFalse(div.dataAttributes.containsKey('bar'));
bool hasBeenInvoked;
String f() {
@@ -52,16 +52,16 @@ main() {
}
hasBeenInvoked = false;
- Expect.equals('bar-value', div.dataset.putIfAbsent('bar', f));
+ Expect.equals('bar-value', div.dataAttributes.putIfAbsent('bar', f));
Expect.isTrue(hasBeenInvoked);
hasBeenInvoked = false;
- Expect.equals('bar-value', div.dataset.putIfAbsent('bar', f));
+ Expect.equals('bar-value', div.dataAttributes.putIfAbsent('bar', f));
Expect.isFalse(hasBeenInvoked);
final keys = <String> [];
final values = <String> [];
- div.dataset.forEach(void f(String key, String value) {
+ div.dataAttributes.forEach(void f(String key, String value) {
keys.add(key);
values.add(value);
});
@@ -69,23 +69,23 @@ main() {
Expect.setEquals(const <String> ['foo-value', 'bar-value'], values);
Expect.setEquals(const <String> ['foo', 'bar'],
- new List<String>.from(div.dataset.getKeys()));
+ new List<String>.from(div.dataAttributes.getKeys()));
Expect.setEquals(const <String> ['foo-value', 'bar-value'],
- new List<String>.from(div.dataset.getValues()));
+ new List<String>.from(div.dataAttributes.getValues()));
- Expect.equals(2, div.dataset.length);
- Expect.isFalse(div.dataset.isEmpty());
+ Expect.equals(2, div.dataAttributes.length);
+ Expect.isFalse(div.dataAttributes.isEmpty());
- Expect.isNull(div.dataset.remove('qux'));
- Expect.equals(2, div.dataset.length);
- Expect.isFalse(div.dataset.isEmpty());
+ Expect.isNull(div.dataAttributes.remove('qux'));
+ Expect.equals(2, div.dataAttributes.length);
+ Expect.isFalse(div.dataAttributes.isEmpty());
- Expect.equals('foo-value', div.dataset.remove('foo'));
- Expect.equals(1, div.dataset.length);
- Expect.isFalse(div.dataset.isEmpty());
+ Expect.equals('foo-value', div.dataAttributes.remove('foo'));
+ Expect.equals(1, div.dataAttributes.length);
+ Expect.isFalse(div.dataAttributes.isEmpty());
- div.dataset.clear();
- Expect.equals(0, div.dataset.length);
- Expect.isTrue(div.dataset.isEmpty());
+ div.dataAttributes.clear();
+ Expect.equals(0, div.dataAttributes.length);
+ Expect.isTrue(div.dataAttributes.isEmpty());
});
}

Powered by Google App Engine
This is Rietveld 408576698