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

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

Issue 2751423005: Run dartfmt on all files under runtime. (Closed)
Patch Set: Run dartfmt on all files under runtime. Created 3 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
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 27 matching lines...) Expand all
38 bool allRangesCompiled(coverage) { 38 bool allRangesCompiled(coverage) {
39 for (int i = 0; i < coverage['ranges'].length; i++) { 39 for (int i = 0; i < coverage['ranges'].length; i++) {
40 if (!coverage['ranges'][i]['compiled']) { 40 if (!coverage['ranges'][i]['compiled']) {
41 return false; 41 return false;
42 } 42 }
43 } 43 }
44 return true; 44 return true;
45 } 45 }
46 46
47 var tests = [ 47 var tests = [
48 hasStoppedAtBreakpoint,
49 (Isolate isolate) async {
50 var stack = await isolate.getStack();
48 51
49 hasStoppedAtBreakpoint, 52 // Make sure we are in the right place.
53 expect(stack.type, equals('Stack'));
54 expect(stack['frames'].length, greaterThanOrEqualTo(2));
55 expect(stack['frames'][0].function.name, equals('myFunction'));
56 expect(stack['frames'][0].function.dartOwner.name, equals('MyClass'));
50 57
51 (Isolate isolate) async { 58 var func = stack['frames'][0].function;
52 var stack = await isolate.getStack(); 59 expect(func.name, equals('myFunction'));
60 await func.load();
53 61
54 // Make sure we are in the right place. 62 var expectedRange = {
55 expect(stack.type, equals('Stack')); 63 'scriptIndex': 0,
56 expect(stack['frames'].length, greaterThanOrEqualTo(2)); 64 'startPos': 39,
57 expect(stack['frames'][0].function.name, equals('myFunction')); 65 'endPos': 88,
58 expect(stack['frames'][0].function.dartOwner.name, equals('MyClass')); 66 'compiled': true,
67 'coverage': {
68 'hits': [54, 72, 82],
69 'misses': [60]
70 }
71 };
59 72
60 var func = stack['frames'][0].function; 73 // Full script
61 expect(func.name, equals('myFunction')); 74 var params = {
62 await func.load(); 75 'reports': ['Coverage'],
76 'scriptId': func.location.script.id
77 };
78 var coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
79 expect(coverage['type'], equals('SourceReport'));
80 expect(coverage['ranges'].length, 6);
81 expect(coverage['ranges'][0], equals(expectedRange));
82 expect(coverage['scripts'].length, 1);
83 expect(
84 coverage['scripts'][0]['uri'], endsWith('get_source_report_test.dart'));
85 expect(allRangesCompiled(coverage), isFalse);
63 86
64 var expectedRange = { 87 // Force compilation.
65 'scriptIndex': 0, 88 params = {
66 'startPos': 39, 89 'reports': ['Coverage'],
67 'endPos': 88, 90 'scriptId': func.location.script.id,
68 'compiled': true, 91 'forceCompile': true
69 'coverage': {'hits': [54, 72, 82], 'misses': [60]} 92 };
70 }; 93 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
94 expect(coverage['type'], equals('SourceReport'));
95 expect(coverage['ranges'].length, 6);
96 expect(allRangesCompiled(coverage), isTrue);
71 97
72 // Full script 98 // One function
73 var params = { 'reports' : ['Coverage'], 99 params = {
74 'scriptId' : func.location.script.id }; 100 'reports': ['Coverage'],
75 var coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); 101 'scriptId': func.location.script.id,
76 expect(coverage['type'], equals('SourceReport')); 102 'tokenPos': func.location.tokenPos,
77 expect(coverage['ranges'].length, 6); 103 'endTokenPos': func.location.endTokenPos
78 expect(coverage['ranges'][0], equals(expectedRange)); 104 };
79 expect(coverage['scripts'].length, 1); 105 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
80 expect(coverage['scripts'][0]['uri'], 106 expect(coverage['type'], equals('SourceReport'));
81 endsWith('get_source_report_test.dart')); 107 expect(coverage['ranges'].length, 1);
82 expect(allRangesCompiled(coverage), isFalse); 108 expect(coverage['ranges'][0], equals(expectedRange));
109 expect(coverage['scripts'].length, 1);
110 expect(
111 coverage['scripts'][0]['uri'], endsWith('get_source_report_test.dart'));
83 112
84 // Force compilation. 113 // Full isolate
85 params = { 'reports' : ['Coverage'], 114 params = {
86 'scriptId' : func.location.script.id, 115 'reports': ['Coverage']
87 'forceCompile' : true }; 116 };
88 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); 117 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
89 expect(coverage['type'], equals('SourceReport')); 118 expect(coverage['type'], equals('SourceReport'));
90 expect(coverage['ranges'].length, 6); 119 expect(coverage['ranges'].length, greaterThan(1));
91 expect(allRangesCompiled(coverage), isTrue); 120 expect(coverage['scripts'].length, greaterThan(1));
92 121
93 // One function 122 // Multiple reports (make sure enum list parameter parsing works).
94 params = { 'reports' : ['Coverage'], 123 params = {
95 'scriptId' : func.location.script.id, 124 'reports': ['_CallSites', 'Coverage', 'PossibleBreakpoints'],
96 'tokenPos' : func.location.tokenPos, 125 'scriptId': func.location.script.id,
97 'endTokenPos' : func.location.endTokenPos }; 126 'tokenPos': func.location.tokenPos,
98 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); 127 'endTokenPos': func.location.endTokenPos
99 expect(coverage['type'], equals('SourceReport')); 128 };
100 expect(coverage['ranges'].length, 1); 129 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
101 expect(coverage['ranges'][0], equals(expectedRange)); 130 expect(coverage['type'], equals('SourceReport'));
102 expect(coverage['scripts'].length, 1); 131 expect(coverage['ranges'].length, 1);
103 expect(coverage['scripts'][0]['uri'], 132 var range = coverage['ranges'][0];
104 endsWith('get_source_report_test.dart')); 133 expect(range.containsKey('callSites'), isTrue);
134 expect(range.containsKey('coverage'), isTrue);
135 expect(range.containsKey('possibleBreakpoints'), isTrue);
105 136
106 // Full isolate 137 // missing scriptId with tokenPos.
107 params = { 'reports' : ['Coverage'] }; 138 bool caughtException = false;
108 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); 139 try {
109 expect(coverage['type'], equals('SourceReport')); 140 params = {
110 expect(coverage['ranges'].length, greaterThan(1)); 141 'reports': ['Coverage'],
111 expect(coverage['scripts'].length, greaterThan(1)); 142 'tokenPos': func.location.tokenPos
143 };
144 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
145 } on ServerRpcException catch (e) {
146 caughtException = true;
147 expect(e.code, equals(ServerRpcException.kInvalidParams));
148 expect(
149 e.message,
150 "getSourceReport: the 'tokenPos' parameter requires the "
151 "\'scriptId\' parameter");
152 }
153 expect(caughtException, isTrue);
112 154
113 // Multiple reports (make sure enum list parameter parsing works). 155 // missing scriptId with endTokenPos.
114 params = { 'reports' : ['_CallSites', 'Coverage', 'PossibleBreakpoints'], 156 caughtException = false;
115 'scriptId' : func.location.script.id, 157 try {
116 'tokenPos' : func.location.tokenPos, 158 params = {
117 'endTokenPos' : func.location.endTokenPos }; 159 'reports': ['Coverage'],
118 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params); 160 'endTokenPos': func.location.endTokenPos
119 expect(coverage['type'], equals('SourceReport')); 161 };
120 expect(coverage['ranges'].length, 1); 162 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
121 var range = coverage['ranges'][0]; 163 } on ServerRpcException catch (e) {
122 expect(range.containsKey('callSites'), isTrue); 164 caughtException = true;
123 expect(range.containsKey('coverage'), isTrue); 165 expect(e.code, equals(ServerRpcException.kInvalidParams));
124 expect(range.containsKey('possibleBreakpoints'), isTrue); 166 expect(
125 167 e.message,
126 // missing scriptId with tokenPos. 168 "getSourceReport: the 'endTokenPos' parameter requires the "
127 bool caughtException = false; 169 "\'scriptId\' parameter");
128 try { 170 }
129 params = { 'reports' : ['Coverage'], 171 expect(caughtException, isTrue);
130 'tokenPos' : func.location.tokenPos }; 172 },
131 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
132 } on ServerRpcException catch(e) {
133 caughtException = true;
134 expect(e.code, equals(ServerRpcException.kInvalidParams));
135 expect(e.message,
136 "getSourceReport: the 'tokenPos' parameter requires the "
137 "\'scriptId\' parameter");
138 }
139 expect(caughtException, isTrue);
140
141 // missing scriptId with endTokenPos.
142 caughtException = false;
143 try {
144 params = { 'reports' : ['Coverage'],
145 'endTokenPos' : func.location.endTokenPos };
146 coverage = await isolate.invokeRpcNoUpgrade('getSourceReport', params);
147 } on ServerRpcException catch(e) {
148 caughtException = true;
149 expect(e.code, equals(ServerRpcException.kInvalidParams));
150 expect(e.message,
151 "getSourceReport: the 'endTokenPos' parameter requires the "
152 "\'scriptId\' parameter");
153 }
154 expect(caughtException, isTrue);
155 },
156
157 ]; 173 ];
158 174
159 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); 175 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698