| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 @TestOn('browser') | 5 @TestOn('browser') |
| 6 @Skip( | 6 @Skip( |
| 7 "This suite requires a WebSocket server, which is currently unsupported\n" | 7 "This suite requires a WebSocket server, which is currently unsupported\n" |
| 8 "by the test package (dart-lang/test#330). It's currently set up to talk\n" | 8 "by the test package (dart-lang/test#330). It's currently set up to talk\n" |
| 9 "to a hard-coded server on localhost:1234 that is spawned in \n" | 9 "to a hard-coded server on localhost:1234 that is spawned in \n" |
| 10 "html_test_server.dart.") | 10 "html_test_server.dart.") |
| 11 | 11 |
| 12 import 'dart:async'; | 12 import 'dart:async'; |
| 13 import 'dart:html'; | 13 import 'dart:html'; |
| 14 import 'dart:typed_data'; | 14 import 'dart:typed_data'; |
| 15 | 15 |
| 16 import 'package:async/async.dart'; | 16 import 'package:async/async.dart'; |
| 17 import 'package:test/test.dart'; | 17 import 'package:test/test.dart'; |
| 18 | 18 |
| 19 import 'package:web_socket_channel/html.dart'; | 19 import 'package:web_socket_channel/html.dart'; |
| 20 import 'package:web_socket_channel/web_socket_channel.dart'; |
| 20 | 21 |
| 21 void main() { | 22 void main() { |
| 22 var channel; | 23 var channel; |
| 23 tearDown(() { | 24 tearDown(() { |
| 24 if (channel != null) channel.sink.close(); | 25 if (channel != null) channel.sink.close(); |
| 25 }); | 26 }); |
| 26 | 27 |
| 27 test("communicates using an existing WebSocket", () async { | 28 test("communicates using an existing WebSocket", () async { |
| 28 var webSocket = new WebSocket("ws://localhost:1234"); | 29 var webSocket = new WebSocket("ws://localhost:1234"); |
| 29 channel = new HtmlWebSocketChannel(webSocket); | 30 channel = new HtmlWebSocketChannel(webSocket); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 var channel = new HtmlWebSocketChannel.connect("ws://localhost:1235"); | 82 var channel = new HtmlWebSocketChannel.connect("ws://localhost:1235"); |
| 82 expect(channel.stream.toList(), | 83 expect(channel.stream.toList(), |
| 83 throwsA(new isInstanceOf<WebSocketChannelException>())); | 84 throwsA(new isInstanceOf<WebSocketChannelException>())); |
| 84 }); | 85 }); |
| 85 } | 86 } |
| 86 | 87 |
| 87 Future<List<int>> _decodeBlob(Blob blob) async { | 88 Future<List<int>> _decodeBlob(Blob blob) async { |
| 88 var reader = new FileReader(); | 89 var reader = new FileReader(); |
| 89 reader.readAsArrayBuffer(blob); | 90 reader.readAsArrayBuffer(blob); |
| 90 await reader.onLoad.first; | 91 await reader.onLoad.first; |
| 91 return reader.result; | 92 return reader.result as Uint8List; |
| 92 } | 93 } |
| OLD | NEW |