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

Unified Diff: runtime/observatory/tests/service/get_user_level_retaining_path_rpc_test.dart

Issue 2990643002: Calculates retaining paths through user fields and ignores VM objects (Closed)
Patch Set: Adds new test that expects a simple path for const and top level functions Created 3 years, 5 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
« no previous file with comments | « no previous file | runtime/vm/object_graph.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/get_user_level_retaining_path_rpc_test.dart
diff --git a/runtime/observatory/tests/service/get_user_level_retaining_path_rpc_test.dart b/runtime/observatory/tests/service/get_user_level_retaining_path_rpc_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dc6473ee5a4fd9531fe412593082e68be4efcff6
--- /dev/null
+++ b/runtime/observatory/tests/service/get_user_level_retaining_path_rpc_test.dart
@@ -0,0 +1,72 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--error_on_bad_type --error_on_bad_override
+
+import 'package:observatory/service_io.dart';
+import 'package:unittest/unittest.dart';
+
+import 'test_helper.dart';
+
+class _TestClass {
+ _TestClass();
+ var x;
+ var y;
+}
+
+class _TestConst {
+ const _TestConst();
+}
+
+_TopLevelClosure() {}
+
+var x;
+var fn;
+
+void warmup() {
+ x = const _TestConst();
+ fn = _TopLevelClosure;
+}
+
+eval(Isolate isolate, String expression) async {
+ Map params = {
+ 'targetId': isolate.rootLibrary.id,
+ 'expression': expression,
+ };
+ return await isolate.invokeRpcNoUpgrade('evaluate', params);
+}
+
+var tests = [
+ // Expect a simple path through variable x instead of long path filled
+ // with VM objects
+ (Isolate isolate) async {
+ var target1 = await eval(isolate, 'x;');
+ var params = {
+ 'targetId': target1['id'],
+ 'limit': 100,
+ };
+ var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params);
+ expect(result['type'], equals('RetainingPath'));
+ expect(result['elements'].length, equals(2));
+ expect(
+ result['elements'][0]['value']['class']['name'], equals('_TestConst'));
+ expect(result['elements'][1]['value']['name'], equals('x'));
+ },
+
+ // Expect a simple path through variable fn instead of long path filled
+ // with VM objects
+ (Isolate isolate) async {
+ var target2 = await eval(isolate, 'fn;');
+ var params = {
+ 'targetId': target2['id'],
+ 'limit': 100,
+ };
+ var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params);
+ expect(result['type'], equals('RetainingPath'));
+ expect(result['elements'].length, equals(2));
+ expect(result['elements'][0]['value']['class']['name'], equals('_Closure'));
+ expect(result['elements'][1]['value']['name'], equals('fn'));
+ }
+];
+
+main(args) async => runIsolateTests(args, tests, testeeBefore: warmup);
« no previous file with comments | « no previous file | runtime/vm/object_graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698