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

Unified Diff: pkg/analysis_server/test/mocks.dart

Issue 182903005: split client and server channels (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 6 years, 10 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
« no previous file with comments | « pkg/analysis_server/test/channel_test.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/mocks.dart
diff --git a/pkg/analysis_server/test/mocks.dart b/pkg/analysis_server/test/mocks.dart
index 186d6d079ef6ea9f0bc6c5ab67fee1550766f5f1..1c87b0e331bd0b7d75ef2cd5c316f3ae46c82633 100644
--- a/pkg/analysis_server/test/mocks.dart
+++ b/pkg/analysis_server/test/mocks.dart
@@ -4,15 +4,35 @@
library mocks;
-import 'package:analysis_server/src/channel.dart';
+import 'dart:io';
+import 'dart:async';
/**
- * Instances of the class [MockChannel] implement a [CommunicationChannel] that
- * does nothing in response to every method invoked on it.
+ * A mock [WebSocket] that immediately passes data to the listener.
*/
-class MockChannel implements CommunicationChannel {
- dynamic noSuchMethod(Invocation invocation) {
- // Do nothing
+class MockSocket<T> implements WebSocket {
+ var onData;
+ StreamSubscription<T> listen(void onData(T event),
+ {Function onError, void onDone(), bool cancelOnError}) {
+ this.onData = onData;
return null;
}
+ void add(T event) => onData(event);
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
+
+/**
+ * A mock [WebSocket] for sending invalid JSON data and counting responses.
+ */
+class InvalidJsonMockSocket<T> implements WebSocket {
+ int responseCount = 0;
+ var onData;
+ StreamSubscription<T> listen(void onData(T event),
+ {Function onError, void onDone(), bool cancelOnError}) {
+ this.onData = onData;
+ return null;
+ }
+ void addInvalid(T event) => onData(event);
+ void add(T event) { responseCount++; }
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
« no previous file with comments | « pkg/analysis_server/test/channel_test.dart ('k') | pkg/analysis_server/test/protocol_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698