| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.channel.byte_stream; | 5 library test.channel.byte_stream; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 import 'package:analysis_server/src/channel/byte_stream_channel.dart'; | 11 import 'package:analysis_server/src/channel/byte_stream_channel.dart'; |
| 12 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
| 13 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 13 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 14 | 15 |
| 15 import '../mocks.dart'; | 16 import '../mocks.dart'; |
| 16 | 17 |
| 17 main() { | 18 main() { |
| 18 group('ByteStreamClientChannel', () { | 19 group('ByteStreamClientChannel', () { |
| 19 setUp(ByteStreamClientChannelTest.setUp); | 20 setUp(ByteStreamClientChannelTest.setUp); |
| 20 test('close', ByteStreamClientChannelTest.close); | 21 test('close', ByteStreamClientChannelTest.close); |
| 21 test( | 22 test( |
| 22 'listen_notification', | 23 'listen_notification', |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 234 } |
| 234 | 235 |
| 235 static void setUp() { | 236 static void setUp() { |
| 236 StreamController<List<int>> inputStream = new StreamController<List<int>>(); | 237 StreamController<List<int>> inputStream = new StreamController<List<int>>(); |
| 237 inputSink = new IOSink(inputStream); | 238 inputSink = new IOSink(inputStream); |
| 238 StreamController<List<int>> outputStream = | 239 StreamController<List<int>> outputStream = |
| 239 new StreamController<List<int>>(); | 240 new StreamController<List<int>>(); |
| 240 outputLineStream = outputStream.stream.transform( | 241 outputLineStream = outputStream.stream.transform( |
| 241 (new Utf8Codec()).decoder).transform(new LineSplitter()); | 242 (new Utf8Codec()).decoder).transform(new LineSplitter()); |
| 242 IOSink outputSink = new IOSink(outputStream); | 243 IOSink outputSink = new IOSink(outputStream); |
| 243 channel = new ByteStreamServerChannel(inputStream.stream, outputSink); | 244 channel = new ByteStreamServerChannel( |
| 245 inputStream.stream, |
| 246 outputSink, |
| 247 new NullInstrumentationServer()); |
| 244 StreamController<Request> requestStreamController = | 248 StreamController<Request> requestStreamController = |
| 245 new StreamController<Request>(); | 249 new StreamController<Request>(); |
| 246 requestStream = requestStreamController.stream; | 250 requestStream = requestStreamController.stream; |
| 247 StreamController errorStreamController = new StreamController(); | 251 StreamController errorStreamController = new StreamController(); |
| 248 errorStream = errorStreamController.stream; | 252 errorStream = errorStreamController.stream; |
| 249 Completer doneCompleter = new Completer(); | 253 Completer doneCompleter = new Completer(); |
| 250 doneFuture = doneCompleter.future; | 254 doneFuture = doneCompleter.future; |
| 251 channel.listen((Request request) { | 255 channel.listen((Request request) { |
| 252 requestStreamController.add(request); | 256 requestStreamController.add(request); |
| 253 }, onError: (error) { | 257 }, onError: (error) { |
| 254 errorStreamController.add(error); | 258 errorStreamController.add(error); |
| 255 }, onDone: () { | 259 }, onDone: () { |
| 256 doneCompleter.complete(); | 260 doneCompleter.complete(); |
| 257 }); | 261 }); |
| 258 } | 262 } |
| 259 } | 263 } |
| OLD | NEW |