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

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

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io' as io; 7 import 'dart:io' as io;
8 import 'package:observatory/service_io.dart'; 8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'test_helper.dart'; 10 import 'test_helper.dart';
11 11
12
12 /// Test that we correctly remove sockets that have been closed from the list 13 /// Test that we correctly remove sockets that have been closed from the list
13 /// of open sockets. We explictly leave one socket open. 14 /// of open sockets. We explictly leave one socket open.
14 15
15 Future setup() async { 16 Future setup() async {
16 var serverSocket = await io.ServerSocket.bind('127.0.0.1', 0); 17 var serverSocket = await io.ServerSocket.bind('127.0.0.1', 0);
17 serverSocket.listen((s) { 18 serverSocket.listen((s) {
18 s.drain(); 19 s.drain();
19 s.close(); 20 s.close();
20 }); 21 });
21 var socket = await io.Socket.connect("127.0.0.1", serverSocket.port); 22 var socket = await io.Socket.connect("127.0.0.1", serverSocket.port);
22 socket.write("foobar"); 23 socket.write("foobar");
23 socket.write("foobar"); 24 socket.write("foobar");
24 25
25 await socket.flush(); 26 await socket.flush();
26 await socket.close(); 27 await socket.close();
27 await socket.drain(); 28 await socket.drain();
28 29
29 var socket2 = await io.Socket.connect("127.0.0.1", serverSocket.port); 30 var socket2 = await io.Socket.connect("127.0.0.1", serverSocket.port);
30 socket2.write("foobarfoobar"); 31 socket2.write("foobarfoobar");
31 await socket2.flush(); 32 await socket2.flush();
32 await socket2.close(); 33 await socket2.close();
33 await socket2.drain(); 34 await socket2.drain();
34 await serverSocket.close(); 35 await serverSocket.close();
35 36
36 var server = await io.RawDatagramSocket.bind('127.0.0.1', 0); 37 var server = await io.RawDatagramSocket.bind('127.0.0.1', 0);
37 server.listen((io.RawSocketEvent event) { 38 server.listen((io.RawSocketEvent event) {
38 if (event == io.RawSocketEvent.READ) { 39 if(event == io.RawSocketEvent.READ) {
39 io.Datagram dg = server.receive(); 40 io.Datagram dg = server.receive();
40 dg.data.forEach((x) => true); 41 dg.data.forEach((x) => true);
41 server.close(); 42 server.close();
42 } 43 }
43 }); 44 });
44 var client = await io.RawDatagramSocket.bind('127.0.0.1', 0); 45 var client = await io.RawDatagramSocket.bind('127.0.0.1', 0);
45 client.send(UTF8.encoder.convert('foobar'), 46 client.send(UTF8.encoder.convert('foobar'),
46 new io.InternetAddress('127.0.0.1'), server.port); 47 new io.InternetAddress('127.0.0.1'), server.port);
47 client.close(); 48 client.close();
48 49
49 // The one socket to expect. 50 // The one socket to expect.
50 await io.ServerSocket.bind('127.0.0.1', 0); 51 await io.ServerSocket.bind('127.0.0.1', 0);
51 } 52 }
52 53
53 var tests = [ 54 var tests = [
54 // Initial. 55 // Initial.
55 (Isolate isolate) async { 56 (Isolate isolate) async {
56 var result = 57 var result =
57 await isolate.invokeRpcNoUpgrade('ext.dart.io.getOpenSockets', {}); 58 await isolate.invokeRpcNoUpgrade('ext.dart.io.getOpenSockets', {});
58 expect(result['type'], equals('_opensockets')); 59 expect(result['type'], equals('_opensockets'));
59 // We expect only one socket to be open, the server socket create at the 60 // We expect only one socket to be open, the server socket create at the
60 // end of test. 61 // end of test.
61 expect(result['data'].length, equals(1)); 62 expect(result['data'].length, equals(1));
62 var server = await isolate.invokeRpcNoUpgrade( 63 var server = await isolate.invokeRpcNoUpgrade(
63 'ext.dart.io.getSocketByID', {'id': result['data'][0]['id']}); 64 'ext.dart.io.getSocketByID', { 'id' : result['data'][0]['id'] });
64 expect(server['listening'], isTrue); 65 expect(server['listening'], isTrue);
65 expect(server['lastRead'], equals(0)); 66 expect(server['lastRead'], equals(0));
66 expect(server['totalRead'], equals(0)); 67 expect(server['totalRead'], equals(0));
67 expect(server['lastWrite'], equals(0)); 68 expect(server['lastWrite'], equals(0));
68 expect(server['totalWritten'], equals(0)); 69 expect(server['totalWritten'], equals(0));
69 expect(server['writeCount'], equals(0)); 70 expect(server['writeCount'], equals(0));
70 expect(server['readCount'], equals(0)); 71 expect(server['readCount'], equals(0));
71 }, 72 },
72 ]; 73 ];
73 74
74 main(args) async => runIsolateTests(args, tests, testeeBefore: setup); 75 main(args) async => runIsolateTests(args, tests, testeeBefore:setup);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698