| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "dart:utf"; | 6 import "dart:utf"; |
| 7 import "dart:math"; | 7 import "dart:math"; |
| 8 import "dart:async"; | 8 import "dart:async"; |
| 9 import "dart:collection"; | 9 import "dart:collection"; |
| 10 import "dart:typeddata"; | 10 import "dart:typeddata"; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } else if (count < 65536) { | 83 } else if (count < 65536) { |
| 84 frame[frameIndex++] = 126; | 84 frame[frameIndex++] = 126; |
| 85 frame[frameIndex++] = count >> 8; | 85 frame[frameIndex++] = count >> 8; |
| 86 frame[frameIndex++] = count & 0xFF; | 86 frame[frameIndex++] = count & 0xFF; |
| 87 } else { | 87 } else { |
| 88 frame[frameIndex++] = 127; | 88 frame[frameIndex++] = 127; |
| 89 for (int i = 0; i < 8; i++) { | 89 for (int i = 0; i < 8; i++) { |
| 90 frame[frameIndex++] = count >> ((7 - i) * 8) & 0xFF; | 90 frame[frameIndex++] = count >> ((7 - i) * 8) & 0xFF; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 frame.setRange(frameIndex, count, data, offset); | 93 frame.setRange(frameIndex, frameIndex + count, data, offset); |
| 94 return frame; | 94 return frame; |
| 95 } | 95 } |
| 96 | 96 |
| 97 | 97 |
| 98 // Test processing messages which are sent in a single frame. | 98 // Test processing messages which are sent in a single frame. |
| 99 void testFullMessages() { | 99 void testFullMessages() { |
| 100 void testMessage(int opcode, List<int> message) { | 100 void testMessage(int opcode, List<int> message) { |
| 101 int messageCount = 0; | 101 int messageCount = 0; |
| 102 // Use the same web socket protocol transformer for all frames. | 102 // Use the same web socket protocol transformer for all frames. |
| 103 var transformer = new _WebSocketProtocolTransformer(); | 103 var transformer = new _WebSocketProtocolTransformer(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 true, FRAME_OPCODE_BINARY, null, message, 0, message.length); | 239 true, FRAME_OPCODE_BINARY, null, message, 0, message.length); |
| 240 controller.add(frame); | 240 controller.add(frame); |
| 241 } | 241 } |
| 242 | 242 |
| 243 | 243 |
| 244 void main() { | 244 void main() { |
| 245 testFullMessages(); | 245 testFullMessages(); |
| 246 testFragmentedMessages(); | 246 testFragmentedMessages(); |
| 247 testUnmaskedMessage(); | 247 testUnmaskedMessage(); |
| 248 } | 248 } |
| OLD | NEW |