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

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

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (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 }; 22 var result =
23 var result = await isolate.invokeRpcNoUpgrade( 23 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
24 '_getAllocationProfile', params);
25 expect(result['type'], equals('AllocationProfile')); 24 expect(result['type'], equals('AllocationProfile'));
26 expect(result.containsKey('dateLastAccumulatorReset'), isFalse); 25 expect(result.containsKey('dateLastAccumulatorReset'), isFalse);
27 expect(result.containsKey('dateLastServiceGC'), isFalse); 26 expect(result.containsKey('dateLastServiceGC'), isFalse);
28 expect(result['heaps'].length, isPositive); 27 expect(result['heaps'].length, isPositive);
29 expect(result['heaps']['new']['type'], equals('HeapSpace')); 28 expect(result['heaps']['new']['type'], equals('HeapSpace'));
30 expect(result['heaps']['old']['type'], equals('HeapSpace')); 29 expect(result['heaps']['old']['type'], equals('HeapSpace'));
31 expect(result['members'].length, isPositive); 30 expect(result['members'].length, isPositive);
32 expect(result['members'][0]['type'], equals('ClassHeapStats')); 31 expect(result['members'][0]['type'], equals('ClassHeapStats'));
33 32
34 // reset. 33 // reset.
35 params = { 34 params = {
36 'reset' : 'true', 35 'reset': 'true',
37 }; 36 };
38 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 37 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
39 expect(result['type'], equals('AllocationProfile')); 38 expect(result['type'], equals('AllocationProfile'));
40 var firstReset = result['dateLastAccumulatorReset']; 39 var firstReset = result['dateLastAccumulatorReset'];
41 expect(firstReset, new isInstanceOf<String>()); 40 expect(firstReset, new isInstanceOf<String>());
42 expect(result.containsKey('dateLastServiceGC'), isFalse); 41 expect(result.containsKey('dateLastServiceGC'), isFalse);
43 expect(result['heaps'].length, isPositive); 42 expect(result['heaps'].length, isPositive);
44 expect(result['heaps']['new']['type'], equals('HeapSpace')); 43 expect(result['heaps']['new']['type'], equals('HeapSpace'));
45 expect(result['heaps']['old']['type'], equals('HeapSpace')); 44 expect(result['heaps']['old']['type'], equals('HeapSpace'));
46 expect(result['members'].length, isPositive); 45 expect(result['members'].length, isPositive);
47 expect(result['members'][0]['type'], equals('ClassHeapStats')); 46 expect(result['members'][0]['type'], equals('ClassHeapStats'));
48 47
49 await sleep(1000); 48 await sleep(1000);
50 49
51 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 50 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
52 var secondReset = result['dateLastAccumulatorReset']; 51 var secondReset = result['dateLastAccumulatorReset'];
53 expect(secondReset, isNot(equals(firstReset))); 52 expect(secondReset, isNot(equals(firstReset)));
54 53
55 // gc. 54 // gc.
56 params = { 55 params = {
57 'gc' : 'full', 56 'gc': 'full',
58 }; 57 };
59 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 58 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
60 expect(result['type'], equals('AllocationProfile')); 59 expect(result['type'], equals('AllocationProfile'));
61 expect(result['dateLastAccumulatorReset'], equals(secondReset)); 60 expect(result['dateLastAccumulatorReset'], equals(secondReset));
62 var firstGC = result['dateLastServiceGC']; 61 var firstGC = result['dateLastServiceGC'];
63 expect(firstGC, new isInstanceOf<String>()); 62 expect(firstGC, new isInstanceOf<String>());
64 expect(result['heaps'].length, isPositive); 63 expect(result['heaps'].length, isPositive);
65 expect(result['heaps']['new']['type'], equals('HeapSpace')); 64 expect(result['heaps']['new']['type'], equals('HeapSpace'));
66 expect(result['heaps']['old']['type'], equals('HeapSpace')); 65 expect(result['heaps']['old']['type'], equals('HeapSpace'));
67 expect(result['members'].length, isPositive); 66 expect(result['members'].length, isPositive);
68 expect(result['members'][0]['type'], equals('ClassHeapStats')); 67 expect(result['members'][0]['type'], equals('ClassHeapStats'));
69 68
70 await sleep(1000); 69 await sleep(1000);
71 70
72 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 71 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
73 var secondGC = result['dateLastAccumulatorReset']; 72 var secondGC = result['dateLastAccumulatorReset'];
74 expect(secondGC, isNot(equals(firstGC))); 73 expect(secondGC, isNot(equals(firstGC)));
75 }, 74 },
76
77 (Isolate isolate) async { 75 (Isolate isolate) async {
78 var params = { 76 var params = {
79 'reset' : 'banana', 77 'reset': 'banana',
80 }; 78 };
81 bool caughtException; 79 bool caughtException;
82 try { 80 try {
83 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 81 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
84 expect(false, isTrue, reason:'Unreachable'); 82 expect(false, isTrue, reason: 'Unreachable');
85 } on ServerRpcException catch (e) { 83 } on ServerRpcException catch (e) {
86 caughtException = true; 84 caughtException = true;
87 expect(e.code, equals(ServerRpcException.kInvalidParams)); 85 expect(e.code, equals(ServerRpcException.kInvalidParams));
88 expect(e.data['details'], 86 expect(e.data['details'],
89 "_getAllocationProfile: invalid \'reset\' parameter: banana"); 87 "_getAllocationProfile: invalid \'reset\' parameter: banana");
90 } 88 }
91 expect(caughtException, isTrue); 89 expect(caughtException, isTrue);
92 }, 90 },
93
94 (Isolate isolate) async { 91 (Isolate isolate) async {
95 var params = { 92 var params = {
96 'gc' : 'banana', 93 'gc': 'banana',
97 }; 94 };
98 bool caughtException; 95 bool caughtException;
99 try { 96 try {
100 await isolate.invokeRpcNoUpgrade( 97 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
101 '_getAllocationProfile', params); 98 expect(false, isTrue, reason: 'Unreachable');
102 expect(false, isTrue, reason:'Unreachable');
103 } on ServerRpcException catch (e) { 99 } on ServerRpcException catch (e) {
104 caughtException = true; 100 caughtException = true;
105 expect(e.code, equals(ServerRpcException.kInvalidParams)); 101 expect(e.code, equals(ServerRpcException.kInvalidParams));
106 expect(e.data['details'], 102 expect(e.data['details'],
107 "_getAllocationProfile: invalid \'gc\' parameter: banana"); 103 "_getAllocationProfile: invalid \'gc\' parameter: banana");
108 } 104 }
109 expect(caughtException, isTrue); 105 expect(caughtException, isTrue);
110 }, 106 },
111 ]; 107 ];
112 108
113 main(args) async => runIsolateTests(args, tests); 109 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