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

Side by Side Diff: runtime/observatory/tests/service/get_allocation_profile_rpc_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 // VMOptions=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 import 'dart:async'; 6 import 'dart:async';
7 import 'package:observatory/service_io.dart'; 7 import 'package:observatory/service_io.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'test_helper.dart'; 10 import 'test_helper.dart';
11 11
12 Future sleep(int milliseconds) { 12 Future sleep(int milliseconds) {
13 Completer completer = new Completer(); 13 Completer completer = new Completer();
14 Duration duration = new Duration(milliseconds: milliseconds); 14 Duration duration = new Duration(milliseconds: milliseconds);
15 new Timer(duration, () => completer.complete()); 15 new Timer(duration, () => completer.complete() );
16 return completer.future; 16 return completer.future;
17 } 17 }
18 18
19 var tests = [ 19 var tests = [
20 (Isolate isolate) async { 20 (Isolate isolate) async {
21 var params = {}; 21 var params = {
22 var result = 22 };
23 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 23 var result = await isolate.invokeRpcNoUpgrade(
24 '_getAllocationProfile', params);
24 expect(result['type'], equals('AllocationProfile')); 25 expect(result['type'], equals('AllocationProfile'));
25 expect(result.containsKey('dateLastAccumulatorReset'), isFalse); 26 expect(result.containsKey('dateLastAccumulatorReset'), isFalse);
26 expect(result.containsKey('dateLastServiceGC'), isFalse); 27 expect(result.containsKey('dateLastServiceGC'), isFalse);
27 expect(result['heaps'].length, isPositive); 28 expect(result['heaps'].length, isPositive);
28 expect(result['heaps']['new']['type'], equals('HeapSpace')); 29 expect(result['heaps']['new']['type'], equals('HeapSpace'));
29 expect(result['heaps']['old']['type'], equals('HeapSpace')); 30 expect(result['heaps']['old']['type'], equals('HeapSpace'));
30 expect(result['members'].length, isPositive); 31 expect(result['members'].length, isPositive);
31 expect(result['members'][0]['type'], equals('ClassHeapStats')); 32 expect(result['members'][0]['type'], equals('ClassHeapStats'));
32 33
33 // reset. 34 // reset.
34 params = { 35 params = {
35 'reset': 'true', 36 'reset' : 'true',
36 }; 37 };
37 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 38 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
38 expect(result['type'], equals('AllocationProfile')); 39 expect(result['type'], equals('AllocationProfile'));
39 var firstReset = result['dateLastAccumulatorReset']; 40 var firstReset = result['dateLastAccumulatorReset'];
40 expect(firstReset, new isInstanceOf<String>()); 41 expect(firstReset, new isInstanceOf<String>());
41 expect(result.containsKey('dateLastServiceGC'), isFalse); 42 expect(result.containsKey('dateLastServiceGC'), isFalse);
42 expect(result['heaps'].length, isPositive); 43 expect(result['heaps'].length, isPositive);
43 expect(result['heaps']['new']['type'], equals('HeapSpace')); 44 expect(result['heaps']['new']['type'], equals('HeapSpace'));
44 expect(result['heaps']['old']['type'], equals('HeapSpace')); 45 expect(result['heaps']['old']['type'], equals('HeapSpace'));
45 expect(result['members'].length, isPositive); 46 expect(result['members'].length, isPositive);
46 expect(result['members'][0]['type'], equals('ClassHeapStats')); 47 expect(result['members'][0]['type'], equals('ClassHeapStats'));
47 48
48 await sleep(1000); 49 await sleep(1000);
49 50
50 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 51 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
51 var secondReset = result['dateLastAccumulatorReset']; 52 var secondReset = result['dateLastAccumulatorReset'];
52 expect(secondReset, isNot(equals(firstReset))); 53 expect(secondReset, isNot(equals(firstReset)));
53 54
54 // gc. 55 // gc.
55 params = { 56 params = {
56 'gc': 'full', 57 'gc' : 'full',
57 }; 58 };
58 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 59 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
59 expect(result['type'], equals('AllocationProfile')); 60 expect(result['type'], equals('AllocationProfile'));
60 expect(result['dateLastAccumulatorReset'], equals(secondReset)); 61 expect(result['dateLastAccumulatorReset'], equals(secondReset));
61 var firstGC = result['dateLastServiceGC']; 62 var firstGC = result['dateLastServiceGC'];
62 expect(firstGC, new isInstanceOf<String>()); 63 expect(firstGC, new isInstanceOf<String>());
63 expect(result['heaps'].length, isPositive); 64 expect(result['heaps'].length, isPositive);
64 expect(result['heaps']['new']['type'], equals('HeapSpace')); 65 expect(result['heaps']['new']['type'], equals('HeapSpace'));
65 expect(result['heaps']['old']['type'], equals('HeapSpace')); 66 expect(result['heaps']['old']['type'], equals('HeapSpace'));
66 expect(result['members'].length, isPositive); 67 expect(result['members'].length, isPositive);
67 expect(result['members'][0]['type'], equals('ClassHeapStats')); 68 expect(result['members'][0]['type'], equals('ClassHeapStats'));
68 69
69 await sleep(1000); 70 await sleep(1000);
70 71
71 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 72 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
72 var secondGC = result['dateLastAccumulatorReset']; 73 var secondGC = result['dateLastAccumulatorReset'];
73 expect(secondGC, isNot(equals(firstGC))); 74 expect(secondGC, isNot(equals(firstGC)));
74 }, 75 },
76
75 (Isolate isolate) async { 77 (Isolate isolate) async {
76 var params = { 78 var params = {
77 'reset': 'banana', 79 'reset' : 'banana',
78 }; 80 };
79 bool caughtException; 81 bool caughtException;
80 try { 82 try {
81 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 83 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
82 expect(false, isTrue, reason: 'Unreachable'); 84 expect(false, isTrue, reason:'Unreachable');
83 } on ServerRpcException catch (e) { 85 } on ServerRpcException catch (e) {
84 caughtException = true; 86 caughtException = true;
85 expect(e.code, equals(ServerRpcException.kInvalidParams)); 87 expect(e.code, equals(ServerRpcException.kInvalidParams));
86 expect(e.data['details'], 88 expect(e.data['details'],
87 "_getAllocationProfile: invalid \'reset\' parameter: banana"); 89 "_getAllocationProfile: invalid \'reset\' parameter: banana");
88 } 90 }
89 expect(caughtException, isTrue); 91 expect(caughtException, isTrue);
90 }, 92 },
93
91 (Isolate isolate) async { 94 (Isolate isolate) async {
92 var params = { 95 var params = {
93 'gc': 'banana', 96 'gc' : 'banana',
94 }; 97 };
95 bool caughtException; 98 bool caughtException;
96 try { 99 try {
97 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 100 await isolate.invokeRpcNoUpgrade(
98 expect(false, isTrue, reason: 'Unreachable'); 101 '_getAllocationProfile', params);
102 expect(false, isTrue, reason:'Unreachable');
99 } on ServerRpcException catch (e) { 103 } on ServerRpcException catch (e) {
100 caughtException = true; 104 caughtException = true;
101 expect(e.code, equals(ServerRpcException.kInvalidParams)); 105 expect(e.code, equals(ServerRpcException.kInvalidParams));
102 expect(e.data['details'], 106 expect(e.data['details'],
103 "_getAllocationProfile: invalid \'gc\' parameter: banana"); 107 "_getAllocationProfile: invalid \'gc\' parameter: banana");
104 } 108 }
105 expect(caughtException, isTrue); 109 expect(caughtException, isTrue);
106 }, 110 },
107 ]; 111 ];
108 112
109 main(args) async => runIsolateTests(args, tests); 113 main(args) async => runIsolateTests(args, tests);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/gc_test.dart ('k') | runtime/observatory/tests/service/get_allocation_samples_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698