| 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 path the the SDK relative to the currently running script |
| 17 * or throw an exception if it cannot be found. | 17 * or throw an exception if it cannot be found. |
| 18 */ | 18 */ |
| 19 String get sdkPath { | 19 String get sdkPath { |
| 20 Uri sdkUri = Uri.base.resolveUri(Platform.script).resolve('../../../sdk/'); | 20 Uri sdkUri = Platform.script.resolve('../../../sdk/'); |
| 21 // Verify that the internal library file exists | 21 // Verify that the internal library file exists |
| 22 Uri libFileUri = sdkUri.resolve('lib/_internal/libraries.dart'); | 22 Uri libFileUri = sdkUri.resolve('lib/_internal/libraries.dart'); |
| 23 if (!new File.fromUri(libFileUri).existsSync()) { | 23 if (!new File.fromUri(libFileUri).existsSync()) { |
| 24 throw 'Expected Dart SDK at ${sdkUri.path}'; | 24 throw 'Expected Dart SDK at ${sdkUri.path}'; |
| 25 } | 25 } |
| 26 return sdkUri.path; | 26 return sdkUri.path; |
| 27 } | 27 } |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * A mock [WebSocket] for testing. | 30 * A mock [WebSocket] for testing. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 responsesReceived.add(response); | 104 responsesReceived.add(response); |
| 105 // Wrap send response in future to simulate websocket | 105 // Wrap send response in future to simulate websocket |
| 106 new Future(() => responseController.add(response)); | 106 new Future(() => responseController.add(response)); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void expectMsgCount({responseCount: 0, notificationCount: 0}) { | 109 void expectMsgCount({responseCount: 0, notificationCount: 0}) { |
| 110 expect(responsesReceived, hasLength(responseCount)); | 110 expect(responsesReceived, hasLength(responseCount)); |
| 111 expect(notificationsReceived, hasLength(notificationCount)); | 111 expect(notificationsReceived, hasLength(notificationCount)); |
| 112 } | 112 } |
| 113 } | 113 } |
| OLD | NEW |