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

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

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

Powered by Google App Engine
This is Rietveld 408576698