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

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

Issue 1390353005: Web Socket compression - take two (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix observatory issues Created 5 years, 1 month 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
« no previous file with comments | « tests/standalone/io/web_socket_compression_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/web_socket_typed_data_test.dart
diff --git a/tests/standalone/io/web_socket_typed_data_test.dart b/tests/standalone/io/web_socket_typed_data_test.dart
index d65bedc947520c727b9d755ad43db351b6e7b7e0..571b57d70327d2662fc91c4d96ec7344e367b4b8 100644
--- a/tests/standalone/io/web_socket_typed_data_test.dart
+++ b/tests/standalone/io/web_socket_typed_data_test.dart
@@ -15,13 +15,17 @@ import "dart:typed_data";
Future<HttpServer> createServer() => HttpServer.bind("127.0.0.1", 0);
-Future<WebSocket> createClient(int port) =>
- WebSocket.connect('ws://127.0.0.1:$port/');
+Future<WebSocket> createClient(int port, bool compression) =>
+ compression ? WebSocket.connect('ws://127.0.0.1:$port/')
+ : WebSocket.connect('ws://127.0.0.1:$port/',
+ compression: CompressionOptions.OFF);
-void test(expected, testData) {
+void test(expected, testData, compression) {
createServer().then((server) {
var messageCount = 0;
- server.transform(new WebSocketTransformer()).listen((webSocket) {
+ var transformer = compression ? new WebSocketTransformer()
+ : new WebSocketTransformer(compression: CompressionOptions.OFF);
+ server.transform(transformer).listen((webSocket) {
webSocket.listen(
(message) {
Expect.listEquals(expected, message);
@@ -31,7 +35,7 @@ void test(expected, testData) {
onDone: () => Expect.equals(testData.length, messageCount));
});
- createClient(server.port).then((webSocket) {
+ createClient(server.port, compression).then((webSocket) {
var messageCount = 0;
webSocket.listen(
(message) {
@@ -45,7 +49,7 @@ void test(expected, testData) {
});
}
-testUintLists() {
+testUintLists({bool compression: false}) {
var fillData = new List.generate(256, (index) => index);
var testData = [
new Uint8List(256),
@@ -55,10 +59,10 @@ testUintLists() {
new Uint64List(256),
];
testData.forEach((list) => list.setAll(0, fillData));
- test(fillData, testData);
+ test(fillData, testData, compression);
}
-testIntLists() {
+testIntLists({bool compression: false}) {
var fillData = new List.generate(128, (index) => index);
var testData = [
new Int8List(128),
@@ -67,18 +71,20 @@ testIntLists() {
new Int64List(128),
];
testData.forEach((list) => list.setAll(0, fillData));
- test(fillData, testData);
+ test(fillData, testData, compression);
}
-void testOutOfRangeClient() {
+void testOutOfRangeClient({bool compression: false}) {
createServer().then((server) {
var messageCount = 0;
- server.transform(new WebSocketTransformer()).listen((webSocket) {
+ var transformer = compression ? new WebSocketTransformer()
+ : new WebSocketTransformer(compression: CompressionOptions.OFF);
+ server.transform(transformer).listen((webSocket) {
webSocket.listen((message) => Expect.fail("No message expected"));
});
Future clientError(data) {
- return createClient(server.port).then((webSocket) {
+ return createClient(server.port, compression).then((webSocket) {
var messageCount = 0;
webSocket.listen((message) => Expect.fail("No message expected"));
webSocket.add(data);
@@ -129,7 +135,7 @@ void testOutOfRangeClient() {
});
}
-void testOutOfRangeServer() {
+void testOutOfRangeServer({bool compression: false}) {
var futures = [];
var testData = [];
var data;
@@ -175,7 +181,9 @@ void testOutOfRangeServer() {
createServer().then((server) {
var messageCount = 0;
- server.transform(new WebSocketTransformer()).listen((webSocket) {
+ var transformer = compression ? new WebSocketTransformer()
+ : new WebSocketTransformer(compression: CompressionOptions.OFF);
+ server.transform(transformer).listen((webSocket) {
webSocket.listen((message) {
messageCount++;
webSocket.add(testData[message[0]]);
@@ -187,7 +195,7 @@ void testOutOfRangeServer() {
Future x(int i) {
var completer = new Completer();
- createClient(server.port).then((webSocket) {
+ createClient(server.port, compression).then((webSocket) {
webSocket.listen((message) => Expect.fail("No message expected"),
onDone: () => completer.complete(true),
onError: (e) => completer.completeError(e));
@@ -204,7 +212,11 @@ void testOutOfRangeServer() {
main() {
testUintLists();
+ testUintLists(compression: true);
testIntLists();
+ testIntLists(compression: true);
testOutOfRangeClient();
+ testOutOfRangeClient(compression: true);
// testOutOfRangeServer();
+ // testOutOfRangeServer(compression: true);
}
« no previous file with comments | « tests/standalone/io/web_socket_compression_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698