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

Side by Side Diff: tests/dom/htmlelement_test.dart

Issue 10178014: Copy lib/dom tests that use dart:html to lib/html. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 years, 7 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 | « tests/dom/htmlcollection_test.dart ('k') | tests/dom/indexeddb_1_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #library('ElementTest');
2 #import('../../lib/unittest/unittest.dart');
3 #import('../../lib/unittest/html_config.dart');
4 #import('dart:html');
5
6 main() {
7 useHtmlConfiguration();
8 test('InnerHTML', () {
9 Element element = new Element.tag('div');
10 element.id = 'test';
11 element.innerHTML = 'Hello World';
12 document.body.nodes.add(element);
13
14 element = document.query('#test');
15 Expect.stringEquals('Hello World', element.innerHTML);
16 element.remove();
17 });
18 test('HTMLTable', () {
19 Element table = new Element.tag('table');
20
21 TableRowElement row = new Element.tag('tr');
22 table.nodes.add(row);
23
24 row.nodes.add(new Element.tag('td'));
25 row.nodes.add(new Element.tag('td'));
26
27 Expect.equals(2, row.cells.length);
28
29 TableRowElement headerRow = table.rows.item(0);
30 Expect.equals(2, headerRow.cells.length);
31 });
32 test('dataAttributes', () {
33 Element div = new Element.tag('div');
34
35 Expect.isTrue(div.dataAttributes.isEmpty());
36 Expect.equals(null, div.dataAttributes['foo']);
37 Expect.isTrue(div.dataAttributes.isEmpty());
38
39 div.dataAttributes['foo'] = 'foo-value';
40 Expect.equals('foo-value', div.dataAttributes['foo']);
41 Expect.isFalse(div.dataAttributes.isEmpty());
42
43 Expect.isTrue(div.dataAttributes.containsValue('foo-value'));
44 Expect.isFalse(div.dataAttributes.containsValue('bar-value'));
45 Expect.isTrue(div.dataAttributes.containsKey('foo'));
46 Expect.isFalse(div.dataAttributes.containsKey('bar'));
47
48 bool hasBeenInvoked;
49 String f() {
50 hasBeenInvoked = true;
51 return 'bar-value';
52 }
53
54 hasBeenInvoked = false;
55 Expect.equals('bar-value', div.dataAttributes.putIfAbsent('bar', f));
56 Expect.isTrue(hasBeenInvoked);
57
58 hasBeenInvoked = false;
59 Expect.equals('bar-value', div.dataAttributes.putIfAbsent('bar', f));
60 Expect.isFalse(hasBeenInvoked);
61
62 final keys = <String> [];
63 final values = <String> [];
64 div.dataAttributes.forEach(void f(String key, String value) {
65 keys.add(key);
66 values.add(value);
67 });
68 Expect.setEquals(const <String> ['foo', 'bar'], keys);
69 Expect.setEquals(const <String> ['foo-value', 'bar-value'], values);
70
71 Expect.setEquals(const <String> ['foo', 'bar'],
72 new List<String>.from(div.dataAttributes.getKeys()));
73 Expect.setEquals(const <String> ['foo-value', 'bar-value'],
74 new List<String>.from(div.dataAttributes.getValues()));
75
76 Expect.equals(2, div.dataAttributes.length);
77 Expect.isFalse(div.dataAttributes.isEmpty());
78
79 Expect.isNull(div.dataAttributes.remove('qux'));
80 Expect.equals(2, div.dataAttributes.length);
81 Expect.isFalse(div.dataAttributes.isEmpty());
82
83 Expect.equals('foo-value', div.dataAttributes.remove('foo'));
84 Expect.equals(1, div.dataAttributes.length);
85 Expect.isFalse(div.dataAttributes.isEmpty());
86
87 div.dataAttributes.clear();
88 Expect.equals(0, div.dataAttributes.length);
89 Expect.isTrue(div.dataAttributes.isEmpty());
90 });
91 }
OLDNEW
« no previous file with comments | « tests/dom/htmlcollection_test.dart ('k') | tests/dom/indexeddb_1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698