| OLD | NEW |
| 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 mocks; | 5 library mocks; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| 11 import 'package:analysis_server/src/channel.dart'; | 11 import 'package:analysis_server/src/channel.dart'; |
| 12 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
| 13 import 'package:unittest/matcher.dart'; | 13 import 'package:unittest/matcher.dart'; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Answer the path the the SDK relative to the currently running script | 16 * Answer the absolute path the the SDK relative to the currently running |
| 17 * or throw an exception if it cannot be found. | 17 * script or throw an exception if it cannot be found. |
| 18 */ | 18 */ |
| 19 String get sdkPath { | 19 String get sdkPath { |
| 20 Uri sdkUri = Platform.script.resolve('../../../sdk/'); | 20 Uri sdkUri = Platform.script.resolve('../../../sdk/'); |
| 21 // Verify that the internal library file exists | 21 |
| 22 Uri libFileUri = sdkUri.resolve('lib/_internal/libraries.dart'); | 22 // Verify the directory exists |
| 23 if (!new File.fromUri(libFileUri).existsSync()) { | 23 Directory sdkDir = new Directory.fromUri(sdkUri); |
| 24 throw 'Expected Dart SDK at ${sdkUri.path}'; | 24 if (!sdkDir.existsSync()) { |
| 25 throw 'Specified Dart SDK does not exist: $sdkDir'; |
| 25 } | 26 } |
| 26 return sdkUri.path; | 27 |
| 28 return sdkDir.path; |
| 27 } | 29 } |
| 28 | 30 |
| 29 /** | 31 /** |
| 30 * A mock [WebSocket] for testing. | 32 * A mock [WebSocket] for testing. |
| 31 */ | 33 */ |
| 32 class MockSocket<T> implements WebSocket { | 34 class MockSocket<T> implements WebSocket { |
| 33 StreamController controller = new StreamController(); | 35 StreamController controller = new StreamController(); |
| 34 MockSocket twin; | 36 MockSocket twin; |
| 35 Stream stream; | 37 Stream stream; |
| 36 | 38 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 responsesReceived.add(response); | 106 responsesReceived.add(response); |
| 105 // Wrap send response in future to simulate websocket | 107 // Wrap send response in future to simulate websocket |
| 106 new Future(() => responseController.add(response)); | 108 new Future(() => responseController.add(response)); |
| 107 } | 109 } |
| 108 | 110 |
| 109 void expectMsgCount({responseCount: 0, notificationCount: 0}) { | 111 void expectMsgCount({responseCount: 0, notificationCount: 0}) { |
| 110 expect(responsesReceived, hasLength(responseCount)); | 112 expect(responsesReceived, hasLength(responseCount)); |
| 111 expect(notificationsReceived, hasLength(notificationCount)); | 113 expect(notificationsReceived, hasLength(notificationCount)); |
| 112 } | 114 } |
| 113 } | 115 } |
| OLD | NEW |