@@ -8,14 +8,15 @@ import 'package:async/async.dart';
8
8
import 'package:stream_channel/stream_channel.dart' ;
9
9
import 'package:test/test.dart' ;
10
10
import 'package:web_socket/web_socket.dart' ;
11
+ import 'package:web_socket_channel/adapter_web_socket_channel.dart' ;
11
12
import 'package:web_socket_channel/src/exception.dart' ;
12
- import 'package:web_socket_channel/web_socket_adapter_web_socket_channel.dart' ;
13
13
import 'package:web_socket_channel/web_socket_channel.dart' ;
14
+
14
15
import 'echo_server_vm.dart'
15
16
if (dart.library.js_interop) 'echo_server_web.dart' ;
16
17
17
18
void main () {
18
- group ('WebSocketWebSocketChannelAdapter ' , () {
19
+ group ('AdapterWebSocketChannel ' , () {
19
20
late Uri uri;
20
21
late StreamChannel <Object ?> httpServerChannel;
21
22
late StreamQueue <Object ?> httpServerQueue;
@@ -34,52 +35,52 @@ void main() {
34
35
35
36
test ('failed connect' , () async {
36
37
final channel =
37
- WebSocketAdapterWebSocketChannel .connect (Uri .parse ('ws://notahost' ));
38
+ AdapterWebSocketChannel .connect (Uri .parse ('ws://notahost' ));
38
39
39
40
await expectLater (
40
41
channel.ready, throwsA (isA <WebSocketChannelException >()));
41
42
});
42
43
43
44
test ('good connect' , () async {
44
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
45
+ final channel = AdapterWebSocketChannel .connect (uri);
45
46
await expectLater (channel.ready, completes);
46
47
await channel.sink.close ();
47
48
});
48
49
49
50
test ('echo empty text' , () async {
50
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
51
+ final channel = AdapterWebSocketChannel .connect (uri);
51
52
await expectLater (channel.ready, completes);
52
53
channel.sink.add ('' );
53
54
expect (await channel.stream.first, '' );
54
55
await channel.sink.close ();
55
56
});
56
57
57
58
test ('echo empty binary' , () async {
58
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
59
+ final channel = AdapterWebSocketChannel .connect (uri);
59
60
await expectLater (channel.ready, completes);
60
61
channel.sink.add (Uint8List .fromList (< int > []));
61
62
expect (await channel.stream.first, isEmpty);
62
63
await channel.sink.close ();
63
64
});
64
65
65
66
test ('echo hello' , () async {
66
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
67
+ final channel = AdapterWebSocketChannel .connect (uri);
67
68
await expectLater (channel.ready, completes);
68
69
channel.sink.add ('hello' );
69
70
expect (await channel.stream.first, 'hello' );
70
71
await channel.sink.close ();
71
72
});
72
73
73
74
test ('echo [1,2,3]' , () async {
74
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
75
+ final channel = AdapterWebSocketChannel .connect (uri);
75
76
await expectLater (channel.ready, completes);
76
77
channel.sink.add ([1 , 2 , 3 ]);
77
78
expect (await channel.stream.first, [1 , 2 , 3 ]);
78
79
await channel.sink.close ();
79
80
});
80
81
81
82
test ('alternative string and binary request and response' , () async {
82
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
83
+ final channel = AdapterWebSocketChannel .connect (uri);
83
84
await expectLater (channel.ready, completes);
84
85
channel.sink.add ('This count says:' );
85
86
channel.sink.add ([1 , 2 , 3 ]);
@@ -94,7 +95,7 @@ void main() {
94
95
});
95
96
96
97
test ('remote close' , () async {
97
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
98
+ final channel = AdapterWebSocketChannel .connect (uri);
98
99
await expectLater (channel.ready, completes);
99
100
channel.sink.add ('close' ); // Asks the peer to close.
100
101
// Give the server time to send a close frame.
@@ -105,7 +106,7 @@ void main() {
105
106
});
106
107
107
108
test ('local close' , () async {
108
- final channel = WebSocketAdapterWebSocketChannel .connect (uri);
109
+ final channel = AdapterWebSocketChannel .connect (uri);
109
110
await expectLater (channel.ready, completes);
110
111
await channel.sink.close (3005 , 'please close' );
111
112
expect (channel.closeCode, null );
@@ -114,7 +115,7 @@ void main() {
114
115
115
116
test ('constructor with WebSocket' , () async {
116
117
final webSocket = await WebSocket .connect (uri);
117
- final channel = WebSocketAdapterWebSocketChannel (webSocket);
118
+ final channel = AdapterWebSocketChannel (webSocket);
118
119
119
120
await expectLater (channel.ready, completes);
120
121
channel.sink.add ('This count says:' );
@@ -131,7 +132,7 @@ void main() {
131
132
132
133
test ('constructor with Future<WebSocket>' , () async {
133
134
final webSocketFuture = WebSocket .connect (uri);
134
- final channel = WebSocketAdapterWebSocketChannel (webSocketFuture);
135
+ final channel = AdapterWebSocketChannel (webSocketFuture);
135
136
136
137
await expectLater (channel.ready, completes);
137
138
channel.sink.add ('This count says:' );
0 commit comments