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

Side by Side Diff: tests/standalone/io/web_socket_pipe_test.dart

Issue 25354003: Redo StreamTransformers so they work with Stack traces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/async/stream_transformer_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:async"; 11 import "dart:async";
12 import "dart:io"; 12 import "dart:io";
13 13
14 class IdentityTransformer extends StreamEventTransformer { 14 createReverseStringTransformer() {
15 void handleData(data, sink) => sink.add(data); 15 return new StreamTransformer.fromHandlers(
16 } 16 handleData: (String data, sink) {
17 17 var sb = new StringBuffer();
18 class ReverseStringTransformer extends StreamEventTransformer { 18 for (int i = data.length - 1; i >= 0; i--) sb.write(data[i]);
19 void handleData(String data, sink) { 19 sink.add(sb.toString());
20 var sb = new StringBuffer(); 20 });
21 for (int i = data.length - 1; i >= 0; i--) sb.write(data[i]);
22 sink.add(sb.toString());
23 }
24 } 21 }
25 22
26 testPipe({int messages, bool transform}) { 23 testPipe({int messages, bool transform}) {
27 HttpServer.bind("127.0.0.1", 0).then((server) { 24 HttpServer.bind("127.0.0.1", 0).then((server) {
28 server.listen((request) { 25 server.listen((request) {
29 WebSocketTransformer.upgrade(request).then((websocket) { 26 WebSocketTransformer.upgrade(request).then((websocket) {
30 (transform ? websocket.transform(new ReverseStringTransformer()) 27 (transform ? websocket.transform(createReverseStringTransformer())
31 : websocket) 28 : websocket)
32 .pipe(websocket) 29 .pipe(websocket)
33 .then((_) => server.close()); 30 .then((_) => server.close());
34 }); 31 });
35 }); 32 });
36 WebSocket.connect("ws://127.0.0.1:${server.port}/").then((client) { 33 WebSocket.connect("ws://127.0.0.1:${server.port}/").then((client) {
37 var count = 0; 34 var count = 0;
38 next() { 35 next() {
39 if (count < messages) { 36 if (count < messages) {
40 client.add("Hello"); 37 client.add("Hello");
(...skipping 19 matching lines...) Expand all
60 } 57 }
61 58
62 void main() { 59 void main() {
63 testPipe(messages: 0, transform: false); 60 testPipe(messages: 0, transform: false);
64 testPipe(messages: 0, transform: true); 61 testPipe(messages: 0, transform: true);
65 testPipe(messages: 1, transform: false); 62 testPipe(messages: 1, transform: false);
66 testPipe(messages: 1, transform: true); 63 testPipe(messages: 1, transform: true);
67 testPipe(messages: 10, transform: false); 64 testPipe(messages: 10, transform: false);
68 testPipe(messages: 10, transform: true); 65 testPipe(messages: 10, transform: true);
69 } 66 }
OLDNEW
« no previous file with comments | « tests/lib/async/stream_transformer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698