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

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

Issue 1753903003: Make getSourceReport public. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:observatory/service_io.dart'; 6 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'test_helper.dart'; 8 import 'test_helper.dart';
9 import 'service_test_common.dart'; 9 import 'service_test_common.dart';
10 import 'dart:developer'; 10 import 'dart:developer';
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 'scriptIndex': 0, 65 'scriptIndex': 0,
66 'startPos': 38, 66 'startPos': 38,
67 'endPos': 87, 67 'endPos': 87,
68 'compiled': true, 68 'compiled': true,
69 'coverage': {'hits': [53, 71, 81], 'misses': [59]} 69 'coverage': {'hits': [53, 71, 81], 'misses': [59]}
70 }; 70 };
71 71
72 // Full script 72 // Full script
73 var params = { 'reports' : ['Coverage'], 73 var params = { 'reports' : ['Coverage'],
74 'scriptId' : func.location.script.id }; 74 'scriptId' : func.location.script.id };
75 var coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); 75 var coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
76 expect(coverage['type'], equals('SourceReport')); 76 expect(coverage['type'], equals('SourceReport'));
77 expect(coverage['ranges'].length, 6); 77 expect(coverage['ranges'].length, 6);
78 expect(coverage['ranges'][0], equals(expectedRange)); 78 expect(coverage['ranges'][0], equals(expectedRange));
79 expect(coverage['scripts'].length, 1); 79 expect(coverage['scripts'].length, 1);
80 expect(coverage['scripts'][0]['uri'], 80 expect(coverage['scripts'][0]['uri'],
81 endsWith('get_source_report_test.dart')); 81 endsWith('get_source_report_test.dart'));
82 expect(allRangesCompiled(coverage), isFalse); 82 expect(allRangesCompiled(coverage), isFalse);
83 83
84 // Force compilation. 84 // Force compilation.
85 params = { 'reports' : ['Coverage'], 85 params = { 'reports' : ['Coverage'],
86 'scriptId' : func.location.script.id, 86 'scriptId' : func.location.script.id,
87 'forceCompile' : true }; 87 'forceCompile' : true };
88 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); 88 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
89 expect(coverage['type'], equals('SourceReport')); 89 expect(coverage['type'], equals('SourceReport'));
90 expect(coverage['ranges'].length, 6); 90 expect(coverage['ranges'].length, 6);
91 expect(allRangesCompiled(coverage), isTrue); 91 expect(allRangesCompiled(coverage), isTrue);
92 92
93 // One function 93 // One function
94 params = { 'reports' : ['Coverage'], 94 params = { 'reports' : ['Coverage'],
95 'scriptId' : func.location.script.id, 95 'scriptId' : func.location.script.id,
96 'tokenPos' : func.location.tokenPos, 96 'tokenPos' : func.location.tokenPos,
97 'endTokenPos' : func.location.endTokenPos }; 97 'endTokenPos' : func.location.endTokenPos };
98 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); 98 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
99 expect(coverage['type'], equals('SourceReport')); 99 expect(coverage['type'], equals('SourceReport'));
100 expect(coverage['ranges'].length, 1); 100 expect(coverage['ranges'].length, 1);
101 expect(coverage['ranges'][0], equals(expectedRange)); 101 expect(coverage['ranges'][0], equals(expectedRange));
102 expect(coverage['scripts'].length, 1); 102 expect(coverage['scripts'].length, 1);
103 expect(coverage['scripts'][0]['uri'], 103 expect(coverage['scripts'][0]['uri'],
104 endsWith('get_source_report_test.dart')); 104 endsWith('get_source_report_test.dart'));
105 105
106 // Full isolate 106 // Full isolate
107 params = { 'reports' : ['Coverage'] }; 107 params = { 'reports' : ['Coverage'] };
108 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); 108 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
109 expect(coverage['type'], equals('SourceReport')); 109 expect(coverage['type'], equals('SourceReport'));
110 expect(coverage['ranges'].length, greaterThan(1)); 110 expect(coverage['ranges'].length, greaterThan(1));
111 expect(coverage['scripts'].length, greaterThan(1)); 111 expect(coverage['scripts'].length, greaterThan(1));
112 112
113 // Multiple reports (make sure enum list parameter parsing works). 113 // Multiple reports (make sure enum list parameter parsing works).
114 params = { 'reports' : ['_CallSites', 'Coverage', 'PossibleBreakpoints'], 114 params = { 'reports' : ['_CallSites', 'Coverage', 'PossibleBreakpoints'],
115 'scriptId' : func.location.script.id, 115 'scriptId' : func.location.script.id,
116 'tokenPos' : func.location.tokenPos, 116 'tokenPos' : func.location.tokenPos,
117 'endTokenPos' : func.location.endTokenPos }; 117 'endTokenPos' : func.location.endTokenPos };
118 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); 118 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
119 expect(coverage['type'], equals('SourceReport')); 119 expect(coverage['type'], equals('SourceReport'));
120 expect(coverage['ranges'].length, 1); 120 expect(coverage['ranges'].length, 1);
121 var range = coverage['ranges'][0]; 121 var range = coverage['ranges'][0];
122 expect(range.containsKey('callSites'), isTrue); 122 expect(range.containsKey('callSites'), isTrue);
123 expect(range.containsKey('coverage'), isTrue); 123 expect(range.containsKey('coverage'), isTrue);
124 expect(range.containsKey('possibleBreakpoints'), isTrue); 124 expect(range.containsKey('possibleBreakpoints'), isTrue);
125 125
126 // missing scriptId with tokenPos. 126 // missing scriptId with tokenPos.
127 bool caughtException = false; 127 bool caughtException = false;
128 try { 128 try {
129 params = { 'reports' : ['Coverage'], 129 params = { 'reports' : ['Coverage'],
130 'tokenPos' : func.location.tokenPos }; 130 'tokenPos' : func.location.tokenPos };
131 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); 131 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
132 } on ServerRpcException catch(e) { 132 } on ServerRpcException catch(e) {
133 caughtException = true; 133 caughtException = true;
134 expect(e.code, equals(ServerRpcException.kInvalidParams)); 134 expect(e.code, equals(ServerRpcException.kInvalidParams));
135 expect(e.message, 135 expect(e.message,
136 "_getSourceReport: the 'tokenPos' parameter requires the " 136 "getSourceReport: the 'tokenPos' parameter requires the "
137 "\'scriptId\' parameter"); 137 "\'scriptId\' parameter");
138 } 138 }
139 expect(caughtException, isTrue); 139 expect(caughtException, isTrue);
140 140
141 // missing scriptId with endTokenPos. 141 // missing scriptId with endTokenPos.
142 caughtException = false; 142 caughtException = false;
143 try { 143 try {
144 params = { 'reports' : ['Coverage'], 144 params = { 'reports' : ['Coverage'],
145 'endTokenPos' : func.location.endTokenPos }; 145 'endTokenPos' : func.location.endTokenPos };
146 coverage = await isolate.invokeRpcNoUpgrade('_getSourceReport', params); 146 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
147 } on ServerRpcException catch(e) { 147 } on ServerRpcException catch(e) {
148 caughtException = true; 148 caughtException = true;
149 expect(e.code, equals(ServerRpcException.kInvalidParams)); 149 expect(e.code, equals(ServerRpcException.kInvalidParams));
150 expect(e.message, 150 expect(e.message,
151 "_getSourceReport: the 'endTokenPos' parameter requires the " 151 "getSourceReport: the 'endTokenPos' parameter requires the "
152 "\'scriptId\' parameter"); 152 "\'scriptId\' parameter");
153 } 153 }
154 expect(caughtException, isTrue); 154 expect(caughtException, isTrue);
155 }, 155 },
156 156
157 ]; 157 ];
158 158
159 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); 159 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698