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

Unified Diff: runtime/observatory/tests/service/echo_test.dart

Issue 1217823009: Make VM event streams look like real dart streams. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Polish Created 5 years, 5 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: runtime/observatory/tests/service/echo_test.dart
diff --git a/runtime/observatory/tests/service/echo_test.dart b/runtime/observatory/tests/service/echo_test.dart
index eab58882b5e12ec473d596fb882b918a6f8129c4..39b365138fe871a94f77358627874b2c9e0931ec 100644
--- a/runtime/observatory/tests/service/echo_test.dart
+++ b/runtime/observatory/tests/service/echo_test.dart
@@ -22,19 +22,22 @@ var tests = [
expect(result['text'], equals('hello'));
}),
-(Isolate isolate) {
+(Isolate isolate) async {
Completer completer = new Completer();
- isolate.vm.events.stream.listen((ServiceEvent event) {
- if (event.kind == '_Echo') {
- expect(event.data.lengthInBytes, equals(3));
- expect(event.data.getUint8(0), equals(0));
- expect(event.data.getUint8(1), equals(128));
- expect(event.data.getUint8(2), equals(255));
- completer.complete();
- }
+ var stream = await isolate.vm.getEventStream('_Echo');
+ var subscription;
+ subscription = stream.listen((ServiceEvent event) {
+ assert(event.kind == '_Echo');
+ expect(event.data.lengthInBytes, equals(3));
+ expect(event.data.getUint8(0), equals(0));
+ expect(event.data.getUint8(1), equals(128));
+ expect(event.data.getUint8(2), equals(255));
+ subscription.cancel();
+ completer.complete();
});
- isolate.invokeRpc('_triggerEchoEvent', { 'text': 'hello' });
- return completer.future;
+
+ await isolate.invokeRpc('_triggerEchoEvent', { 'text': 'hello' });
+ await completer.future;
},
];

Powered by Google App Engine
This is Rietveld 408576698