| 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 test.domain.analysis.abstract; | 5 library test.domain.analysis.abstract; |
| 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/domain_analysis.dart'; | 10 import 'package:analysis_server/src/domain_analysis.dart'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 resourceProvider.newFile(path, content); | 75 resourceProvider.newFile(path, content); |
| 76 return path; | 76 return path; |
| 77 } | 77 } |
| 78 | 78 |
| 79 String addTestFile(String content) { | 79 String addTestFile(String content) { |
| 80 addFile(testFile, content); | 80 addFile(testFile, content); |
| 81 this.testCode = content; | 81 this.testCode = content; |
| 82 return testFile; | 82 return testFile; |
| 83 } | 83 } |
| 84 | 84 |
| 85 AnalysisServer createAnalysisServer(Index index) { |
| 86 return new AnalysisServer( |
| 87 serverChannel, |
| 88 resourceProvider, |
| 89 packageMapProvider, |
| 90 index, |
| 91 new AnalysisServerOptions(), |
| 92 new MockSdk()); |
| 93 } |
| 94 |
| 85 Index createIndex() { | 95 Index createIndex() { |
| 86 return null; | 96 return null; |
| 87 } | 97 } |
| 88 | 98 |
| 89 /** | 99 /** |
| 90 * Creates a project `/project`. | 100 * Creates a project `/project`. |
| 91 */ | 101 */ |
| 92 void createProject() { | 102 void createProject() { |
| 93 resourceProvider.newFolder(projectPath); | 103 resourceProvider.newFolder(projectPath); |
| 94 Request request = | 104 Request request = |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // Request request = new AnalysisSetAnalysisRootsParams(['/project'], | 230 // Request request = new AnalysisSetAnalysisRootsParams(['/project'], |
| 221 // []).toRequest('0'); | 231 // []).toRequest('0'); |
| 222 // handleSuccessfulRequest(request); | 232 // handleSuccessfulRequest(request); |
| 223 // } | 233 // } |
| 224 | 234 |
| 225 void setUp() { | 235 void setUp() { |
| 226 serverChannel = new MockServerChannel(); | 236 serverChannel = new MockServerChannel(); |
| 227 resourceProvider = new MemoryResourceProvider(); | 237 resourceProvider = new MemoryResourceProvider(); |
| 228 packageMapProvider = new MockPackageMapProvider(); | 238 packageMapProvider = new MockPackageMapProvider(); |
| 229 Index index = createIndex(); | 239 Index index = createIndex(); |
| 230 server = new AnalysisServer( | 240 server = createAnalysisServer(index); |
| 231 serverChannel, | |
| 232 resourceProvider, | |
| 233 packageMapProvider, | |
| 234 index, | |
| 235 new AnalysisServerOptions(), | |
| 236 new MockSdk()); | |
| 237 server.contextDirectoryManager.defaultOptions.enableAsync = true; | 241 server.contextDirectoryManager.defaultOptions.enableAsync = true; |
| 238 server.contextDirectoryManager.defaultOptions.enableEnum = true; | 242 server.contextDirectoryManager.defaultOptions.enableEnum = true; |
| 239 handler = new AnalysisDomainHandler(server); | 243 handler = new AnalysisDomainHandler(server); |
| 240 // listen for notifications | 244 // listen for notifications |
| 241 Stream<Notification> notificationStream = | 245 Stream<Notification> notificationStream = |
| 242 serverChannel.notificationController.stream; | 246 serverChannel.notificationController.stream; |
| 243 notificationStream.listen((Notification notification) { | 247 notificationStream.listen((Notification notification) { |
| 244 processNotification(notification); | 248 processNotification(notification); |
| 245 }); | 249 }); |
| 246 } | 250 } |
| 247 | 251 |
| 248 void tearDown() { | 252 void tearDown() { |
| 249 server.done(); | 253 server.done(); |
| 250 handler = null; | 254 handler = null; |
| 251 server = null; | 255 server = null; |
| 252 resourceProvider = null; | 256 resourceProvider = null; |
| 253 serverChannel = null; | 257 serverChannel = null; |
| 254 } | 258 } |
| 255 | 259 |
| 256 /** | 260 /** |
| 257 * Returns a [Future] that completes when the [AnalysisServer] finishes | 261 * Returns a [Future] that completes when the [AnalysisServer] finishes |
| 258 * all its scheduled tasks. | 262 * all its scheduled tasks. |
| 259 */ | 263 */ |
| 260 Future waitForTasksFinished() { | 264 Future waitForTasksFinished() { |
| 261 return waitForServerOperationsPerformed(server); | 265 return waitForServerOperationsPerformed(server); |
| 262 } | 266 } |
| 263 } | 267 } |
| OLD | NEW |