| OLD | NEW |
| 1 library streams_test; | 1 library streams_test; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
| 4 import 'dart:async'; | 4 import 'dart:async'; |
| 5 import 'dart:html'; | 5 import 'dart:html'; |
| 6 | 6 |
| 7 class StreamHelper { | 7 class StreamHelper { |
| 8 var _a; | 8 var _a; |
| 9 StreamHelper() { | 9 StreamHelper() { |
| 10 _a = new TextInputElement(); | 10 _a = new TextInputElement(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 expect(callCount, 1); | 80 expect(callCount, 1); |
| 81 | 81 |
| 82 subscription.cancel(); | 82 subscription.cancel(); |
| 83 helper.pulse(); | 83 helper.pulse(); |
| 84 expect(callCount, 1); | 84 expect(callCount, 1); |
| 85 | 85 |
| 86 expect(() { | 86 expect(() { |
| 87 subscription.onData((_) {}); | 87 subscription.onData((_) {}); |
| 88 }, throws); | 88 }, throws); |
| 89 | 89 |
| 90 expect(() { | 90 // Calling these after a cancel does nothing. |
| 91 subscription.pause(); | 91 subscription.cancel(); |
| 92 }, throws); | 92 subscription.pause(); |
| 93 | 93 subscription.resume(); |
| 94 expect(() { | |
| 95 subscription.resume(); | |
| 96 }, throws); | |
| 97 }); | 94 }); |
| 98 | 95 |
| 99 test('pause/resume', () { | 96 test('pause/resume', () { |
| 100 var helper = new StreamHelper(); | 97 var helper = new StreamHelper(); |
| 101 | 98 |
| 102 var callCount = 0; | 99 var callCount = 0; |
| 103 var subscription = helper.stream.listen((_) { | 100 var subscription = helper.stream.listen((_) { |
| 104 ++callCount; | 101 ++callCount; |
| 105 }); | 102 }); |
| 106 | 103 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 subscription.pause(); | 121 subscription.pause(); |
| 125 helper.pulse(); | 122 helper.pulse(); |
| 126 subscription.resume(); | 123 subscription.resume(); |
| 127 helper.pulse(); | 124 helper.pulse(); |
| 128 expect(callCount, 2); | 125 expect(callCount, 2); |
| 129 | 126 |
| 130 completer.complete(0); | 127 completer.complete(0); |
| 131 helper.pulse(); | 128 helper.pulse(); |
| 132 expect(callCount, 3); | 129 expect(callCount, 3); |
| 133 | 130 |
| 134 // Not paused. | 131 // Not paused, but resuming once too often is ok. |
| 135 expect(() { | 132 subscription.resume(); |
| 136 subscription.resume(); | |
| 137 }, throws); | |
| 138 }); | 133 }); |
| 139 | 134 |
| 140 test('onData', () { | 135 test('onData', () { |
| 141 var helper = new StreamHelper(); | 136 var helper = new StreamHelper(); |
| 142 | 137 |
| 143 var callCountOne = 0; | 138 var callCountOne = 0; |
| 144 var subscription = helper.stream.listen((_) { | 139 var subscription = helper.stream.listen((_) { |
| 145 ++callCountOne; | 140 ++callCountOne; |
| 146 }); | 141 }); |
| 147 | 142 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 }); | 271 }); |
| 277 | 272 |
| 278 test('singleWhere', () { | 273 test('singleWhere', () { |
| 279 stream.singleWhere((_) => true).then((_) {}); | 274 stream.singleWhere((_) => true).then((_) {}); |
| 280 }); | 275 }); |
| 281 | 276 |
| 282 test('elementAt', () { | 277 test('elementAt', () { |
| 283 stream.elementAt(0).then((_) {}); | 278 stream.elementAt(0).then((_) {}); |
| 284 }); | 279 }); |
| 285 } | 280 } |
| OLD | NEW |