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

Side by Side Diff: utils/tests/pub/test_pub.dart

Issue 12052038: Rename new Uri.fromString to Uri.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload because of Error. 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 | « utils/tests/pub/oauth2_test.dart ('k') | 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) 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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub
6 /// tests are integration tests that stage some stuff on the file system, run 6 /// tests are integration tests that stage some stuff on the file system, run
7 /// pub, and then validate the results. This library provides an API to build 7 /// pub, and then validate the results. This library provides an API to build
8 /// tests like that. 8 /// tests like that.
9 library test_pub; 9 library test_pub;
10 10
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 return new Future.immediate(server); 1440 return new Future.immediate(server);
1441 })); 1441 }));
1442 return scheduledServer; 1442 return scheduledServer;
1443 } 1443 }
1444 1444
1445 /// The port on which the server is listening. 1445 /// The port on which the server is listening.
1446 Future<int> get port => _server.then((s) => s.port); 1446 Future<int> get port => _server.then((s) => s.port);
1447 1447
1448 /// The base URL of the server, including its port. 1448 /// The base URL of the server, including its port.
1449 Future<Uri> get url => 1449 Future<Uri> get url =>
1450 port.then((p) => new Uri.fromString("http://localhost:$p")); 1450 port.then((p) => Uri.parse("http://localhost:$p"));
1451 1451
1452 /// Assert that the next request has the given [method] and [path], and pass 1452 /// Assert that the next request has the given [method] and [path], and pass
1453 /// it to [handler] to handle. If [handler] returns a [Future], wait until 1453 /// it to [handler] to handle. If [handler] returns a [Future], wait until
1454 /// it's completed to continue the schedule. 1454 /// it's completed to continue the schedule.
1455 void handle(String method, String path, 1455 void handle(String method, String path,
1456 Future handler(HttpRequest request, HttpResponse response)) { 1456 Future handler(HttpRequest request, HttpResponse response)) {
1457 var handlerCompleter = new Completer<Function>(); 1457 var handlerCompleter = new Completer<Function>();
1458 _scheduleValue((_) { 1458 _scheduleValue((_) {
1459 var requestCompleteCompleter = new Completer(); 1459 var requestCompleteCompleter = new Completer();
1460 handlerCompleter.complete((request, response) { 1460 handlerCompleter.complete((request, response) {
1461 expect(request.method, equals(method)); 1461 expect(request.method, equals(method));
1462 // TODO(nweiz): Use request.path once issue 7464 is fixed. 1462 // TODO(nweiz): Use request.path once issue 7464 is fixed.
1463 expect(new Uri.fromString(request.uri).path, equals(path)); 1463 expect(Uri.parse(request.uri).path, equals(path));
1464 1464
1465 var future = handler(request, response); 1465 var future = handler(request, response);
1466 if (future == null) future = new Future.immediate(null); 1466 if (future == null) future = new Future.immediate(null);
1467 chainToCompleter(future, requestCompleteCompleter); 1467 chainToCompleter(future, requestCompleteCompleter);
1468 }); 1468 });
1469 return timeout(requestCompleteCompleter.future, 1469 return timeout(requestCompleteCompleter.future,
1470 _SCHEDULE_TIMEOUT, "waiting for $method $path"); 1470 _SCHEDULE_TIMEOUT, "waiting for $method $path");
1471 }); 1471 });
1472 _handlers.add(handlerCompleter.future); 1472 _handlers.add(handlerCompleter.future);
1473 } 1473 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 /// calling [completion] is unnecessary. 1557 /// calling [completion] is unnecessary.
1558 void expectLater(Future actual, matcher, {String reason, 1558 void expectLater(Future actual, matcher, {String reason,
1559 FailureHandler failureHandler, bool verbose: false}) { 1559 FailureHandler failureHandler, bool verbose: false}) {
1560 _schedule((_) { 1560 _schedule((_) {
1561 return actual.then((value) { 1561 return actual.then((value) {
1562 expect(value, matcher, reason: reason, failureHandler: failureHandler, 1562 expect(value, matcher, reason: reason, failureHandler: failureHandler,
1563 verbose: false); 1563 verbose: false);
1564 }); 1564 });
1565 }); 1565 });
1566 } 1566 }
OLDNEW
« no previous file with comments | « utils/tests/pub/oauth2_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698