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

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

Issue 2255613002: Converted Observatory heap-profile element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Better sorting tests Created 4 years, 4 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 'package:observatory/service_io.dart'; 7 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
8 9
9 import 'test_helper.dart'; 10 import 'test_helper.dart';
10 11
12 Future sleep(int milliseconds) {
13 Completer completer = new Completer();
14 Duration duration = new Duration(milliseconds: milliseconds);
15 new Timer(duration, () => completer.complete() );
16 return completer.future;
17 }
18
11 var tests = [ 19 var tests = [
12 (Isolate isolate) async { 20 (Isolate isolate) async {
13 var params = { 21 var params = {
14 }; 22 };
15 var result = await isolate.invokeRpcNoUpgrade( 23 var result = await isolate.invokeRpcNoUpgrade(
16 '_getAllocationProfile', params); 24 '_getAllocationProfile', params);
17 expect(result['type'], equals('AllocationProfile')); 25 expect(result['type'], equals('AllocationProfile'));
18 var lastReset = result['dateLastAccumulatorReset']; 26 expect(result.containsKey('dateLastAccumulatorReset'), isFalse);
19 expect(lastReset, new isInstanceOf<String>()); 27 expect(result.containsKey('dateLastServiceGC'), isFalse);
20 var lastGC = result['dateLastServiceGC'];
21 expect(lastGC, new isInstanceOf<String>());
22 expect(result['heaps'].length, isPositive); 28 expect(result['heaps'].length, isPositive);
23 expect(result['heaps']['new']['type'], equals('HeapSpace')); 29 expect(result['heaps']['new']['type'], equals('HeapSpace'));
24 expect(result['heaps']['old']['type'], equals('HeapSpace')); 30 expect(result['heaps']['old']['type'], equals('HeapSpace'));
25 expect(result['members'].length, isPositive); 31 expect(result['members'].length, isPositive);
26 expect(result['members'][0]['type'], equals('ClassHeapStats')); 32 expect(result['members'][0]['type'], equals('ClassHeapStats'));
27 33
28 // reset. 34 // reset.
29 params = { 35 params = {
30 'reset' : 'true', 36 'reset' : 'true',
31 }; 37 };
32 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 38 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
33 expect(result['type'], equals('AllocationProfile')); 39 expect(result['type'], equals('AllocationProfile'));
34 var newReset = result['dateLastAccumulatorReset']; 40 var firstReset = result['dateLastAccumulatorReset'];
35 expect(newReset, isNot(equals(lastReset))); 41 expect(firstReset, new isInstanceOf<String>());
36 expect(result['dateLastServiceGC'], equals(lastGC)); 42 expect(result.containsKey('dateLastServiceGC'), isFalse);
37 expect(result['heaps'].length, isPositive); 43 expect(result['heaps'].length, isPositive);
38 expect(result['heaps']['new']['type'], equals('HeapSpace')); 44 expect(result['heaps']['new']['type'], equals('HeapSpace'));
39 expect(result['heaps']['old']['type'], equals('HeapSpace')); 45 expect(result['heaps']['old']['type'], equals('HeapSpace'));
40 expect(result['members'].length, isPositive); 46 expect(result['members'].length, isPositive);
41 expect(result['members'][0]['type'], equals('ClassHeapStats')); 47 expect(result['members'][0]['type'], equals('ClassHeapStats'));
42 48
49 await sleep(10);
50
51 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
52 var secondReset = result['dateLastAccumulatorReset'];
53 expect(secondReset, isNot(equals(firstReset)));
54
43 // gc. 55 // gc.
44 params = { 56 params = {
45 'gc' : 'full', 57 'gc' : 'full',
46 }; 58 };
47 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 59 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
48 expect(result['type'], equals('AllocationProfile')); 60 expect(result['type'], equals('AllocationProfile'));
49 expect(result['dateLastAccumulatorReset'], equals(newReset)); 61 expect(result['dateLastAccumulatorReset'], equals(secondReset));
50 var newGC = result['dateLastServiceGCt']; 62 var firstGC = result['dateLastServiceGC'];
51 expect(newGC, isNot(equals(lastGC))); 63 expect(firstGC, new isInstanceOf<String>());
52 expect(result['heaps'].length, isPositive); 64 expect(result['heaps'].length, isPositive);
53 expect(result['heaps']['new']['type'], equals('HeapSpace')); 65 expect(result['heaps']['new']['type'], equals('HeapSpace'));
54 expect(result['heaps']['old']['type'], equals('HeapSpace')); 66 expect(result['heaps']['old']['type'], equals('HeapSpace'));
55 expect(result['members'].length, isPositive); 67 expect(result['members'].length, isPositive);
56 expect(result['members'][0]['type'], equals('ClassHeapStats')); 68 expect(result['members'][0]['type'], equals('ClassHeapStats'));
69
70 await sleep(10);
71
72 result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
73 var secondGC = result['dateLastAccumulatorReset'];
74 expect(secondGC, isNot(equals(firstGC)));
57 }, 75 },
58 76
59 (Isolate isolate) async { 77 (Isolate isolate) async {
60 var params = { 78 var params = {
61 'reset' : 'banana', 79 'reset' : 'banana',
62 }; 80 };
63 bool caughtException; 81 bool caughtException;
64 try { 82 try {
65 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params); 83 await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
66 expect(false, isTrue, reason:'Unreachable'); 84 expect(false, isTrue, reason:'Unreachable');
(...skipping 19 matching lines...) Expand all
86 caughtException = true; 104 caughtException = true;
87 expect(e.code, equals(ServerRpcException.kInvalidParams)); 105 expect(e.code, equals(ServerRpcException.kInvalidParams));
88 expect(e.data['details'], 106 expect(e.data['details'],
89 "_getAllocationProfile: invalid \'gc\' parameter: banana"); 107 "_getAllocationProfile: invalid \'gc\' parameter: banana");
90 } 108 }
91 expect(caughtException, isTrue); 109 expect(caughtException, isTrue);
92 }, 110 },
93 ]; 111 ];
94 112
95 main(args) async => runIsolateTests(args, tests); 113 main(args) async => runIsolateTests(args, tests);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/observatory_ui/mocks/repositories/allocation_profile.dart ('k') | runtime/vm/class_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698