Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 library test_utils; | 5 library test_utils; |
| 6 | 6 |
| 7 import 'dart:async'; | |
| 7 import 'dart:io'; | 8 import 'dart:io'; |
| 8 import 'dart:json' as json; | 9 import 'dart:json' as json; |
| 9 import 'dart:uri'; | 10 import 'dart:uri'; |
| 10 | 11 |
| 11 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
| 12 import 'package:http/http.dart' as http; | 13 import 'package:http/http.dart' as http; |
| 13 import 'package:http/src/utils.dart'; | 14 import 'package:http/src/utils.dart'; |
| 14 | 15 |
| 15 /// The current server instance. | 16 /// The current server instance. |
| 16 HttpServer _server; | 17 HttpServer _server; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 98 |
| 98 _server.listen("127.0.0.1", 0); | 99 _server.listen("127.0.0.1", 0); |
| 99 } | 100 } |
| 100 | 101 |
| 101 /// Stops the current HTTP server. | 102 /// Stops the current HTTP server. |
| 102 void stopServer() { | 103 void stopServer() { |
| 103 _server.close(); | 104 _server.close(); |
| 104 _server = null; | 105 _server = null; |
| 105 } | 106 } |
| 106 | 107 |
| 108 /// Buffers all input from an InputStream and returns it as a future. | |
|
Bob Nystrom
2013/01/08 23:50:49
Is this a dart:io compatibility thing? If so, docu
nweiz
2013/01/09 00:52:11
Done.
| |
| 109 Future<List<int>> consumeInputStream(InputStream stream) => | |
| 110 new http.ByteStream(wrapInputStream(stream)).toBytes(); | |
| 111 | |
| 107 /// A matcher that matches JSON that parses to a value that matches the inner | 112 /// A matcher that matches JSON that parses to a value that matches the inner |
| 108 /// matcher. | 113 /// matcher. |
| 109 Matcher parse(matcher) => new _Parse(matcher); | 114 Matcher parse(matcher) => new _Parse(matcher); |
| 110 | 115 |
| 111 class _Parse extends BaseMatcher { | 116 class _Parse extends BaseMatcher { |
| 112 final Matcher _matcher; | 117 final Matcher _matcher; |
| 113 | 118 |
| 114 _Parse(this._matcher); | 119 _Parse(this._matcher); |
| 115 | 120 |
| 116 bool matches(item, MatchState matchState) { | 121 bool matches(item, MatchState matchState) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 const Matcher throwsRedirectLimitExceededException = | 170 const Matcher throwsRedirectLimitExceededException = |
| 166 const Throws(isRedirectLimitExceededException); | 171 const Throws(isRedirectLimitExceededException); |
| 167 | 172 |
| 168 class _RedirectLimitExceededException extends TypeMatcher { | 173 class _RedirectLimitExceededException extends TypeMatcher { |
| 169 const _RedirectLimitExceededException() : | 174 const _RedirectLimitExceededException() : |
| 170 super("RedirectLimitExceededException"); | 175 super("RedirectLimitExceededException"); |
| 171 | 176 |
| 172 bool matches(item, MatchState matchState) => | 177 bool matches(item, MatchState matchState) => |
| 173 item is RedirectLimitExceededException; | 178 item is RedirectLimitExceededException; |
| 174 } | 179 } |
| OLD | NEW |