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

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

Issue 198083004: (TBR) simplify check for valid SDK directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « no previous file | 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 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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698