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

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

Issue 12330133: Don't use external servers in the tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed long lines Created 7 years, 10 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:async";
6 import "dart:io";
7 import "dart:uri";
8 import "dart:isolate";
9
10 // By running tests sequentially, we cover the socket reuse code in HttpClient.
11
12 void testGoogleUrls() {
13 int testsStarted = 0;
14 int testsFinished = 0;
15 bool allStarted = false;
16 HttpClient client = new HttpClient();
17
18 Future testUrl(String url) {
19 testsStarted++;
20 var requestUri = Uri.parse(url);
21 return client.getUrl(requestUri)
22 .then((HttpClientRequest request) => request.close())
23 .then((HttpClientResponse response) {
24 Expect.isTrue(response.statusCode < 500);
25 if (requestUri.path.length == 0) {
26 Expect.isTrue(response.statusCode != 404);
27 }
28 return response.reduce(null, (previous, element) => null);
29 })
30 .catchError((error) => Expect.fail("Unexpected IO error: $error"));
31 }
32
33 // TODO(3593): Use a Dart HTTP server for this test.
34 testUrl('http://www.google.dk')
35 .then((_) => testUrl('http://www.google.dk'))
36 .then((_) => testUrl('http://www.google.dk/#q=foo'))
37 .then((_) => testUrl('http://www.google.dk/#hl=da&q=foo'))
38 .then((_) { client.close(); });
39 }
40
41 void main() {
42 testGoogleUrls();
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698