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

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

Issue 394923004: As a temporary measure, allow SDK to be specified on analysis server cmd line. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/search/search_domain_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 'mocks.dart'; 9 import 'mocks.dart';
10 10
11 import 'package:analysis_server/src/constants.dart'; 11 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/protocol.dart'; 12 import 'package:analysis_server/src/protocol.dart';
13 import 'package:analysis_server/src/socket_server.dart'; 13 import 'package:analysis_server/src/socket_server.dart';
14 import 'package:analyzer/src/generated/sdk_io.dart';
14 import 'package:unittest/unittest.dart'; 15 import 'package:unittest/unittest.dart';
15 16
16 main() { 17 main() {
17 group('SocketServer', () { 18 group('SocketServer', () {
18 test('createAnalysisServer_successful', 19 test('createAnalysisServer_successful',
19 SocketServerTest.createAnalysisServer_successful); 20 SocketServerTest.createAnalysisServer_successful);
20 test('createAnalysisServer_alreadyStarted', 21 test('createAnalysisServer_alreadyStarted',
21 SocketServerTest.createAnalysisServer_alreadyStarted); 22 SocketServerTest.createAnalysisServer_alreadyStarted);
22 }); 23 });
23 } 24 }
24 25
25 class SocketServerTest { 26 class SocketServerTest {
26 static Future createAnalysisServer_successful() { 27 static Future createAnalysisServer_successful() {
27 SocketServer server = new SocketServer(); 28 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk);
28 MockServerChannel channel = new MockServerChannel(); 29 MockServerChannel channel = new MockServerChannel();
29 server.createAnalysisServer(channel); 30 server.createAnalysisServer(channel);
30 channel.expectMsgCount(notificationCount: 1); 31 channel.expectMsgCount(notificationCount: 1);
31 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED); 32 expect(channel.notificationsReceived[0].event, SERVER_CONNECTED);
32 expect(channel.notificationsReceived[0].params, isEmpty); 33 expect(channel.notificationsReceived[0].params, isEmpty);
33 return channel.sendRequest( 34 return channel.sendRequest(
34 new Request('0', SERVER_SHUTDOWN) 35 new Request('0', SERVER_SHUTDOWN)
35 ).then((Response response) { 36 ).then((Response response) {
36 expect(response.id, equals('0')); 37 expect(response.id, equals('0'));
37 expect(response.error, isNull); 38 expect(response.error, isNull);
38 channel.expectMsgCount(responseCount: 1, notificationCount: 1); 39 channel.expectMsgCount(responseCount: 1, notificationCount: 1);
39 }); 40 });
40 } 41 }
41 42
42 static void createAnalysisServer_alreadyStarted() { 43 static void createAnalysisServer_alreadyStarted() {
43 SocketServer server = new SocketServer(); 44 SocketServer server = new SocketServer(DirectoryBasedDartSdk.defaultSdk);
44 MockServerChannel channel1 = new MockServerChannel(); 45 MockServerChannel channel1 = new MockServerChannel();
45 MockServerChannel channel2 = new MockServerChannel(); 46 MockServerChannel channel2 = new MockServerChannel();
46 server.createAnalysisServer(channel1); 47 server.createAnalysisServer(channel1);
47 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED); 48 expect(channel1.notificationsReceived[0].event, SERVER_CONNECTED);
48 expect(channel1.notificationsReceived[0].params, isEmpty); 49 expect(channel1.notificationsReceived[0].params, isEmpty);
49 server.createAnalysisServer(channel2); 50 server.createAnalysisServer(channel2);
50 channel1.expectMsgCount(notificationCount: 1); 51 channel1.expectMsgCount(notificationCount: 1);
51 channel2.expectMsgCount(responseCount: 1); 52 channel2.expectMsgCount(responseCount: 1);
52 expect(channel2.responsesReceived[0].id, equals('')); 53 expect(channel2.responsesReceived[0].id, equals(''));
53 expect(channel2.responsesReceived[0].error, isNotNull); 54 expect(channel2.responsesReceived[0].error, isNotNull);
54 expect(channel2.responsesReceived[0].error.code, equals( 55 expect(channel2.responsesReceived[0].error.code, equals(
55 RequestError.CODE_SERVER_ALREADY_STARTED)); 56 RequestError.CODE_SERVER_ALREADY_STARTED));
56 channel2.sendRequest(new Request('0', SERVER_SHUTDOWN)).then((Response respo nse) { 57 channel2.sendRequest(new Request('0', SERVER_SHUTDOWN)).then((Response respo nse) {
57 expect(response.id, equals('0')); 58 expect(response.id, equals('0'));
58 expect(response.error, isNotNull); 59 expect(response.error, isNotNull);
59 expect(response.error.code, equals( 60 expect(response.error.code, equals(
60 RequestError.CODE_SERVER_ALREADY_STARTED)); 61 RequestError.CODE_SERVER_ALREADY_STARTED));
61 channel2.expectMsgCount(responseCount: 2); 62 channel2.expectMsgCount(responseCount: 2);
62 }); 63 });
63 } 64 }
64 } 65 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/search/search_domain_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698