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

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

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
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';
11 import 'package:analysis_server/src/plugin/server_plugin.dart'; 11 import 'package:analysis_server/src/plugin/server_plugin.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/instrumentation/instrumentation.dart'; 14 import 'package:analyzer/instrumentation/instrumentation.dart';
15 import 'package:analyzer/src/generated/sdk_io.dart'; 15 import 'package:analyzer/src/generated/sdk_io.dart';
16 import 'package:plugin/manager.dart'; 16 import 'package:plugin/manager.dart';
17 import 'package:unittest/unittest.dart'; 17 import 'package:unittest/unittest.dart';
18 18
19 import 'mocks.dart'; 19 import 'mocks.dart';
20 import 'utils.dart';
20 21
21 main() { 22 main() {
23 initializeTestEnvironment();
22 group('SocketServer', () { 24 group('SocketServer', () {
23 test('createAnalysisServer_successful', 25 test('createAnalysisServer_successful',
24 SocketServerTest.createAnalysisServer_successful); 26 SocketServerTest.createAnalysisServer_successful);
25 test('createAnalysisServer_alreadyStarted', 27 test('createAnalysisServer_alreadyStarted',
26 SocketServerTest.createAnalysisServer_alreadyStarted); 28 SocketServerTest.createAnalysisServer_alreadyStarted);
27 test('requestHandler_exception', SocketServerTest.requestHandler_exception); 29 test('requestHandler_exception', SocketServerTest.requestHandler_exception);
28 test('requestHandler_futureException', 30 test('requestHandler_futureException',
29 SocketServerTest.requestHandler_futureException); 31 SocketServerTest.requestHandler_futureException);
30 }); 32 });
31 } 33 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 expect(response.error, isNull); 104 expect(response.error, isNull);
103 channel.expectMsgCount(responseCount: 1, notificationCount: 2); 105 channel.expectMsgCount(responseCount: 1, notificationCount: 2);
104 expect(channel.notificationsReceived[1].event, SERVER_ERROR); 106 expect(channel.notificationsReceived[1].event, SERVER_ERROR);
105 }); 107 });
106 } 108 }
107 109
108 static SocketServer _createSocketServer() { 110 static SocketServer _createSocketServer() {
109 ServerPlugin serverPlugin = new ServerPlugin(); 111 ServerPlugin serverPlugin = new ServerPlugin();
110 ExtensionManager manager = new ExtensionManager(); 112 ExtensionManager manager = new ExtensionManager();
111 manager.processPlugins([serverPlugin]); 113 manager.processPlugins([serverPlugin]);
112 return new SocketServer(new AnalysisServerOptions(), 114 return new SocketServer(
113 DirectoryBasedDartSdk.defaultSdk, InstrumentationService.NULL_SERVICE, 115 new AnalysisServerOptions(),
114 serverPlugin, null, null); 116 DirectoryBasedDartSdk.defaultSdk,
117 InstrumentationService.NULL_SERVICE,
118 serverPlugin,
119 null,
120 null);
115 } 121 }
116 } 122 }
117 123
118 class _MockRequestHandler implements RequestHandler { 124 class _MockRequestHandler implements RequestHandler {
119 final bool futureException; 125 final bool futureException;
120 126
121 _MockRequestHandler(this.futureException); 127 _MockRequestHandler(this.futureException);
122 128
123 @override 129 @override
124 Response handleRequest(Request request) { 130 Response handleRequest(Request request) {
125 if (futureException) { 131 if (futureException) {
126 new Future(throwException); 132 new Future(throwException);
127 return new Response(request.id); 133 return new Response(request.id);
128 } 134 }
129 throw 'mock request exception'; 135 throw 'mock request exception';
130 } 136 }
131 137
132 void throwException() { 138 void throwException() {
133 throw 'mock future exception'; 139 throw 'mock future exception';
134 } 140 }
135 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698