Index: tests/standalone/io/web_socket_protocol_processor_test.dart |
diff --git a/tests/standalone/io/web_socket_protocol_processor_test.dart b/tests/standalone/io/web_socket_protocol_processor_test.dart |
index 0f7c1fa9040e6d617f47ff9d061f64d4c14e8e0e..5da7212f1b2e87a128749e9a3c510f6309769f30 100644 |
--- a/tests/standalone/io/web_socket_protocol_processor_test.dart |
+++ b/tests/standalone/io/web_socket_protocol_processor_test.dart |
@@ -60,7 +60,7 @@ class WebSocketMessageCollector { |
Function onClosed; |
WebSocketMessageCollector(Stream stream, |
- [List<int> this.expectedMessage = null]) { |
+ [List<int> this.expectedMessage = null]) { |
stream.listen(onMessageData, onDone: onClosed, onError: onError); |
} |
@@ -78,22 +78,15 @@ class WebSocketMessageCollector { |
if (trace != null) msg += "\nStackTrace: $trace"; |
Expect.fail(msg); |
} |
- |
} |
- |
// Web socket constants. |
const int FRAME_OPCODE_TEXT = 1; |
const int FRAME_OPCODE_BINARY = 2; |
- |
// Function for building a web socket frame. |
-List<int> createFrame(bool fin, |
- int opcode, |
- int maskingKey, |
- List<int> data, |
- int offset, |
- int count) { |
+List<int> createFrame(bool fin, int opcode, int maskingKey, List<int> data, |
+ int offset, int count) { |
int frameSize = 2; |
if (count > 125) frameSize += 2; |
if (count > 65535) frameSize += 6; |
@@ -119,7 +112,6 @@ List<int> createFrame(bool fin, |
return frame; |
} |
- |
// Test processing messages which are sent in a single frame. |
void testFullMessages() { |
void testMessage(int opcode, List<int> message) { |
@@ -128,11 +120,10 @@ void testFullMessages() { |
var transformer = new _WebSocketProtocolTransformer(); |
var controller = new StreamController(sync: true); |
WebSocketMessageCollector mc = new WebSocketMessageCollector( |
- controller.stream.transform(transformer), |
- message); |
+ controller.stream.transform(transformer), message); |
- List<int> frame = createFrame( |
- true, opcode, null, message, 0, message.length); |
+ List<int> frame = |
+ createFrame(true, opcode, null, message, 0, message.length); |
// Update the transformer with one big chunk. |
messageCount++; |
@@ -185,14 +176,13 @@ void testFullMessages() { |
runTest(65534, 65537, 1); |
} |
- |
// Test processing of frames which are split into fragments. |
void testFragmentedMessages() { |
// Use the same web socket protocol transformer for all frames. |
var transformer = new _WebSocketProtocolTransformer(); |
var controller = new StreamController(sync: true); |
- WebSocketMessageCollector mc = new WebSocketMessageCollector( |
- controller.stream.transform(transformer)); |
+ WebSocketMessageCollector mc = |
+ new WebSocketMessageCollector(controller.stream.transform(transformer)); |
int messageCount = 0; |
int frameCount = 0; |
@@ -206,12 +196,8 @@ void testFragmentedMessages() { |
while (!lastFrame) { |
int payloadSize = min(fragmentSize, remaining); |
lastFrame = payloadSize == remaining; |
- List<int> frame = createFrame(lastFrame, |
- firstFrame ? opcode : 0x00, |
- null, |
- message, |
- messageIndex, |
- payloadSize); |
+ List<int> frame = createFrame(lastFrame, firstFrame ? opcode : 0x00, null, |
+ message, messageIndex, payloadSize); |
frameCount++; |
messageIndex += payloadSize; |
controller.add(frame); |
@@ -261,12 +247,11 @@ void testUnmaskedMessage() { |
asyncEnd(); |
}); |
var message = new Uint8List(10); |
- List<int> frame = createFrame( |
- true, FRAME_OPCODE_BINARY, null, message, 0, message.length); |
+ List<int> frame = |
+ createFrame(true, FRAME_OPCODE_BINARY, null, message, 0, message.length); |
controller.add(frame); |
} |
- |
void main() { |
testFullMessages(); |
testFragmentedMessages(); |