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

Side by Side Diff: pkg/analysis_server/test/mocks.dart

Issue 302323002: Add a boolean which causes AnalysisServer to rethrow exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 mocks; 5 library mocks;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 @MirrorsUsed(targets: 'mocks', override: '*') 10 @MirrorsUsed(targets: 'mocks', override: '*')
11 import 'dart:mirrors'; 11 import 'dart:mirrors';
12 12
13 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
14 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
15 import 'package:analysis_server/src/analysis_logger.dart';
16 import 'package:analysis_server/src/analysis_server.dart'; 15 import 'package:analysis_server/src/analysis_server.dart';
17 import 'package:analysis_server/src/channel.dart'; 16 import 'package:analysis_server/src/channel.dart';
18 import 'package:analysis_server/src/protocol.dart'; 17 import 'package:analysis_server/src/protocol.dart';
19 import 'package:matcher/matcher.dart'; 18 import 'package:matcher/matcher.dart';
20 import 'package:mock/mock.dart'; 19 import 'package:mock/mock.dart';
21 import 'package:unittest/unittest.dart'; 20 import 'package:unittest/unittest.dart';
22 21
23 /** 22 /**
24 * Answer the absolute path the the SDK relative to the currently running 23 * Answer the absolute path the the SDK relative to the currently running
25 * script or throw an exception if it cannot be found. 24 * script or throw an exception if it cannot be found.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 new Future(() => responseController.add(response)); 165 new Future(() => responseController.add(response));
167 } 166 }
168 167
169 void expectMsgCount({responseCount: 0, notificationCount: 0}) { 168 void expectMsgCount({responseCount: 0, notificationCount: 0}) {
170 expect(responsesReceived, hasLength(responseCount)); 169 expect(responsesReceived, hasLength(responseCount));
171 expect(notificationsReceived, hasLength(notificationCount)); 170 expect(notificationsReceived, hasLength(notificationCount));
172 } 171 }
173 } 172 }
174 173
175 /** 174 /**
176 * Exception thrown when an unexpected function call is made on a mock.
177 */
178 class UnexpectedMockCall extends Error {
179 UnexpectedMockCall(this.functionName);
180
181 final String functionName;
182
183 String toString() => "Unexpected call to $functionName";
184 }
185
186 /**
187 * Shorthand function for throwing an UnexpectedMockCall exception.
188 */
189 _unexpected(String functionName) {
190 throw new UnexpectedMockCall(functionName);
191 }
192
193 /**
194 * A mock [AnalysisLogger] that treats all errors and warnings as unexpected.
195 */
196 @proxy
197 class MockAnalysisLogger extends Logger {
198
199 void logError(String message) {
200 print(message);
201 _unexpected('MockAnalysisLogger.logError');
202 }
203
204 noSuchMethod(Invocation invocation) {
205 var name = MirrorSystem.getName(invocation.memberName);
206 return _unexpected("MockAnalysisLogger.$name");
207 }
208 }
209
210 /**
211 * A mock [AnalysisContext] for testing [AnalysisServer]. 175 * A mock [AnalysisContext] for testing [AnalysisServer].
212 */ 176 */
213 class MockAnalysisContext extends Mock implements AnalysisContext { 177 class MockAnalysisContext extends Mock implements AnalysisContext {
214 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 178 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
215 } 179 }
216 180
217 /** 181 /**
218 * A mock [Source]. Particularly useful when all that is needed is the 182 * A mock [Source]. Particularly useful when all that is needed is the
219 * encoding. 183 * encoding.
220 */ 184 */
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 Response response = item; 260 Response response = item;
297 var id = response.id; 261 var id = response.id;
298 RequestError error = response.error; 262 RequestError error = response.error;
299 mismatchDescription.add('has identifier "$id"'); 263 mismatchDescription.add('has identifier "$id"');
300 if (error == null) { 264 if (error == null) {
301 mismatchDescription.add(' and has no error'); 265 mismatchDescription.add(' and has no error');
302 } 266 }
303 return mismatchDescription; 267 return mismatchDescription;
304 } 268 }
305 } 269 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698