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

Unified Diff: pkg/scheduled_test/lib/src/scheduled_server/handler.dart

Issue 216373004: Use shelf handlers in ScheduledServer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/scheduled_test/lib/scheduled_server.dart ('k') | pkg/scheduled_test/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/lib/src/scheduled_server/handler.dart
diff --git a/pkg/scheduled_test/lib/src/scheduled_server/handler.dart b/pkg/scheduled_test/lib/src/scheduled_server/handler.dart
index ecac381ee7eaa9ab194f862c81d9afd57498fca6..9dd44ce4d007b48731b9f45c95883fae0705418b 100644
--- a/pkg/scheduled_test/lib/src/scheduled_server/handler.dart
+++ b/pkg/scheduled_test/lib/src/scheduled_server/handler.dart
@@ -6,6 +6,8 @@ library scheduled_server.handler;
import 'dart:async';
+import 'package:shelf/shelf.dart' as shelf;
+
import '../../scheduled_server.dart';
import '../../scheduled_test.dart';
import '../utils.dart';
@@ -22,8 +24,8 @@ class Handler {
final String path;
/// The function to run to handle the request.
- ScheduledHandler get fn => _fn;
- ScheduledHandler _fn;
+ shelf.Handler get fn => _fn;
+ shelf.Handler _fn;
/// The scheduled task immediately prior to this handler. If this task is
/// running when this handler receives a request, it should wait until the
@@ -41,28 +43,31 @@ class Handler {
/// Whether it's time for the handler to receive its request.
var ready = false;
- Handler(this.server, this.method, this.path, ScheduledHandler fn) {
+ Handler(this.server, this.method, this.path, shelf.Handler fn) {
_fn = (request) {
return _waitForTask().then((_) {
if (!ready) {
- fail("'${server.description}' received "
- "$method $path earlier than expected.");
+ fail("'${server.description}' received $method $path earlier than "
+ "expected.");
}
+ var description = "'${server.description}' handling ${request.method} "
+ "${request.pathInfo}";
// Use a nested call to [schedule] to help the user tell the difference
// between a test failing while waiting for a handler and a test failing
// while executing a handler.
chainToCompleter(schedule(() {
return syncFuture(() {
- if (request.method != method || request.uri.path != path) {
+ if (request.method != method || request.pathInfo != path) {
fail("'${server.description}' expected $method $path, "
- "but got ${request.method} ${request.uri.path}.");
+ "but got ${request.method} ${request.pathInfo}.");
}
return fn(request);
});
- }, "'${server.description}' handling ${request.method} ${request.uri}"),
- _resultCompleter);
+ }, description), _resultCompleter);
+
+ return _resultCompleter.future;
});
};
}
« no previous file with comments | « pkg/scheduled_test/lib/scheduled_server.dart ('k') | pkg/scheduled_test/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698