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

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

Issue 308703005: Extract constants into separate libarary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/resource_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/analysis_server.dart'; 11 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/domain_server.dart';
13 import 'package:analysis_server/src/protocol.dart'; 12 import 'package:analysis_server/src/protocol.dart';
14 import 'package:analysis_server/src/socket_server.dart'; 13 import 'package:analysis_server/src/socket_server.dart';
15 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
16 15
17 main() { 16 main() {
18 group('SocketServer', () { 17 group('SocketServer', () {
19 test('createAnalysisServer_successful', 18 test('createAnalysisServer_successful',
20 SocketServerTest.createAnalysisServer_successful); 19 SocketServerTest.createAnalysisServer_successful);
21 test('createAnalysisServer_alreadyStarted', 20 test('createAnalysisServer_alreadyStarted',
22 SocketServerTest.createAnalysisServer_alreadyStarted); 21 SocketServerTest.createAnalysisServer_alreadyStarted);
23 }); 22 });
24 } 23 }
25 24
26 class SocketServerTest { 25 class SocketServerTest {
27 static Future createAnalysisServer_successful() { 26 static Future createAnalysisServer_successful() {
28 SocketServer server = new SocketServer(); 27 SocketServer server = new SocketServer();
29 MockServerChannel channel = new MockServerChannel(); 28 MockServerChannel channel = new MockServerChannel();
30 server.createAnalysisServer(channel); 29 server.createAnalysisServer(channel);
31 channel.expectMsgCount(notificationCount: 1); 30 channel.expectMsgCount(notificationCount: 1);
32 expect(channel.notificationsReceived[0].event, equals( 31 expect(channel.notificationsReceived[0].event, NOTIFICATION_CONNECTED);
33 AnalysisServer.CONNECTED_NOTIFICATION));
34 expect(channel.notificationsReceived[0].params, isEmpty); 32 expect(channel.notificationsReceived[0].params, isEmpty);
35 return channel.sendRequest(new Request('0', 33 return channel.sendRequest(
36 ServerDomainHandler.SHUTDOWN_METHOD)).then((Response response) { 34 new Request('0', METHOD_SHUTDOWN)
35 ).then((Response response) {
37 expect(response.id, equals('0')); 36 expect(response.id, equals('0'));
38 expect(response.error, isNull); 37 expect(response.error, isNull);
39 channel.expectMsgCount(responseCount: 1, notificationCount: 1); 38 channel.expectMsgCount(responseCount: 1, notificationCount: 1);
40 }); 39 });
41 } 40 }
42 41
43 static void createAnalysisServer_alreadyStarted() { 42 static void createAnalysisServer_alreadyStarted() {
44 SocketServer server = new SocketServer(); 43 SocketServer server = new SocketServer();
45 MockServerChannel channel1 = new MockServerChannel(); 44 MockServerChannel channel1 = new MockServerChannel();
46 MockServerChannel channel2 = new MockServerChannel(); 45 MockServerChannel channel2 = new MockServerChannel();
47 server.createAnalysisServer(channel1); 46 server.createAnalysisServer(channel1);
48 expect(channel1.notificationsReceived[0].event, equals( 47 expect(channel1.notificationsReceived[0].event, NOTIFICATION_CONNECTED);
49 AnalysisServer.CONNECTED_NOTIFICATION));
50 expect(channel1.notificationsReceived[0].params, isEmpty); 48 expect(channel1.notificationsReceived[0].params, isEmpty);
51 server.createAnalysisServer(channel2); 49 server.createAnalysisServer(channel2);
52 channel1.expectMsgCount(notificationCount: 1); 50 channel1.expectMsgCount(notificationCount: 1);
53 channel2.expectMsgCount(responseCount: 1); 51 channel2.expectMsgCount(responseCount: 1);
54 expect(channel2.responsesReceived[0].id, equals('')); 52 expect(channel2.responsesReceived[0].id, equals(''));
55 expect(channel2.responsesReceived[0].error, isNotNull); 53 expect(channel2.responsesReceived[0].error, isNotNull);
56 expect(channel2.responsesReceived[0].error.code, equals( 54 expect(channel2.responsesReceived[0].error.code, equals(
57 RequestError.CODE_SERVER_ALREADY_STARTED)); 55 RequestError.CODE_SERVER_ALREADY_STARTED));
58 channel2.sendRequest(new Request('0', ServerDomainHandler.SHUTDOWN_METHOD) 56 channel2.sendRequest(new Request('0', METHOD_SHUTDOWN)).then((Response respo nse) {
59 ).then((Response response) {
60 expect(response.id, equals('0')); 57 expect(response.id, equals('0'));
61 expect(response.error, isNotNull); 58 expect(response.error, isNotNull);
62 expect(response.error.code, equals( 59 expect(response.error.code, equals(
63 RequestError.CODE_SERVER_ALREADY_STARTED)); 60 RequestError.CODE_SERVER_ALREADY_STARTED));
64 channel2.expectMsgCount(responseCount: 2); 61 channel2.expectMsgCount(responseCount: 2);
65 }); 62 });
66 } 63 }
67 } 64 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/resource_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698