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

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

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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
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:io"); 5 #import("dart:io");
6 #import("dart:isolate"); 6 #import("dart:isolate");
7 #import("dart:math");
7 8
8 class ExpectedDataOutputStream implements OutputStream { 9 class ExpectedDataOutputStream implements OutputStream {
9 ExpectedDataOutputStream(List<int> this._data, 10 ExpectedDataOutputStream(List<int> this._data,
10 int this._cutoff, 11 int this._cutoff,
11 bool this._closeAsError, 12 bool this._closeAsError,
12 SocketMock this._socket); 13 SocketMock this._socket);
13 14
14 void set onNoPendingWrites(void callback()) { 15 void set onNoPendingWrites(void callback()) {
15 _onNoPendingWrites = callback; 16 _onNoPendingWrites = callback;
16 } 17 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 int _cutoff; 56 int _cutoff;
56 bool _closeAsError; 57 bool _closeAsError;
57 SocketMock _socket; 58 SocketMock _socket;
58 } 59 }
59 60
60 class SocketMock implements Socket { 61 class SocketMock implements Socket {
61 SocketMock(List<int> this._data, 62 SocketMock(List<int> this._data,
62 List<int> expected, 63 List<int> expected,
63 int cutoff, 64 int cutoff,
64 bool closeAsError) : 65 bool closeAsError) :
65 _hashCode = (Math.random() * (1 << 32)).toInt(), 66 _hashCode = new Random().nextInt(1<< 32),
66 _read = [] { 67 _read = [] {
67 _outputStream = 68 _outputStream =
68 new ExpectedDataOutputStream(expected, cutoff, closeAsError, this); 69 new ExpectedDataOutputStream(expected, cutoff, closeAsError, this);
69 } 70 }
70 71
71 int available() { 72 int available() {
72 return _data.length; 73 return _data.length;
73 } 74 }
74 75
75 void _closeInternal([bool asError = false]) { 76 void _closeInternal([bool asError = false]) {
76 Expect.isFalse(_closed); 77 Expect.isFalse(_closed);
77 _closed = true; 78 _closed = true;
78 _onClosedInternal(); 79 _onClosedInternal();
79 if (asError) { 80 if (asError) {
80 _onError(new Exception("Socket closed unexpected")); 81 _onError(new Exception("Socket closed unexpected"));
81 } else { 82 } else {
82 _onClosed(); 83 _onClosed();
83 } 84 }
84 } 85 }
85 86
86 int readList(List<int> buffer, int offset, int count) { 87 int readList(List<int> buffer, int offset, int count) {
87 int max = Math.min(count, _data.length); 88 int max = min(count, _data.length);
88 buffer.setRange(offset, max, _data); 89 buffer.setRange(offset, max, _data);
89 _data = _data.getRange(max, _data.length - max); 90 _data = _data.getRange(max, _data.length - max);
90 return max; 91 return max;
91 } 92 }
92 93
93 void close([bool halfClose = false]) { 94 void close([bool halfClose = false]) {
94 if (!halfClose && !_closed) _closeInternal(); 95 if (!halfClose && !_closed) _closeInternal();
95 } 96 }
96 97
97 void set onData(void callback()) { 98 void set onData(void callback()) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n", 212 "GET / HTTP/1.1\r\nKeep-Alive: False\r\n\r\n",
212 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close" 213 "HTTP/1.1 200 OK\r\ntransfer-encoding: chunked\r\nconnection: close"
213 "\r\n\r\n0\r\n\r\n"); 214 "\r\n\r\n0\r\n\r\n");
214 215
215 server.close(); 216 server.close();
216 } 217 }
217 218
218 void main() { 219 void main() {
219 testSocketClose(); 220 testSocketClose();
220 } 221 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_parser_test.dart ('k') | tests/standalone/io/mime_multipart_parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698