Files
sdk/runtime/observatory/tests/service/echo_test.dart
T
Ryan Macnak 9f4ffb64ef Partial static mode changes for vm-service and tests (part 2).
Bug: https://github.com/dart-lang/sdk/issues/31587
Change-Id: Ie2605f5043b9f5d2f9156928e3cd39f74e726853
Reviewed-on: https://dart-review.googlesource.com/30681
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-12-20 00:45:28 +00:00

42 lines
1.5 KiB
Dart

// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--error_on_bad_type --error_on_bad_override
import 'dart:async';
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'test_helper.dart';
var tests = <IsolateTest>[
(Isolate isolate) =>
isolate.vm.invokeRpcNoUpgrade('_echo', {'text': 'hello'}).then((result) {
expect(result['type'], equals('_EchoResponse'));
expect(result['text'], equals('hello'));
}),
(Isolate isolate) =>
isolate.invokeRpcNoUpgrade('_echo', {'text': 'hello'}).then((result) {
expect(result['type'], equals('_EchoResponse'));
expect(result['text'], equals('hello'));
}),
(Isolate isolate) async {
Completer completer = new Completer();
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();
});
await isolate.invokeRpc('_triggerEchoEvent', {'text': 'hello'});
await completer.future;
},
];
main(args) => runIsolateTests(args, tests);