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

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

Issue 756193002: Add --enable-incremental-resolution option. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « pkg/analysis_server/test/domain_server_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
10 import 'package:analysis_server/src/protocol.dart'; 11 import 'package:analysis_server/src/protocol.dart';
11 import 'package:analysis_server/src/socket_server.dart'; 12 import 'package:analysis_server/src/socket_server.dart';
12 import 'package:analyzer/src/generated/sdk_io.dart'; 13 import 'package:analyzer/src/generated/sdk_io.dart';
13 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
14 15
15 import 'mocks.dart'; 16 import 'mocks.dart';
16 17
17 main() { 18 main() {
18 group('SocketServer', () { 19 group('SocketServer', () {
19 test( 20 test(
20 'createAnalysisServer_successful', 21 'createAnalysisServer_successful',
21 SocketServerTest.createAnalysisServer_successful); 22 SocketServerTest.createAnalysisServer_successful);
22 test( 23 test(
23 'createAnalysisServer_alreadyStarted', 24 'createAnalysisServer_alreadyStarted',
24 SocketServerTest.createAnalysisServer_alreadyStarted); 25 SocketServerTest.createAnalysisServer_alreadyStarted);
25 test('requestHandler_exception', SocketServerTest.requestHandler_exception); 26 test('requestHandler_exception', SocketServerTest.requestHandler_exception);
26 test( 27 test(
27 'requestHandler_futureException', 28 'requestHandler_futureException',
28 SocketServerTest.requestHandler_futureException); 29 SocketServerTest.requestHandler_futureException);
29 }); 30 });
30 } 31 }
31 32
32 class SocketServerTest { 33 class SocketServerTest {
33 static void createAnalysisServer_alreadyStarted() { 34 static void createAnalysisServer_alreadyStarted() {
34 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); 35 SocketServer server = new SocketServer(
36 new AnalysisServerOptions(),
37 DirectoryBasedDartSdk.defaultSdk);
35 MockServerChannel channel1 = new MockServerChannel(); 38 MockServerChannel channel1 = new MockServerChannel();
36 MockServerChannel channel2 = new MockServerChannel(); 39 MockServerChannel channel2 = new MockServerChannel();
37 server.createAnalysisServer(channel1); 40 server.createAnalysisServer(channel1);
38 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED); 41 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED);
39 server.createAnalysisServer(channel2); 42 server.createAnalysisServer(channel2);
40 channel1.expectMsgCount(notificationCount: 1); 43 channel1.expectMsgCount(notificationCount: 1);
41 channel2.expectMsgCount(responseCount: 1); 44 channel2.expectMsgCount(responseCount: 1);
42 expect(channel2.responsesReceived[0].id, equals('')); 45 expect(channel2.responsesReceived[0].id, equals(''));
43 expect(channel2.responsesReceived[0].error, isNotNull); 46 expect(channel2.responsesReceived[0].error, isNotNull);
44 expect( 47 expect(
45 channel2.responsesReceived[0].error.code, 48 channel2.responsesReceived[0].error.code,
46 equals(RequestErrorCode.SERVER_ALREADY_STARTED)); 49 equals(RequestErrorCode.SERVER_ALREADY_STARTED));
47 channel2.sendRequest( 50 channel2.sendRequest(
48 new ServerShutdownParams().toRequest('0')).then((Response response) { 51 new ServerShutdownParams().toRequest('0')).then((Response response) {
49 expect(response.id, equals('0')); 52 expect(response.id, equals('0'));
50 expect(response.error, isNotNull); 53 expect(response.error, isNotNull);
51 expect( 54 expect(
52 response.error.code, 55 response.error.code,
53 equals(RequestErrorCode.SERVER_ALREADY_STARTED)); 56 equals(RequestErrorCode.SERVER_ALREADY_STARTED));
54 channel2.expectMsgCount(responseCount: 2); 57 channel2.expectMsgCount(responseCount: 2);
55 }); 58 });
56 } 59 }
57 60
58 static Future createAnalysisServer_successful() { 61 static Future createAnalysisServer_successful() {
59 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); 62 SocketServer server = new SocketServer(
63 new AnalysisServerOptions(),
64 DirectoryBasedDartSdk.defaultSdk);
60 MockServerChannel channel = new MockServerChannel(); 65 MockServerChannel channel = new MockServerChannel();
61 server.createAnalysisServer(channel); 66 server.createAnalysisServer(channel);
62 channel.expectMsgCount(notificationCount: 1); 67 channel.expectMsgCount(notificationCount: 1);
63 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); 68 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED);
64 return channel.sendRequest( 69 return channel.sendRequest(
65 new ServerShutdownParams().toRequest('0')).then((Response response) { 70 new ServerShutdownParams().toRequest('0')).then((Response response) {
66 expect(response.id, equals('0')); 71 expect(response.id, equals('0'));
67 expect(response.error, isNull); 72 expect(response.error, isNull);
68 channel.expectMsgCount(responseCount: 1, notificationCount: 1); 73 channel.expectMsgCount(responseCount: 1, notificationCount: 1);
69 }); 74 });
70 } 75 }
71 76
72 static Future requestHandler_exception() { 77 static Future requestHandler_exception() {
73 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); 78 SocketServer server = new SocketServer(
79 new AnalysisServerOptions(),
80 DirectoryBasedDartSdk.defaultSdk);
74 MockServerChannel channel = new MockServerChannel(); 81 MockServerChannel channel = new MockServerChannel();
75 server.createAnalysisServer(channel); 82 server.createAnalysisServer(channel);
76 channel.expectMsgCount(notificationCount: 1); 83 channel.expectMsgCount(notificationCount: 1);
77 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); 84 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED);
78 _MockRequestHandler handler = new _MockRequestHandler(false); 85 _MockRequestHandler handler = new _MockRequestHandler(false);
79 server.analysisServer.handlers = [handler]; 86 server.analysisServer.handlers = [handler];
80 var request = new ServerGetVersionParams().toRequest('0'); 87 var request = new ServerGetVersionParams().toRequest('0');
81 return channel.sendRequest(request).then((Response response) { 88 return channel.sendRequest(request).then((Response response) {
82 expect(response.id, equals('0')); 89 expect(response.id, equals('0'));
83 expect(response.error, isNotNull); 90 expect(response.error, isNotNull);
84 expect(response.error.code, equals(RequestErrorCode.SERVER_ERROR)); 91 expect(response.error.code, equals(RequestErrorCode.SERVER_ERROR));
85 expect(response.error.message, equals('mock request exception')); 92 expect(response.error.message, equals('mock request exception'));
86 expect(response.error.stackTrace, isNotNull); 93 expect(response.error.stackTrace, isNotNull);
87 expect(response.error.stackTrace, isNot(isEmpty)); 94 expect(response.error.stackTrace, isNot(isEmpty));
88 channel.expectMsgCount(responseCount: 1, notificationCount: 1); 95 channel.expectMsgCount(responseCount: 1, notificationCount: 1);
89 }); 96 });
90 } 97 }
91 98
92 static Future requestHandler_futureException() { 99 static Future requestHandler_futureException() {
93 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk); 100 SocketServer server = new SocketServer(
101 new AnalysisServerOptions(),
102 DirectoryBasedDartSdk.defaultSdk);
94 MockServerChannel channel = new MockServerChannel(); 103 MockServerChannel channel = new MockServerChannel();
95 server.createAnalysisServer(channel); 104 server.createAnalysisServer(channel);
96 _MockRequestHandler handler = new _MockRequestHandler(true); 105 _MockRequestHandler handler = new _MockRequestHandler(true);
97 server.analysisServer.handlers = [handler]; 106 server.analysisServer.handlers = [handler];
98 var request = new ServerGetVersionParams().toRequest('0'); 107 var request = new ServerGetVersionParams().toRequest('0');
99 return channel.sendRequest(request).then((Response response) { 108 return channel.sendRequest(request).then((Response response) {
100 expect(response.id, equals('0')); 109 expect(response.id, equals('0'));
101 expect(response.error, isNull); 110 expect(response.error, isNull);
102 channel.expectMsgCount(responseCount: 1, notificationCount: 2); 111 channel.expectMsgCount(responseCount: 1, notificationCount: 2);
103 expect(channel.notificationsReceived[1].event, SERVER_ERROR); 112 expect(channel.notificationsReceived[1].event, SERVER_ERROR);
(...skipping 12 matching lines...) Expand all
116 new Future(throwException); 125 new Future(throwException);
117 return new Response(request.id); 126 return new Response(request.id);
118 } 127 }
119 throw 'mock request exception'; 128 throw 'mock request exception';
120 } 129 }
121 130
122 void throwException() { 131 void throwException() {
123 throw 'mock future exception'; 132 throw 'mock future exception';
124 } 133 }
125 } 134 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/domain_server_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698