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

Unified Diff: pkg/analyzer_plugin/test/plugin/mocks.dart

Issue 3008443002: Enhance NavigationMixin to handle notifications (Closed)
Patch Set: Added a test Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer_plugin/test/plugin/mocks.dart
diff --git a/pkg/analyzer_plugin/test/plugin/mocks.dart b/pkg/analyzer_plugin/test/plugin/mocks.dart
index 76df463089d0a25fff889d9efe84f7cc2835a7b0..b8f784d772836a7cb4dd384c49db2d3f22fca699 100644
--- a/pkg/analyzer_plugin/test/plugin/mocks.dart
+++ b/pkg/analyzer_plugin/test/plugin/mocks.dart
@@ -49,9 +49,12 @@ class MockAnalysisDriver extends AnalysisDriver {
class MockChannel implements PluginCommunicationChannel {
bool _closed = false;
- void Function(Request) _onRequest;
- Function _onError;
void Function() _onDone;
+ Function _onError;
+ void Function(Notification) _onNotification;
+ void Function(Request) _onRequest;
+
+ List<Notification> sentNotifications = <Notification>[];
int idCounter = 0;
@@ -64,10 +67,11 @@ class MockChannel implements PluginCommunicationChannel {
@override
void listen(void onRequest(Request request),
- {Function onError, void onDone()}) {
- _onRequest = onRequest;
- _onError = onError;
+ {void onDone(), Function onError, Function onNotification}) {
_onDone = onDone;
+ _onError = onError;
+ _onNotification = onNotification;
+ _onRequest = onRequest;
}
void sendDone() {
@@ -83,10 +87,16 @@ class MockChannel implements PluginCommunicationChannel {
if (_closed) {
throw new StateError('Sent a notification to a closed channel');
}
- fail('Unexpected invocation of sendNotification');
+ if (_onNotification == null) {
+ fail('Unexpected invocation of sendNotification');
+ }
+ _onNotification(notification);
}
Future<Response> sendRequest(RequestParams params) {
+ if (_onRequest == null) {
+ fail('Unexpected invocation of sendNotification');
+ }
String id = (idCounter++).toString();
Request request = params.toRequest(id);
Completer<Response> completer = new Completer<Response>();
@@ -109,9 +119,14 @@ class MockChannel implements PluginCommunicationChannel {
* A concrete implementation of a server plugin that is suitable for testing.
*/
class MockServerPlugin extends ServerPlugin {
+ MockChannel mockChannel = new MockChannel();
+
MockServerPlugin(ResourceProvider resourceProvider) : super(resourceProvider);
@override
+ PluginCommunicationChannel get channel => mockChannel;
+
+ @override
List<String> get fileGlobsToAnalyze => <String>['*.dart'];
@override
« no previous file with comments | « pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart ('k') | pkg/analyzer_plugin/test/plugin/navigation_mixin_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698