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.analysis.get_errors; | 5 library test.analysis.get_errors; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
10 import 'package:analysis_server/src/domain_analysis.dart'; | 10 import 'package:analysis_server/src/domain_analysis.dart'; |
11 import 'package:analyzer/file_system/file_system.dart'; | |
12 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
13 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
14 | 13 |
15 import '../analysis_abstract.dart'; | 14 import '../analysis_abstract.dart'; |
16 import '../utils.dart'; | 15 import '../utils.dart'; |
17 | 16 |
18 main() { | 17 main() { |
19 initializeTestEnvironment(); | 18 initializeTestEnvironment(); |
20 defineReflectiveTests(GetErrorsTest); | 19 defineReflectiveTests(GetErrorsTest); |
21 } | 20 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 test_removeContextAfterRequest() { | 92 test_removeContextAfterRequest() { |
94 addTestFile(''' | 93 addTestFile(''' |
95 main() { | 94 main() { |
96 print(42) | 95 print(42) |
97 } | 96 } |
98 '''); | 97 '''); |
99 // handle the request synchronously | 98 // handle the request synchronously |
100 Request request = _createGetErrorsRequest(); | 99 Request request = _createGetErrorsRequest(); |
101 server.handleRequest(request); | 100 server.handleRequest(request); |
102 // remove context, causes sending an "invalid file" error | 101 // remove context, causes sending an "invalid file" error |
103 { | 102 resourceProvider.deleteFolder(projectPath); |
104 Folder projectFolder = resourceProvider.getResource(projectPath); | |
105 server.contextManager.callbacks.removeContext(projectFolder, <String>[]); | |
106 } | |
107 // wait for an error response | 103 // wait for an error response |
108 return serverChannel.waitForResponse(request).then((Response response) { | 104 return serverChannel.waitForResponse(request).then((Response response) { |
109 expect(response.error, isNotNull); | 105 expect(response.error, isNotNull); |
110 expect(response.error.code, RequestErrorCode.GET_ERRORS_INVALID_FILE); | 106 expect(response.error.code, RequestErrorCode.GET_ERRORS_INVALID_FILE); |
111 }); | 107 }); |
112 } | 108 } |
113 | 109 |
114 Future _checkInvalid(String file) { | 110 Future _checkInvalid(String file) { |
115 Request request = _createGetErrorsRequest(); | 111 Request request = _createGetErrorsRequest(); |
116 return serverChannel.sendRequest(request).then((Response response) { | 112 return serverChannel.sendRequest(request).then((Response response) { |
117 expect(response.error, isNotNull); | 113 expect(response.error, isNotNull); |
118 expect(response.error.code, RequestErrorCode.GET_ERRORS_INVALID_FILE); | 114 expect(response.error.code, RequestErrorCode.GET_ERRORS_INVALID_FILE); |
119 }); | 115 }); |
120 } | 116 } |
121 | 117 |
122 Request _createGetErrorsRequest() { | 118 Request _createGetErrorsRequest() { |
123 return new AnalysisGetErrorsParams(testFile).toRequest(requestId); | 119 return new AnalysisGetErrorsParams(testFile).toRequest(requestId); |
124 } | 120 } |
125 | 121 |
126 Future<List<AnalysisError>> _getErrors(String file) { | 122 Future<List<AnalysisError>> _getErrors(String file) { |
127 Request request = _createGetErrorsRequest(); | 123 Request request = _createGetErrorsRequest(); |
128 return serverChannel.sendRequest(request).then((Response response) { | 124 return serverChannel.sendRequest(request).then((Response response) { |
129 return new AnalysisGetErrorsResult.fromResponse(response).errors; | 125 return new AnalysisGetErrorsResult.fromResponse(response).errors; |
130 }); | 126 }); |
131 } | 127 } |
132 } | 128 } |
OLD | NEW |