| 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; | 5 library test.channel; |
| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 test('invalidJsonToClient', WebSocketChannelTest.invalidJsonToClient); | 21 test('invalidJsonToClient', WebSocketChannelTest.invalidJsonToClient); |
| 22 test('invalidJsonToServer', WebSocketChannelTest.invalidJsonToServer); | 22 test('invalidJsonToServer', WebSocketChannelTest.invalidJsonToServer); |
| 23 test('notification', WebSocketChannelTest.notification); | 23 test('notification', WebSocketChannelTest.notification); |
| 24 test('notificationAndResponse', WebSocketChannelTest.notificationAndResponse
); | 24 test('notificationAndResponse', WebSocketChannelTest.notificationAndResponse
); |
| 25 test('request', WebSocketChannelTest.request); | 25 test('request', WebSocketChannelTest.request); |
| 26 test('requestResponse', WebSocketChannelTest.requestResponse); | 26 test('requestResponse', WebSocketChannelTest.requestResponse); |
| 27 test('response', WebSocketChannelTest.response); | 27 test('response', WebSocketChannelTest.response); |
| 28 }); | 28 }); |
| 29 group('ByteStreamServerChannel', () { | 29 group('ByteStreamServerChannel', () { |
| 30 setUp(ByteStreamServerChannelTest.setUp); | 30 setUp(ByteStreamServerChannelTest.setUp); |
| 31 test('closed', ByteStreamServerChannelTest.closed); |
| 31 test('listen_wellFormedRequest', | 32 test('listen_wellFormedRequest', |
| 32 ByteStreamServerChannelTest.listen_wellFormedRequest); | 33 ByteStreamServerChannelTest.listen_wellFormedRequest); |
| 33 test('listen_invalidRequest', | 34 test('listen_invalidRequest', |
| 34 ByteStreamServerChannelTest.listen_invalidRequest); | 35 ByteStreamServerChannelTest.listen_invalidRequest); |
| 35 test('listen_invalidJson', ByteStreamServerChannelTest.listen_invalidJson); | 36 test('listen_invalidJson', ByteStreamServerChannelTest.listen_invalidJson); |
| 36 test('listen_streamError', ByteStreamServerChannelTest.listen_streamError); | 37 test('listen_streamError', ByteStreamServerChannelTest.listen_streamError); |
| 37 test('listen_streamDone', ByteStreamServerChannelTest.listen_streamDone); | 38 test('listen_streamDone', ByteStreamServerChannelTest.listen_streamDone); |
| 38 test('sendNotification', ByteStreamServerChannelTest.sendNotification); | 39 test('sendNotification', ByteStreamServerChannelTest.sendNotification); |
| 39 test('sendResponse', ByteStreamServerChannelTest.sendResponse); | 40 test('sendResponse', ByteStreamServerChannelTest.sendResponse); |
| 40 }); | 41 }); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 doneFuture = doneCompleter.future; | 220 doneFuture = doneCompleter.future; |
| 220 channel.listen((Request request) { | 221 channel.listen((Request request) { |
| 221 requestStreamController.add(request); | 222 requestStreamController.add(request); |
| 222 }, onError: (error) { | 223 }, onError: (error) { |
| 223 errorStreamController.add(error); | 224 errorStreamController.add(error); |
| 224 }, onDone: () { | 225 }, onDone: () { |
| 225 doneCompleter.complete(); | 226 doneCompleter.complete(); |
| 226 }); | 227 }); |
| 227 } | 228 } |
| 228 | 229 |
| 230 static Future closed() { |
| 231 return inputSink.close().then((_) => channel.closed.timeout(new Duration( |
| 232 seconds: 1))); |
| 233 } |
| 234 |
| 229 static Future listen_wellFormedRequest() { | 235 static Future listen_wellFormedRequest() { |
| 230 inputSink.writeln('{"id":"0","method":"server.version"}'); | 236 inputSink.writeln('{"id":"0","method":"server.version"}'); |
| 231 return inputSink.flush().then((_) => requestStream.first.timeout( | 237 return inputSink.flush().then((_) => requestStream.first.timeout( |
| 232 new Duration(seconds: 1))).then((Request request) { | 238 new Duration(seconds: 1))).then((Request request) { |
| 233 expect(request.id, equals("0")); | 239 expect(request.id, equals("0")); |
| 234 expect(request.method, equals("server.version")); | 240 expect(request.method, equals("server.version")); |
| 235 }); | 241 }); |
| 236 } | 242 } |
| 237 | 243 |
| 238 static Future listen_invalidRequest() { | 244 static Future listen_invalidRequest() { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 channel.sendResponse(new Response('foo')); | 292 channel.sendResponse(new Response('foo')); |
| 287 return outputLineStream.first.timeout(new Duration(seconds: 1)).then((String | 293 return outputLineStream.first.timeout(new Duration(seconds: 1)).then((String |
| 288 response) { | 294 response) { |
| 289 var jsonResponse = new JsonCodec().decode(response); | 295 var jsonResponse = new JsonCodec().decode(response); |
| 290 expect(jsonResponse, isMap); | 296 expect(jsonResponse, isMap); |
| 291 expect(jsonResponse, contains('id')); | 297 expect(jsonResponse, contains('id')); |
| 292 expect(jsonResponse['id'], equals('foo')); | 298 expect(jsonResponse['id'], equals('foo')); |
| 293 }); | 299 }); |
| 294 } | 300 } |
| 295 } | 301 } |
| OLD | NEW |