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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/tests/service/get_allocation_profile_rpc_test.dart
diff --git a/runtime/observatory/tests/service/get_allocation_profile_rpc_test.dart b/runtime/observatory/tests/service/get_allocation_profile_rpc_test.dart
index 7db64c99cec931dedfb4cd04f32753558627c846..2af7ffec62c90e14b27c340a3f33d7cfbace069a 100644
--- a/runtime/observatory/tests/service/get_allocation_profile_rpc_test.dart
+++ b/runtime/observatory/tests/service/get_allocation_profile_rpc_test.dart
@@ -3,11 +3,19 @@
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--error_on_bad_type --error_on_bad_override
+import 'dart:async';
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'test_helper.dart';
+Future sleep(int milliseconds) {
+ Completer completer = new Completer();
+ Duration duration = new Duration(milliseconds: milliseconds);
+ new Timer(duration, () => completer.complete() );
+ return completer.future;
+}
+
var tests = [
(Isolate isolate) async {
var params = {
@@ -15,10 +23,8 @@ var tests = [
var result = await isolate.invokeRpcNoUpgrade(
'_getAllocationProfile', params);
expect(result['type'], equals('AllocationProfile'));
- var lastReset = result['dateLastAccumulatorReset'];
- expect(lastReset, new isInstanceOf<String>());
- var lastGC = result['dateLastServiceGC'];
- expect(lastGC, new isInstanceOf<String>());
+ expect(result.containsKey('dateLastAccumulatorReset'), isFalse);
+ expect(result.containsKey('dateLastServiceGC'), isFalse);
expect(result['heaps'].length, isPositive);
expect(result['heaps']['new']['type'], equals('HeapSpace'));
expect(result['heaps']['old']['type'], equals('HeapSpace'));
@@ -31,29 +37,41 @@ var tests = [
};
result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
expect(result['type'], equals('AllocationProfile'));
- var newReset = result['dateLastAccumulatorReset'];
- expect(newReset, isNot(equals(lastReset)));
- expect(result['dateLastServiceGC'], equals(lastGC));
+ var firstReset = result['dateLastAccumulatorReset'];
+ expect(firstReset, new isInstanceOf<String>());
+ expect(result.containsKey('dateLastServiceGC'), isFalse);
expect(result['heaps'].length, isPositive);
expect(result['heaps']['new']['type'], equals('HeapSpace'));
expect(result['heaps']['old']['type'], equals('HeapSpace'));
expect(result['members'].length, isPositive);
expect(result['members'][0]['type'], equals('ClassHeapStats'));
+ await sleep(10);
+
+ result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
+ var secondReset = result['dateLastAccumulatorReset'];
+ expect(secondReset, isNot(equals(firstReset)));
+
// gc.
params = {
'gc' : 'full',
};
result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
expect(result['type'], equals('AllocationProfile'));
- expect(result['dateLastAccumulatorReset'], equals(newReset));
- var newGC = result['dateLastServiceGCt'];
- expect(newGC, isNot(equals(lastGC)));
+ expect(result['dateLastAccumulatorReset'], equals(secondReset));
+ var firstGC = result['dateLastServiceGC'];
+ expect(firstGC, new isInstanceOf<String>());
expect(result['heaps'].length, isPositive);
expect(result['heaps']['new']['type'], equals('HeapSpace'));
expect(result['heaps']['old']['type'], equals('HeapSpace'));
expect(result['members'].length, isPositive);
expect(result['members'][0]['type'], equals('ClassHeapStats'));
+
+ await sleep(10);
+
+ result = await isolate.invokeRpcNoUpgrade('_getAllocationProfile', params);
+ var secondGC = result['dateLastAccumulatorReset'];
+ expect(secondGC, isNot(equals(firstGC)));
},
(Isolate isolate) async {
« 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