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

Side by Side Diff: tests/standalone/io/observatory.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | tests/standalone/io/observatory_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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:convert';
7 import 'dart:io';
8 import 'dart:mirrors';
9
10 import 'package:expect/expect.dart';
11 import 'package:async_helper/async_helper.dart';
12
13 Map lookupServiceObject(String path) {
14 var io = currentMirrorSystem().findLibrary(const Symbol('dart.io'));
15 var m = MirrorSystem.getSymbol('_serviceObjectHandler', io);
16 var paths = Uri.parse(path).pathSegments;
17 Expect.equals('io', paths.first);
18 return JSON.decode(
19 io.invoke(m, [paths.sublist(1), [], []]).reflectee);
20 }
21
22
23 String getServicePath(obj) {
24 var io = currentMirrorSystem().findLibrary(const Symbol('dart.io'));
25 var m = MirrorSystem.getSymbol('_getServicePath', io);
26 return io.invoke(m, [obj]).reflectee;
27 }
28
29
30 Future testHttpServer1() {
31 return HttpServer.bind('localhost', 0).then((server) {
32 var path = getServicePath(server);
33 var map = lookupServiceObject(path);
34 Expect.equals(map['type'], 'HttpServer');
35 Expect.equals(map['id'], path);
36 Expect.equals(map['address'], 'localhost');
37 Expect.equals(map['port'], server.port);
38 Expect.equals(map['closed'], false);
39 Expect.equals(map['idle'], 0);
40 Expect.equals(map['active'], 0);
41 var socket = map['socket'];
42 Expect.equals(socket['type'], '@Socket');
43 Expect.equals(socket['kind'], 'Listening');
44 // Validate owner back-ref.
45 socket = lookupServiceObject(socket['id']);
46 Expect.equals(socket['owner']['id'], path);
47 return server.close();
48 });
49 }
50
51
52 void main() {
53 final tests = [
54 testHttpServer1(),
55 ];
56
57 asyncStart();
58 // Run one test at a time.
59 Future.forEach(tests, (f) => f)
60 .then((_) {
61 asyncEnd();
62 });
63 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | tests/standalone/io/observatory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698