OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "dart:convert"; | 5 import "dart:convert"; |
6 import "dart:math"; | 6 import "dart:math"; |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:collection"; | 8 import "dart:collection"; |
9 import "dart:typed_data"; | 9 import "dart:typed_data"; |
10 import "dart:isolate"; | 10 import "dart:isolate"; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 void onMessageData(buffer) { | 44 void onMessageData(buffer) { |
45 if (buffer is String) { | 45 if (buffer is String) { |
46 buffer = UTF8.encode(buffer); | 46 buffer = UTF8.encode(buffer); |
47 } | 47 } |
48 Expect.listEquals(expectedMessage, buffer); | 48 Expect.listEquals(expectedMessage, buffer); |
49 messageCount++; | 49 messageCount++; |
50 data = buffer; | 50 data = buffer; |
51 } | 51 } |
52 | 52 |
53 void onError(e) { | 53 void onError(e, trace) { |
54 String msg = "Unexpected error $e"; | 54 String msg = "Unexpected error $e"; |
55 var trace = getAttachedStackTrace(e); | |
56 if (trace != null) msg += "\nStackTrace: $trace"; | 55 if (trace != null) msg += "\nStackTrace: $trace"; |
57 Expect.fail(msg); | 56 Expect.fail(msg); |
58 } | 57 } |
59 | 58 |
60 } | 59 } |
61 | 60 |
62 | 61 |
63 // Web socket constants. | 62 // Web socket constants. |
64 const int FRAME_OPCODE_TEXT = 1; | 63 const int FRAME_OPCODE_TEXT = 1; |
65 const int FRAME_OPCODE_BINARY = 2; | 64 const int FRAME_OPCODE_BINARY = 2; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 true, FRAME_OPCODE_BINARY, null, message, 0, message.length); | 242 true, FRAME_OPCODE_BINARY, null, message, 0, message.length); |
244 controller.add(frame); | 243 controller.add(frame); |
245 } | 244 } |
246 | 245 |
247 | 246 |
248 void main() { | 247 void main() { |
249 testFullMessages(); | 248 testFullMessages(); |
250 testFragmentedMessages(); | 249 testFragmentedMessages(); |
251 testUnmaskedMessage(); | 250 testUnmaskedMessage(); |
252 } | 251 } |
OLD | NEW |