| 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.integration.analysis.domain; | 5 library test.integration.analysis.domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_testing/reflective_tests.dart'; | 10 import 'package:analysis_testing/reflective_tests.dart'; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 null, docRegexp: 'Documentation for func')); | 132 null, docRegexp: 'Documentation for func')); |
| 133 tests.add(testHover('35', 2, null, null, ['int'], isLiteral: true, | 133 tests.add(testHover('35', 2, null, null, ['int'], isLiteral: true, |
| 134 parameterRegexps: ['int', 'param'])); | 134 parameterRegexps: ['int', 'param'])); |
| 135 return Future.wait(tests); | 135 return Future.wait(tests); |
| 136 }); | 136 }); |
| 137 } | 137 } |
| 138 | 138 |
| 139 test_getHover_noInfo() { | 139 test_getHover_noInfo() { |
| 140 String filename = 'test.dart'; | 140 String filename = 'test.dart'; |
| 141 String pathname = normalizePath(filename); | 141 String pathname = normalizePath(filename); |
| 142 String text = | 142 String text = r''' |
| 143 r''' | |
| 144 main() { | 143 main() { |
| 145 // no code | 144 // no code |
| 146 } | 145 } |
| 147 '''; | 146 '''; |
| 148 writeFile(filename, text); | 147 writeFile(filename, text); |
| 149 setAnalysisRoots(['']); | 148 setAnalysisRoots(['']); |
| 150 | 149 |
| 151 // Note: analysis.getHover doesn't wait for analysis to complete--it simply | 150 // Note: analysis.getHover doesn't wait for analysis to complete--it simply |
| 152 // returns the latest results that are available at the time that the | 151 // returns the latest results that are available at the time that the |
| 153 // request is made. So wait for analysis to finish before testing anything. | 152 // request is made. So wait for analysis to finish before testing anything. |
| 154 return analysisFinished.then((_) { | 153 return analysisFinished.then((_) { |
| 155 return server.send(ANALYSIS_GET_HOVER, { | 154 return server.send(ANALYSIS_GET_HOVER, { |
| 156 'file': pathname, | 155 'file': pathname, |
| 157 'offset': text.indexOf('no code') | 156 'offset': text.indexOf('no code') |
| 158 }).then((result) { | 157 }).then((result) { |
| 159 expect(result, isAnalysisGetHoverResult); | 158 expect(result, isAnalysisGetHoverResult); |
| 160 expect(result['hovers'], hasLength(0)); | 159 expect(result['hovers'], hasLength(0)); |
| 161 }); | 160 }); |
| 162 }); | 161 }); |
| 163 } | 162 } |
| 163 |
| 164 test_getErrors_before_analysis() { |
| 165 return getErrorsTest(false); |
| 166 } |
| 167 |
| 168 test_getErrors_after_analysis() { |
| 169 debugStdio(); |
| 170 return getErrorsTest(true); |
| 171 } |
| 172 |
| 173 Future getErrorsTest(bool afterAnalysis) { |
| 174 String filename = 'test.dart'; |
| 175 String pathname = normalizePath(filename); |
| 176 String text = |
| 177 r''' |
| 178 main() { |
| 179 var x // parse error: missing ';' |
| 180 }'''; |
| 181 writeFile(filename, text); |
| 182 setAnalysisRoots(['']); |
| 183 Future finishTest() { |
| 184 return server.send(ANALYSIS_GET_ERRORS, { |
| 185 'file': pathname |
| 186 }).then((result) { |
| 187 expect(result, isAnalysisGetErrorsResult); |
| 188 expect(result['errors'], equals(currentAnalysisErrors[pathname])); |
| 189 }); |
| 190 } |
| 191 if (afterAnalysis) { |
| 192 return analysisFinished.then((_) => finishTest()); |
| 193 } else { |
| 194 return finishTest(); |
| 195 } |
| 196 } |
| 164 } | 197 } |
| 165 | 198 |
| 166 main() { | 199 main() { |
| 167 runReflectiveTests(AnalysisDomainIntegrationTest); | 200 runReflectiveTests(AnalysisDomainIntegrationTest); |
| 168 } | 201 } |
| OLD | NEW |