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

Unified Diff: test/client/stream_test.dart

Issue 1652413002: Use StreamChannel. (Closed) Base URL: git@github.com:dart-lang/json_rpc_2.git@master
Patch Set: Code review changes Created 4 years, 11 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
« no previous file with comments | « pubspec.yaml ('k') | test/client/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/client/stream_test.dart
diff --git a/test/client/stream_test.dart b/test/client/stream_test.dart
index 146e75359ab49dd5103a722b55f4dbfe369d886b..b9a31c679d9f3acc9d86e063ddbc56539b25e5b9 100644
--- a/test/client/stream_test.dart
+++ b/test/client/stream_test.dart
@@ -4,17 +4,25 @@
import 'dart:async';
+import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';
+
import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc;
import 'utils.dart';
void main() {
+ var responseController;
+ var requestController;
+ var client;
+ setUp(() {
+ responseController = new StreamController();
+ requestController = new StreamController();
+ client = new json_rpc.Client.withoutJson(
+ new StreamChannel(responseController.stream, requestController.sink));
+ });
+
test(".withoutJson supports decoded stream and sink", () {
- var responseController = new StreamController();
- var requestController = new StreamController();
- var client = new json_rpc.Client.withoutJson(
- responseController.stream, requestController.sink);
client.listen();
expect(requestController.stream.first.then((request) {
@@ -34,11 +42,6 @@ void main() {
});
test(".listen returns when the controller is closed", () {
- var responseController = new StreamController();
- var requestController = new StreamController();
- var client = new json_rpc.Client.withoutJson(
- responseController.stream, requestController.sink);
-
var hasListenCompeted = false;
expect(client.listen().then((_) => hasListenCompeted = true), completes);
@@ -51,30 +54,18 @@ void main() {
});
test(".listen returns a stream error", () {
- var responseController = new StreamController();
- var requestController = new StreamController();
- var client = new json_rpc.Client(
- responseController.stream, requestController.sink);
-
expect(client.listen(), throwsA('oh no'));
responseController.addError('oh no');
});
test(".listen can't be called twice", () {
- var responseController = new StreamController();
- var requestController = new StreamController();
- var client = new json_rpc.Client(
- responseController.stream, requestController.sink);
client.listen();
-
expect(() => client.listen(), throwsStateError);
});
test(".close cancels the stream subscription and closes the sink", () {
- var responseController = new StreamController();
- var requestController = new StreamController();
- var client = new json_rpc.Client(
- responseController.stream, requestController.sink);
+ // Work around sdk#19095.
+ requestController.stream.listen(null);
expect(client.listen(), completes);
@@ -85,13 +76,4 @@ void main() {
expect(() => responseController.stream.listen((_) {}), throwsStateError);
expect(requestController.isClosed, isTrue);
});
-
- test(".close can't be called before .listen", () {
- var responseController = new StreamController();
- var requestController = new StreamController();
- var client = new json_rpc.Client(
- responseController.stream, requestController.sink);
-
- expect(() => client.close(), throwsStateError);
- });
}
« no previous file with comments | « pubspec.yaml ('k') | test/client/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698