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

Side by Side Diff: runtime/observatory/tests/service/udp_socket_service_test.dart

Issue 1323183002: Revert "Extract meta data about open sockets into separate class." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « runtime/observatory/tests/service/tcp_socket_service_test.dart ('k') | sdk/lib/io/io.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) 2015, 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' as io;
8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart';
10 import 'test_helper.dart';
11
12 Future setupUDP() async {
13 var server = await io.RawDatagramSocket.bind('127.0.0.1', 0);
14 server.listen((io.RawSocketEvent event) {
15 if(event == io.RawSocketEvent.READ) {
16 io.Datagram dg = server.receive();
17 dg.data.forEach((x) => true);
18 }
19 });
20 var client = await io.RawDatagramSocket.bind('127.0.0.1', 0);
21 client.send(UTF8.encoder.convert('foobar'),
22 new io.InternetAddress('127.0.0.1'), server.port);
23 }
24
25 var udpTests = [
26 // Initial.
27 (Isolate isolate) async {
28 var result = await isolate.invokeRpcNoUpgrade('__getOpenSockets', {});
29 expect(result['type'], equals('_opensockets'));
30 // We expect 2 sockets to be open (in this order):
31 // The server socket accepting connections, on port X
32 // The client socket on port Y
33 expect(result['data'].length, equals(2));
34 // The first socket will have a name like listening:127.0.0.1:X
35 // The second will have a name like 127.0.0.1:Y
36 // The third will have a name like 127.0.0.1:X
37 expect(result['data'][0]['name'].startsWith('127.0.0.1'), isTrue);
38 expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue);
39
40 var server = await isolate.invokeRpcNoUpgrade(
41 '__getSocketByID', { 'id' : result['data'][0]['id'] });
42 expect(server['id'], equals(result['data'][0]['id']));
43 expect(server['remote_port'], equals('NA'));
44 expect(server['remote_host'], equals('NA'));
45 expect(server['listening'], isFalse);
46 expect(server['socket_type'], equals('UDP'));
47 expect(server['port'], greaterThanOrEqualTo(1024));
48 expect(server['last_read'], greaterThan(0));
49 expect(server['total_read'], equals(6));
50 expect(server['last_write'], equals(0));
51 expect(server['total_written'], equals(0));
52 expect(server['write_count'], equals(0));
53 expect(server['read_count'], equals(1));
54
55 var client = await isolate.invokeRpcNoUpgrade(
56 '__getSocketByID', { 'id' : result['data'][1]['id'] });
57 expect(client['id'], equals(result['data'][1]['id']));
58 expect(client['remote_port'], equals('NA'));
59 expect(client['remote_host'], equals('NA'));
60 expect(client['listening'], isFalse);
61 expect(client['socket_type'], equals('UDP'));
62 expect(client['port'], greaterThanOrEqualTo(1024));
63 expect(client['last_read'], equals(0));
64 expect(client['total_read'], equals(0));
65 expect(client['last_write'], greaterThan(0));
66 expect(client['total_written'], equals(6));
67 expect(client['write_count'], equals(1));
68 expect(client['read_count'], equals(0));
69 },
70 ];
71
72 main(args) async => runIsolateTests(args, udpTests, testeeBefore:setupUDP);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/tcp_socket_service_test.dart ('k') | sdk/lib/io/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698