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

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

Issue 1090293003: Kill service_test.cc tests in favor of dart tests for the service protocol. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix tests Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override
5
6 import 'dart:async';
7
8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart';
10
11 import 'test_helper.dart';
12
13 class _TestClass {
14 _TestClass(this.x, this.y);
15 var x;
16 var y;
17 }
18
19 var target1;
20 var target2;
21 var target3;
22 var globalObject;
23 var globalList;
24
25 void warmup() {
26 target1 = new _TestClass(null, null);
27 target2 = new _TestClass(null, null);
28 globalObject = new _TestClass(target1, target2);
29
30 target3 = new _TestClass(null, null);
31 globalList = new List(100);
32 globalList[12] = target3;
33 }
34
35 eval(Isolate isolate, String expression) async {
36 Map params = {
37 'targetId': isolate.rootLib.id,
38 'expression': expression,
39 };
40 return await isolate.invokeRpcNoUpgrade('eval', params);
41 }
42
43 var tests = [
44 // simple path
45 (Isolate isolate) async {
46 var obj = await eval(isolate, 'globalObject');
47 var params = {
48 'targetId': obj['id'],
49 'limit': 4,
50 };
51 var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params);
52 expect(result['elements'][1]['value']['name'], equals('globalObject'));
53 },
54
55 // missing limit.
56 (Isolate isolate) async {
57 var obj = await eval(isolate, 'globalObject');
58 var params = {
59 'targetId': obj['id'],
60 };
61 var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params);
62 expect(result['message'], contains("invalid 'limit' parameter"));
63 },
64
65 (Isolate isolate) async {
66 var target1 = await eval(
67 isolate, '() { var tmp = target1; target1 = null; return tmp;} ()');
68 var params = {
69 'targetId': target1['id'],
70 'limit': 4,
71 };
72 var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params);
73 expect(result['type'], equals('RetainingPath'));
74 expect(result['elements'][0]['parentField']['name'], equals('x'));
75 expect(result['elements'][2]['value']['name'], equals('globalObject'));
76 },
77
78 (Isolate isolate) async {
79 var target2 = await eval(
80 isolate, '() { var tmp = target2; target2 = null; return tmp;} ()');
81 var params = {
82 'targetId': target2['id'],
83 'limit': 4,
84 };
85 var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params);
86 expect(result['type'], equals('RetainingPath'));
87 expect(result['elements'][0]['parentField']['name'], equals('y'));
88 expect(result['elements'][2]['value']['name'], equals('globalObject'));
89 },
90
91 (Isolate isolate) async {
92 var target3 = await eval(
93 isolate, '() { var tmp = target3; target3 = null; return tmp;} ()');
94 var params = {
95 'targetId': target3['id'],
96 'limit': 4,
97 };
98 var result = await isolate.invokeRpcNoUpgrade('_getRetainingPath', params);
99 expect(result['type'], equals('RetainingPath'));
100 expect(result['elements'][0]['parentListIndex'], equals(12));
101 expect(result['elements'][2]['value']['name'], equals('globalList'));
102 },
103 ];
104
105 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698