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

Unified Diff: pkg/analysis_server/test/channel/web_socket_channel_test.dart

Issue 2959713002: Remove more dead code (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/channel/web_socket_channel_test.dart
diff --git a/pkg/analysis_server/test/channel/web_socket_channel_test.dart b/pkg/analysis_server/test/channel/web_socket_channel_test.dart
deleted file mode 100644
index 0a7a35bd74d8a6854644b6a3f33fad0fdaa1782d..0000000000000000000000000000000000000000
--- a/pkg/analysis_server/test/channel/web_socket_channel_test.dart
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:analysis_server/protocol/protocol.dart';
-import 'package:analysis_server/src/channel/web_socket_channel.dart';
-import 'package:analyzer/instrumentation/instrumentation.dart';
-import 'package:test/test.dart';
-
-import '../mocks.dart';
-
-main() {
- group('WebSocketChannel', () {
- setUp(WebSocketChannelTest.setUp);
- test('close', WebSocketChannelTest.close);
- test('invalidJsonToClient', WebSocketChannelTest.invalidJsonToClient);
- test('invalidJsonToServer', WebSocketChannelTest.invalidJsonToServer);
- test('notification', WebSocketChannelTest.notification);
- test('notificationAndResponse',
- WebSocketChannelTest.notificationAndResponse);
- test('request', WebSocketChannelTest.request);
- test('requestResponse', WebSocketChannelTest.requestResponse);
- test('response', WebSocketChannelTest.response);
- });
-}
-
-class WebSocketChannelTest {
- static MockSocket socket;
- static WebSocketClientChannel client;
- static WebSocketServerChannel server;
-
- static List<Request> requestsReceived;
- static List<Response> responsesReceived;
- static List<Notification> notificationsReceived;
-
- static Future close() {
- var timeout = new Duration(seconds: 1);
- var future = client.responseStream.drain().timeout(timeout);
- client.close();
- return future;
- }
-
- static void expectMsgCount(
- {requestCount: 0, responseCount: 0, notificationCount: 0}) {
- expect(requestsReceived, hasLength(requestCount));
- expect(responsesReceived, hasLength(responseCount));
- expect(notificationsReceived, hasLength(notificationCount));
- }
-
- static Future invalidJsonToClient() {
- var result = client.responseStream.first
- .timeout(new Duration(seconds: 1))
- .then((Response response) {
- expect(response.id, equals('myId'));
- expectMsgCount(responseCount: 1);
- });
- socket.twin.add('{"foo":"bar"}');
- server.sendResponse(new Response('myId'));
- return result;
- }
-
- static Future invalidJsonToServer() {
- var result = client.responseStream.first
- .timeout(new Duration(seconds: 1))
- .then((Response response) {
- expect(response.id, equals(''));
- expect(response.error, isNotNull);
- expectMsgCount(responseCount: 1);
- });
- socket.add('"blat"');
- return result;
- }
-
- static Future notification() {
- var result = client.notificationStream.first
- .timeout(new Duration(seconds: 1))
- .then((Notification notification) {
- expect(notification.event, equals('myEvent'));
- expectMsgCount(notificationCount: 1);
- expect(notificationsReceived.first, equals(notification));
- });
- server.sendNotification(new Notification('myEvent'));
- return result;
- }
-
- static Future notificationAndResponse() {
- var result = Future
- .wait([client.notificationStream.first, client.responseStream.first])
- .timeout(new Duration(seconds: 1))
- .then((_) => expectMsgCount(responseCount: 1, notificationCount: 1));
- server
- ..sendNotification(new Notification('myEvent'))
- ..sendResponse(new Response('myId'));
- return result;
- }
-
- static void request() {
- client.sendRequest(new Request('myId', 'myMth'));
- server.listen((Request request) {
- expect(request.id, equals('myId'));
- expect(request.method, equals('myMth'));
- expectMsgCount(requestCount: 1);
- });
- }
-
- static Future requestResponse() {
- // Simulate server sending a response by echoing the request.
- server.listen(
- (Request request) => server.sendResponse(new Response(request.id)));
- return client
- .sendRequest(new Request('myId', 'myMth'))
- .timeout(new Duration(seconds: 1))
- .then((Response response) {
- expect(response.id, equals('myId'));
- expectMsgCount(requestCount: 1, responseCount: 1);
-
- expect(requestsReceived.first is Request, isTrue);
- Request request = requestsReceived.first;
- expect(request.id, equals('myId'));
- expect(request.method, equals('myMth'));
- expect(responsesReceived.first, equals(response));
- });
- }
-
- static Future response() {
- server.sendResponse(new Response('myId'));
- return client.responseStream.first
- .timeout(new Duration(seconds: 1))
- .then((Response response) {
- expect(response.id, equals('myId'));
- expectMsgCount(responseCount: 1);
- });
- }
-
- static void setUp() {
- socket = new MockSocket.pair();
- client = new WebSocketClientChannel(socket);
- server = new WebSocketServerChannel(
- socket.twin, InstrumentationService.NULL_SERVICE);
-
- requestsReceived = <Request>[];
- responsesReceived = <Response>[];
- notificationsReceived = <Notification>[];
-
- // Allow multiple listeners on server side for testing.
- socket.twin.allowMultipleListeners();
-
- server.listen(requestsReceived.add);
- client.responseStream.listen(responsesReceived.add);
- client.notificationStream.listen(notificationsReceived.add);
- }
-}
« no previous file with comments | « pkg/analysis_server/test/channel/test_all.dart ('k') | pkg/analysis_server/test/services/correction/source_range_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698