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

Side by Side Diff: test/web_socket_test.dart

Issue 1168803003: Don't double-close a WebSocket in web_socket_test. (Closed) Base URL: git@github.com:dart-lang/http_parser@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library http_parser.web_socket_test; 5 library http_parser.web_socket_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:http_parser/http_parser.dart'; 9 import 'package:http_parser/http_parser.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
11 11
12 void main() { 12 void main() {
13 test("a client can communicate with a WebSocket server", () { 13 test("a client can communicate with a WebSocket server", () {
14 return HttpServer.bind("localhost", 0).then((server) { 14 return HttpServer.bind("localhost", 0).then((server) {
15 server.transform(new WebSocketTransformer()).listen((webSocket) { 15 server.transform(new WebSocketTransformer()).listen((webSocket) {
16 webSocket.add("hello!"); 16 webSocket.add("hello!");
17 webSocket.first.then((request) { 17 webSocket.listen((request) {
18 expect(request, equals("ping")); 18 expect(request, equals("ping"));
19 webSocket.add("pong"); 19 webSocket.add("pong");
20 webSocket.close(); 20 webSocket.close();
21 }); 21 });
22 }); 22 });
23 23
24 var client = new HttpClient(); 24 var client = new HttpClient();
25 return client 25 return client
26 .openUrl("GET", Uri.parse("http://localhost:${server.port}")) 26 .openUrl("GET", Uri.parse("http://localhost:${server.port}"))
27 .then((request) { 27 .then((request) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 server.close(); 88 server.close();
89 } else { 89 } else {
90 fail("Only expected two messages."); 90 fail("Only expected two messages.");
91 } 91 }
92 n++; 92 n++;
93 }).asFuture(); 93 }).asFuture();
94 }); 94 });
95 }); 95 });
96 }); 96 });
97 } 97 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698