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

Side by Side Diff: pkg/analyzer/test/instrumentation/instrumentation_test.dart

Issue 2834453002: Add support for reporting plugin data to instrumentation (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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 4
5 library analyzer.test.instrumentation.instrumentation_test; 5 library analyzer.test.instrumentation.instrumentation_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/instrumentation/instrumentation.dart'; 9 import 'package:analyzer/instrumentation/instrumentation.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 void test_logNotification() { 83 void test_logNotification() {
84 TestInstrumentationServer server = new TestInstrumentationServer(); 84 TestInstrumentationServer server = new TestInstrumentationServer();
85 InstrumentationService service = new InstrumentationService(server); 85 InstrumentationService service = new InstrumentationService(server);
86 String message = 'notificationText'; 86 String message = 'notificationText';
87 service.logNotification(message); 87 service.logNotification(message);
88 assertNormal(server, InstrumentationService.TAG_NOTIFICATION, message); 88 assertNormal(server, InstrumentationService.TAG_NOTIFICATION, message);
89 } 89 }
90 90
91 void test_logPluginError() {
92 TestInstrumentationServer server = new TestInstrumentationServer();
93 InstrumentationService service = new InstrumentationService(server);
94 PluginData plugin = new PluginData('path', 'name', 'version');
95 String code = 'code';
96 String message = 'exceptionMessage';
97 String stackTraceText = 'stackTrace';
98 service.logPluginError(plugin, code, message, stackTraceText);
99 assertNormal(server, InstrumentationService.TAG_PLUGIN_ERROR,
100 '$code:$message:$stackTraceText:path:name:version');
101 }
102
103 void test_logPluginException_noTrace() {
104 TestInstrumentationServer server = new TestInstrumentationServer();
105 InstrumentationService service = new InstrumentationService(server);
106 PluginData plugin = new PluginData('path', 'name', 'version');
107 String message = 'exceptionMessage';
108 service.logPluginException(plugin, message, null);
109 assertNormal(server, InstrumentationService.TAG_PLUGIN_EXCEPTION,
110 '$message:null:path:name:version');
111 }
112
113 void test_logPluginException_withTrace() {
114 TestInstrumentationServer server = new TestInstrumentationServer();
115 InstrumentationService service = new InstrumentationService(server);
116 PluginData plugin = new PluginData('path', 'name', 'version');
117 String message = 'exceptionMessage';
118 String stackTraceText = 'stackTrace';
119 StackTrace stackTrace = new StackTrace.fromString(stackTraceText);
120 service.logPluginException(plugin, message, stackTrace);
121 assertNormal(server, InstrumentationService.TAG_PLUGIN_EXCEPTION,
122 '$message:$stackTraceText:path:name:version');
123 }
124
125 void test_logPluginNotification() {
126 TestInstrumentationServer server = new TestInstrumentationServer();
127 InstrumentationService service = new InstrumentationService(server);
128 Uri uri = new Uri.file('path');
129 String notification = 'notification';
130 service.logPluginNotification(uri, notification);
131 assertNormal(server, InstrumentationService.TAG_PLUGIN_NOTIFICATION,
132 'path:$notification');
133 }
134
135 void test_logPluginRequest() {
136 TestInstrumentationServer server = new TestInstrumentationServer();
137 InstrumentationService service = new InstrumentationService(server);
138 Uri uri = new Uri.file('path');
139 String request = 'request';
140 service.logPluginRequest(uri, request);
141 assertNormal(
142 server, InstrumentationService.TAG_PLUGIN_REQUEST, 'path:$request');
143 }
144
145 void test_logPluginResponse() {
146 TestInstrumentationServer server = new TestInstrumentationServer();
147 InstrumentationService service = new InstrumentationService(server);
148 Uri uri = new Uri.file('path');
149 String response = 'response';
150 service.logPluginResponse(uri, response);
151 assertNormal(
152 server, InstrumentationService.TAG_PLUGIN_RESPONSE, 'path:$response');
153 }
154
155 void test_logPluginTimeout() {
156 TestInstrumentationServer server = new TestInstrumentationServer();
157 InstrumentationService service = new InstrumentationService(server);
158 PluginData plugin = new PluginData('path', 'name', 'version');
159 String request = 'request';
160 service.logPluginTimeout(plugin, request);
161 assertNormal(server, InstrumentationService.TAG_PLUGIN_TIMEOUT,
162 '$request:path:name:version');
163 }
164
91 void test_logRequest() { 165 void test_logRequest() {
92 TestInstrumentationServer server = new TestInstrumentationServer(); 166 TestInstrumentationServer server = new TestInstrumentationServer();
93 InstrumentationService service = new InstrumentationService(server); 167 InstrumentationService service = new InstrumentationService(server);
94 String message = 'requestText'; 168 String message = 'requestText';
95 service.logRequest(message); 169 service.logRequest(message);
96 assertNormal(server, InstrumentationService.TAG_REQUEST, message); 170 assertNormal(server, InstrumentationService.TAG_REQUEST, message);
97 } 171 }
98 172
99 void test_logResponse() { 173 void test_logResponse() {
100 TestInstrumentationServer server = new TestInstrumentationServer(); 174 TestInstrumentationServer server = new TestInstrumentationServer();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 fail('Expected "...$message", found "$sent"'); 230 fail('Expected "...$message", found "$sent"');
157 } 231 }
158 } 232 }
159 } 233 }
160 234
161 class TestInstrumentationServer implements InstrumentationServer { 235 class TestInstrumentationServer implements InstrumentationServer {
162 StringBuffer normalChannel = new StringBuffer(); 236 StringBuffer normalChannel = new StringBuffer();
163 StringBuffer priorityChannel = new StringBuffer(); 237 StringBuffer priorityChannel = new StringBuffer();
164 238
165 @override 239 @override
240 String get describe => 'test instrumentation';
241
242 @override
166 String get sessionId => ''; 243 String get sessionId => '';
167 244
168 @override 245 @override
169 String get describe => 'test instrumentation';
170
171 @override
172 void log(String message) { 246 void log(String message) {
173 normalChannel.writeln(message); 247 normalChannel.writeln(message);
174 } 248 }
175 249
176 @override 250 @override
177 void logWithPriority(String message) { 251 void logWithPriority(String message) {
178 priorityChannel.writeln(message); 252 priorityChannel.writeln(message);
179 } 253 }
180 254
181 @override 255 @override
182 Future shutdown() async { 256 Future shutdown() async {
183 // Ignored 257 // Ignored
184 } 258 }
185 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698