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

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

Issue 801543002: Rework instrumentation API (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean-up Created 6 years 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
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 test.socket.server; 5 library test.socket.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
(...skipping 18 matching lines...) Expand all
29 'requestHandler_futureException', 29 'requestHandler_futureException',
30 SocketServerTest.requestHandler_futureException); 30 SocketServerTest.requestHandler_futureException);
31 }); 31 });
32 } 32 }
33 33
34 class SocketServerTest { 34 class SocketServerTest {
35 static void createAnalysisServer_alreadyStarted() { 35 static void createAnalysisServer_alreadyStarted() {
36 SocketServer server = new SocketServer( 36 SocketServer server = new SocketServer(
37 new AnalysisServerOptions(), 37 new AnalysisServerOptions(),
38 DirectoryBasedDartSdk.defaultSdk, 38 DirectoryBasedDartSdk.defaultSdk,
39 new NullInstrumentationServer()); 39 InstrumentationService.NULL_SERVICE);
40 MockServerChannel channel1 = new MockServerChannel(); 40 MockServerChannel channel1 = new MockServerChannel();
41 MockServerChannel channel2 = new MockServerChannel(); 41 MockServerChannel channel2 = new MockServerChannel();
42 server.createAnalysisServer(channel1); 42 server.createAnalysisServer(channel1);
43 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED); 43 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED);
44 server.createAnalysisServer(channel2); 44 server.createAnalysisServer(channel2);
45 channel1.expectMsgCount(notificationCount: 1); 45 channel1.expectMsgCount(notificationCount: 1);
46 channel2.expectMsgCount(responseCount: 1); 46 channel2.expectMsgCount(responseCount: 1);
47 expect(channel2.responsesReceived[0].id, equals('')); 47 expect(channel2.responsesReceived[0].id, equals(''));
48 expect(channel2.responsesReceived[0].error, isNotNull); 48 expect(channel2.responsesReceived[0].error, isNotNull);
49 expect( 49 expect(
50 channel2.responsesReceived[0].error.code, 50 channel2.responsesReceived[0].error.code,
51 equals(RequestErrorCode.SERVER_ALREADY_STARTED)); 51 equals(RequestErrorCode.SERVER_ALREADY_STARTED));
52 channel2.sendRequest( 52 channel2.sendRequest(
53 new ServerShutdownParams().toRequest('0')).then((Response response) { 53 new ServerShutdownParams().toRequest('0')).then((Response response) {
54 expect(response.id, equals('0')); 54 expect(response.id, equals('0'));
55 expect(response.error, isNotNull); 55 expect(response.error, isNotNull);
56 expect( 56 expect(
57 response.error.code, 57 response.error.code,
58 equals(RequestErrorCode.SERVER_ALREADY_STARTED)); 58 equals(RequestErrorCode.SERVER_ALREADY_STARTED));
59 channel2.expectMsgCount(responseCount: 2); 59 channel2.expectMsgCount(responseCount: 2);
60 }); 60 });
61 } 61 }
62 62
63 static Future createAnalysisServer_successful() { 63 static Future createAnalysisServer_successful() {
64 SocketServer server = new SocketServer( 64 SocketServer server = new SocketServer(
65 new AnalysisServerOptions(), 65 new AnalysisServerOptions(),
66 DirectoryBasedDartSdk.defaultSdk, 66 DirectoryBasedDartSdk.defaultSdk,
67 new NullInstrumentationServer()); 67 InstrumentationService.NULL_SERVICE);
68 MockServerChannel channel = new MockServerChannel(); 68 MockServerChannel channel = new MockServerChannel();
69 server.createAnalysisServer(channel); 69 server.createAnalysisServer(channel);
70 channel.expectMsgCount(notificationCount: 1); 70 channel.expectMsgCount(notificationCount: 1);
71 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); 71 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED);
72 return channel.sendRequest( 72 return channel.sendRequest(
73 new ServerShutdownParams().toRequest('0')).then((Response response) { 73 new ServerShutdownParams().toRequest('0')).then((Response response) {
74 expect(response.id, equals('0')); 74 expect(response.id, equals('0'));
75 expect(response.error, isNull); 75 expect(response.error, isNull);
76 channel.expectMsgCount(responseCount: 1, notificationCount: 1); 76 channel.expectMsgCount(responseCount: 1, notificationCount: 1);
77 }); 77 });
78 } 78 }
79 79
80 static Future requestHandler_exception() { 80 static Future requestHandler_exception() {
81 SocketServer server = new SocketServer( 81 SocketServer server = new SocketServer(
82 new AnalysisServerOptions(), 82 new AnalysisServerOptions(),
83 DirectoryBasedDartSdk.defaultSdk, 83 DirectoryBasedDartSdk.defaultSdk,
84 new NullInstrumentationServer()); 84 InstrumentationService.NULL_SERVICE);
85 MockServerChannel channel = new MockServerChannel(); 85 MockServerChannel channel = new MockServerChannel();
86 server.createAnalysisServer(channel); 86 server.createAnalysisServer(channel);
87 channel.expectMsgCount(notificationCount: 1); 87 channel.expectMsgCount(notificationCount: 1);
88 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); 88 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED);
89 _MockRequestHandler handler = new _MockRequestHandler(false); 89 _MockRequestHandler handler = new _MockRequestHandler(false);
90 server.analysisServer.handlers = [handler]; 90 server.analysisServer.handlers = [handler];
91 var request = new ServerGetVersionParams().toRequest('0'); 91 var request = new ServerGetVersionParams().toRequest('0');
92 return channel.sendRequest(request).then((Response response) { 92 return channel.sendRequest(request).then((Response response) {
93 expect(response.id, equals('0')); 93 expect(response.id, equals('0'));
94 expect(response.error, isNotNull); 94 expect(response.error, isNotNull);
95 expect(response.error.code, equals(RequestErrorCode.SERVER_ERROR)); 95 expect(response.error.code, equals(RequestErrorCode.SERVER_ERROR));
96 expect(response.error.message, equals('mock request exception')); 96 expect(response.error.message, equals('mock request exception'));
97 expect(response.error.stackTrace, isNotNull); 97 expect(response.error.stackTrace, isNotNull);
98 expect(response.error.stackTrace, isNot(isEmpty)); 98 expect(response.error.stackTrace, isNot(isEmpty));
99 channel.expectMsgCount(responseCount: 1, notificationCount: 1); 99 channel.expectMsgCount(responseCount: 1, notificationCount: 1);
100 }); 100 });
101 } 101 }
102 102
103 static Future requestHandler_futureException() { 103 static Future requestHandler_futureException() {
104 SocketServer server = new SocketServer( 104 SocketServer server = new SocketServer(
105 new AnalysisServerOptions(), 105 new AnalysisServerOptions(),
106 DirectoryBasedDartSdk.defaultSdk, 106 DirectoryBasedDartSdk.defaultSdk,
107 new NullInstrumentationServer()); 107 InstrumentationService.NULL_SERVICE);
108 MockServerChannel channel = new MockServerChannel(); 108 MockServerChannel channel = new MockServerChannel();
109 server.createAnalysisServer(channel); 109 server.createAnalysisServer(channel);
110 _MockRequestHandler handler = new _MockRequestHandler(true); 110 _MockRequestHandler handler = new _MockRequestHandler(true);
111 server.analysisServer.handlers = [handler]; 111 server.analysisServer.handlers = [handler];
112 var request = new ServerGetVersionParams().toRequest('0'); 112 var request = new ServerGetVersionParams().toRequest('0');
113 return channel.sendRequest(request).then((Response response) { 113 return channel.sendRequest(request).then((Response response) {
114 expect(response.id, equals('0')); 114 expect(response.id, equals('0'));
115 expect(response.error, isNull); 115 expect(response.error, isNull);
116 channel.expectMsgCount(responseCount: 1, notificationCount: 2); 116 channel.expectMsgCount(responseCount: 1, notificationCount: 2);
117 expect(channel.notificationsReceived[1].event, SERVER_ERROR); 117 expect(channel.notificationsReceived[1].event, SERVER_ERROR);
(...skipping 12 matching lines...) Expand all
130 new Future(throwException); 130 new Future(throwException);
131 return new Response(request.id); 131 return new Response(request.id);
132 } 132 }
133 throw 'mock request exception'; 133 throw 'mock request exception';
134 } 134 }
135 135
136 void throwException() { 136 void throwException() {
137 throw 'mock future exception'; 137 throw 'mock future exception';
138 } 138 }
139 } 139 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/domain_server_test.dart ('k') | pkg/analyzer/lib/instrumentation/instrumentation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698