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

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

Issue 11865005: Remove Futures class, move methods to Future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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/standalone/io/http_auth_test.dart ('k') | tools/html_json_doc/lib/html_to_json.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 const SESSION_ID = "DARTSESSID"; 8 const SESSION_ID = "DARTSESSID";
9 9
10 String getSessionId(List<Cookie> cookies) { 10 String getSessionId(List<Cookie> cookies) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 futures.add(connectGetSession(server.port).then((session) { 54 futures.add(connectGetSession(server.port).then((session) {
55 Expect.isNotNull(session); 55 Expect.isNotNull(session);
56 Expect.isTrue(sessions.contains(session)); 56 Expect.isTrue(sessions.contains(session));
57 return connectGetSession(server.port, session).then((session2) { 57 return connectGetSession(server.port, session).then((session2) {
58 Expect.equals(session2, session); 58 Expect.equals(session2, session);
59 Expect.isTrue(sessions.contains(session2)); 59 Expect.isTrue(sessions.contains(session2));
60 return session2; 60 return session2;
61 }); 61 });
62 })); 62 }));
63 } 63 }
64 Futures.wait(futures).then((clientSessions) { 64 Future.wait(futures).then((clientSessions) {
65 Expect.equals(sessions.length, sessionCount); 65 Expect.equals(sessions.length, sessionCount);
66 Expect.setEquals(new Set.from(clientSessions), sessions); 66 Expect.setEquals(new Set.from(clientSessions), sessions);
67 server.close(); 67 server.close();
68 }); 68 });
69 } 69 }
70 70
71 void testTimeout(int sessionCount) { 71 void testTimeout(int sessionCount) {
72 HttpServer server = new HttpServer(); 72 HttpServer server = new HttpServer();
73 server.sessionTimeout = 0; 73 server.sessionTimeout = 0;
74 server.listen("127.0.0.1", 0); 74 server.listen("127.0.0.1", 0);
75 var timeouts = []; 75 var timeouts = [];
76 server.defaultRequestHandler = (request, response) { 76 server.defaultRequestHandler = (request, response) {
77 var c = new Completer(); 77 var c = new Completer();
78 timeouts.add(c.future); 78 timeouts.add(c.future);
79 request.session().onTimeout = () { 79 request.session().onTimeout = () {
80 c.complete(null); 80 c.complete(null);
81 }; 81 };
82 response.outputStream.close(); 82 response.outputStream.close();
83 }; 83 };
84 84
85 var futures = []; 85 var futures = [];
86 for (int i = 0; i < sessionCount; i++) { 86 for (int i = 0; i < sessionCount; i++) {
87 futures.add(connectGetSession(server.port)); 87 futures.add(connectGetSession(server.port));
88 } 88 }
89 Futures.wait(futures).then((clientSessions) { 89 Future.wait(futures).then((clientSessions) {
90 Futures.wait(timeouts).then((_) { 90 Future.wait(timeouts).then((_) {
91 futures = []; 91 futures = [];
92 for (var id in clientSessions) { 92 for (var id in clientSessions) {
93 futures.add(connectGetSession(server.port, id).then((session) { 93 futures.add(connectGetSession(server.port, id).then((session) {
94 Expect.isNotNull(session); 94 Expect.isNotNull(session);
95 Expect.notEquals(id, session); 95 Expect.notEquals(id, session);
96 })); 96 }));
97 } 97 }
98 Futures.wait(futures).then((_) { 98 Future.wait(futures).then((_) {
99 server.close(); 99 server.close();
100 }); 100 });
101 }); 101 });
102 }); 102 });
103 } 103 }
104 104
105 void main() { 105 void main() {
106 testSessions(5); 106 testSessions(5);
107 testTimeout(5); 107 testTimeout(5);
108 } 108 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_auth_test.dart ('k') | tools/html_json_doc/lib/html_to_json.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698