Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1403)

Unified Diff: tests/standalone/io/web_socket_protocol_processor_test.dart

Issue 14696012: Make web-socket pass AutobanhTestSuite. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 39f9d91eb0774ec70b4b3ba94b3e0c73da1ea16a..b655b13e1598b4391d467c15f0ced8ac79241c2e 100644
--- a/tests/standalone/io/web_socket_protocol_processor_test.dart
+++ b/tests/standalone/io/web_socket_protocol_processor_test.dart
@@ -28,10 +28,11 @@ class WebSocketMessageCollector {
List<int> expectedMessage;
int messageCount = 0;
- int closeCount = 0;
var data;
+ Function onClosed;
+
WebSocketMessageCollector(Stream stream,
[List<int> this.expectedMessage = null]) {
stream.listen(onMessageData, onDone: onClosed, onError: onError);
@@ -46,10 +47,6 @@ class WebSocketMessageCollector {
data = buffer;
}
- void onClosed() {
- closeCount++;
- }
-
void onError(e) {
String msg = "Unexpected error $e";
var trace = getAttachedStackTrace(e);
@@ -78,7 +75,7 @@ List<int> createFrame(bool fin,
frameSize += count;
// No masking.
assert(maskingKey == null);
- List<int> frame = new List<int>(frameSize);
+ List<int> frame = new Uint8List(frameSize);
int frameIndex = 0;
frame[frameIndex++] = (fin ? 0x80 : 0x00) | opcode;
if (count < 126) {
@@ -115,33 +112,35 @@ void testFullMessages() {
// Update the transformer with one big chunk.
messageCount++;
controller.add(frame);
- Expect.isNotNull(mc.data);
- Expect.equals(0, transformer._state);
-
- mc.data = null;
-
- // Only run this part on small messages.
- if (message.length < 1000) {
- // Update the transformer one byte at the time.
- messageCount++;
- for (int i = 0; i < frame.length; i++) {
- controller.add(<int>[frame[i]]);
- }
- Expect.equals(0, transformer._state);
+ mc.onClosed = () {
Expect.isNotNull(mc.data);
+ Expect.equals(0, transformer._state);
+
mc.data = null;
- // Update the transformer two bytes at the time.
- messageCount++;
- for (int i = 0; i < frame.length; i += 2) {
- controller.add(frame.sublist(i, min(i + 2, frame.length)));
+ // Only run this part on small messages.
+ if (message.length < 1000) {
+ // Update the transformer one byte at the time.
+ messageCount++;
+ for (int i = 0; i < frame.length; i++) {
+ controller.add(<int>[frame[i]]);
+ }
+ Expect.equals(0, transformer._state);
+ Expect.isNotNull(mc.data);
+ mc.data = null;
+
+ // Update the transformer two bytes at the time.
+ messageCount++;
+ for (int i = 0; i < frame.length; i += 2) {
+ controller.add(frame.sublist(i, min(i + 2, frame.length)));
+ }
+ Expect.equals(0, transformer._state);
+ Expect.isNotNull(mc.data);
}
- Expect.equals(0, transformer._state);
- Expect.isNotNull(mc.data);
- }
- Expect.equals(messageCount, mc.messageCount);
- Expect.equals(0, mc.closeCount);
- print("Messages test, messages $messageCount");
+ Expect.equals(messageCount, mc.messageCount);
+ print("Messages test, messages $messageCount");
+ };
+ controller.close();
}
void runTest(int from, int to, int step) {
@@ -227,7 +226,6 @@ void testFragmentedMessages() {
runTest(65534, 65537, 1);
print("Fragment messages test, messages $messageCount, frames $frameCount");
Expect.equals(messageCount, mc.messageCount);
- Expect.equals(0, mc.closeCount);
}
void testUnmaskedMessage() {
« sdk/lib/io/websocket_impl.dart ('K') | « tests/standalone/io/string_decoder_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698