OLD | NEW |
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 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; |
10 import 'package:analysis_server/src/analysis_server.dart'; | 12 import 'package:analysis_server/src/analysis_server.dart'; |
11 import 'package:analysis_server/src/channel.dart'; | 13 import 'package:analysis_server/src/channel.dart'; |
12 import 'package:analysis_server/src/protocol.dart'; | 14 import 'package:analysis_server/src/protocol.dart'; |
13 import 'package:unittest/matcher.dart'; | 15 import 'package:unittest/matcher.dart'; |
14 | 16 |
15 /** | 17 /** |
16 * Answer the absolute path the the SDK relative to the currently running | 18 * Answer the absolute path the the SDK relative to the currently running |
17 * script or throw an exception if it cannot be found. | 19 * script or throw an exception if it cannot be found. |
18 */ | 20 */ |
19 String get sdkPath { | 21 String get sdkPath { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 StreamController<Response> responseController = new StreamController<Response>
(); | 77 StreamController<Response> responseController = new StreamController<Response>
(); |
76 StreamController<Notification> notificationController = new StreamController<N
otification>(); | 78 StreamController<Notification> notificationController = new StreamController<N
otification>(); |
77 | 79 |
78 List<Response> responsesReceived = []; | 80 List<Response> responsesReceived = []; |
79 List<Notification> notificationsReceived = []; | 81 List<Notification> notificationsReceived = []; |
80 | 82 |
81 MockServerChannel() { | 83 MockServerChannel() { |
82 } | 84 } |
83 | 85 |
84 @override | 86 @override |
85 void listen(void onRequest(Request request), {void onError(), void onDone()})
{ | 87 void listen(void onRequest(Request request), {Function onError, void onDone()}
) { |
86 requestController.stream.listen(onRequest, onError: onError, onDone: onDone)
; | 88 requestController.stream.listen(onRequest, onError: onError, onDone: onDone)
; |
87 } | 89 } |
88 | 90 |
89 @override | 91 @override |
90 void sendNotification(Notification notification) { | 92 void sendNotification(Notification notification) { |
91 notificationsReceived.add(notification); | 93 notificationsReceived.add(notification); |
92 // Wrap send notification in future to simulate websocket | 94 // Wrap send notification in future to simulate websocket |
93 new Future(() => notificationController.add(notification)); | 95 new Future(() => notificationController.add(notification)); |
94 } | 96 } |
95 | 97 |
(...skipping 10 matching lines...) Expand all Loading... |
106 responsesReceived.add(response); | 108 responsesReceived.add(response); |
107 // Wrap send response in future to simulate websocket | 109 // Wrap send response in future to simulate websocket |
108 new Future(() => responseController.add(response)); | 110 new Future(() => responseController.add(response)); |
109 } | 111 } |
110 | 112 |
111 void expectMsgCount({responseCount: 0, notificationCount: 0}) { | 113 void expectMsgCount({responseCount: 0, notificationCount: 0}) { |
112 expect(responsesReceived, hasLength(responseCount)); | 114 expect(responsesReceived, hasLength(responseCount)); |
113 expect(notificationsReceived, hasLength(notificationCount)); | 115 expect(notificationsReceived, hasLength(notificationCount)); |
114 } | 116 } |
115 } | 117 } |
OLD | NEW |