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

Unified Diff: tests/standalone/io/observatory_test.dart

Issue 302173007: Add HttpServerConnection to Observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 6 years, 6 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 | « tests/standalone/io/observatory.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/observatory_test.dart
diff --git a/tests/standalone/io/observatory.dart b/tests/standalone/io/observatory_test.dart
similarity index 56%
rename from tests/standalone/io/observatory.dart
rename to tests/standalone/io/observatory_test.dart
index b22bbc2aa6e23c94ec0df290e93a0112392b2637..b9a656e3ca22d58b623d4ea0da7e6d7ca9df7d3b 100644
--- a/tests/standalone/io/observatory.dart
+++ b/tests/standalone/io/observatory_test.dart
@@ -36,8 +36,8 @@ Future testHttpServer1() {
Expect.equals(map['address'], 'localhost');
Expect.equals(map['port'], server.port);
Expect.equals(map['closed'], false);
- Expect.equals(map['idle'], 0);
- Expect.equals(map['active'], 0);
+ Expect.listEquals(map['idle'], []);
+ Expect.listEquals(map['active'], []);
var socket = map['socket'];
Expect.equals(socket['type'], '@Socket');
Expect.equals(socket['kind'], 'Listening');
@@ -49,9 +49,45 @@ Future testHttpServer1() {
}
+Future testHttpServerConnection1() {
+ return HttpServer.bind('localhost', 0).then((server) {
+ server.listen((request) {
+ var map = lookupServiceObject(getServicePath(server));
+ Expect.listEquals(map['idle'], []);
+ Expect.equals(map['active'].length, 1);
+ var active = map['active'].first;
+ Expect.equals(active['type'], '@HttpServerConnection');
+ var path = active['id'];
+ map = lookupServiceObject(path);
+ Expect.equals(map['type'], 'HttpServerConnection');
+ var socket = map['socket'];
+ Expect.equals(socket['type'], '@Socket');
+ Expect.equals(socket['kind'], 'Normal');
+ // Validate owner back-ref.
+ socket = lookupServiceObject(socket['id']);
+ Expect.equals(socket['owner']['id'], path);
+ request.response.close();
+ });
+ var client = new HttpClient();
+ return client.get('localhost', server.port, '/')
+ .then((request) => request.close())
+ .then((response) => response.drain())
+ .then((_) {
+ // The connection should be idle now.
+ var map = lookupServiceObject(getServicePath(server));
+ Expect.equals(map['idle'].length, 1);
+ Expect.listEquals(map['active'], []);
+ return server.close();
+ });
+
+ });
+}
+
+
void main() {
final tests = [
testHttpServer1(),
+ testHttpServerConnection1(),
];
asyncStart();
« no previous file with comments | « tests/standalone/io/observatory.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698