| 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; | 5 library test.domain.analysis; |
| 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/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void addAnalysisSubscriptionHighlight(String file) { | 201 void addAnalysisSubscriptionHighlight(String file) { |
| 202 var service = AnalysisService.HIGHLIGHTS; | 202 var service = AnalysisService.HIGHLIGHTS; |
| 203 // add file to subscription | 203 // add file to subscription |
| 204 var files = analysisSubscriptions[service.name]; | 204 var files = analysisSubscriptions[service.name]; |
| 205 if (files == null) { | 205 if (files == null) { |
| 206 files = <String>[]; | 206 files = <String>[]; |
| 207 analysisSubscriptions[service.name] = files; | 207 analysisSubscriptions[service.name] = files; |
| 208 } | 208 } |
| 209 files.add(file); | 209 files.add(file); |
| 210 // set subscriptions | 210 // set subscriptions |
| 211 Request request = new Request('0', METHOD_SET_SUBSCRIPTIONS); | 211 Request request = new Request('0', METHOD_SET_ANALYSIS_SUBSCRIPTIONS); |
| 212 request.setParameter(SUBSCRIPTIONS, analysisSubscriptions); | 212 request.setParameter(SUBSCRIPTIONS, analysisSubscriptions); |
| 213 handleSuccessfulRequest(request); | 213 handleSuccessfulRequest(request); |
| 214 } | 214 } |
| 215 | 215 |
| 216 /** | 216 /** |
| 217 * Returns a [Future] that completes when this this helper finished all its | 217 * Returns a [Future] that completes when this this helper finished all its |
| 218 * scheduled tasks. | 218 * scheduled tasks. |
| 219 */ | 219 */ |
| 220 Future waitForTasksFinished() { | 220 Future waitForTasksFinished() { |
| 221 return waitForServerTasksFinished(server); | 221 return waitForServerTasksFinished(server); |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 }); | 1139 }); |
| 1140 }); | 1140 }); |
| 1141 }); | 1141 }); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 | 1144 |
| 1145 void test_setSubscriptions() { | 1145 void test_setSubscriptions() { |
| 1146 test('before analysis', () { | 1146 test('before analysis', () { |
| 1147 AnalysisTestHelper helper = new AnalysisTestHelper(); | 1147 AnalysisTestHelper helper = new AnalysisTestHelper(); |
| 1148 // subscribe | 1148 // subscribe |
| 1149 { | 1149 helper.addAnalysisSubscriptionHighlight(helper.testFile); |
| 1150 var request = new Request('0', METHOD_SET_SUBSCRIPTIONS); | |
| 1151 request.setParameter( | |
| 1152 SUBSCRIPTIONS, | |
| 1153 { | |
| 1154 AnalysisService.HIGHLIGHTS.name : [helper.testFile], | |
| 1155 }); | |
| 1156 helper.handleSuccessfulRequest(request); | |
| 1157 } | |
| 1158 // create project | 1150 // create project |
| 1159 helper.createSingleFileProject('int V = 42;'); | 1151 helper.createSingleFileProject('int V = 42;'); |
| 1160 // wait, there are highlight regions | 1152 // wait, there are highlight regions |
| 1161 helper.waitForTasksFinished().then((_) { | 1153 helper.waitForTasksFinished().then((_) { |
| 1162 var highlights = helper.getHighlights(helper.testFile); | 1154 var highlights = helper.getHighlights(helper.testFile); |
| 1163 expect(highlights, isNot(isEmpty)); | 1155 expect(highlights, isNot(isEmpty)); |
| 1164 }); | 1156 }); |
| 1165 }); | 1157 }); |
| 1166 | 1158 |
| 1167 test('after analysis', () { | 1159 test('after analysis', () { |
| 1168 AnalysisTestHelper helper = new AnalysisTestHelper(); | 1160 AnalysisTestHelper helper = new AnalysisTestHelper(); |
| 1169 // create project | 1161 // create project |
| 1170 helper.createSingleFileProject('int V = 42;'); | 1162 helper.createSingleFileProject('int V = 42;'); |
| 1171 // wait, no regions initially | 1163 // wait, no regions initially |
| 1172 return helper.waitForTasksFinished().then((_) { | 1164 return helper.waitForTasksFinished().then((_) { |
| 1173 var highlights = helper.getHighlights(helper.testFile); | 1165 var highlights = helper.getHighlights(helper.testFile); |
| 1174 expect(highlights, isEmpty); | 1166 expect(highlights, isEmpty); |
| 1175 // subscribe | 1167 // subscribe |
| 1176 { | 1168 helper.addAnalysisSubscriptionHighlight(helper.testFile); |
| 1177 var request = new Request('0', METHOD_SET_SUBSCRIPTIONS); | |
| 1178 request.setParameter( | |
| 1179 SUBSCRIPTIONS, | |
| 1180 { | |
| 1181 AnalysisService.HIGHLIGHTS.name : [helper.testFile], | |
| 1182 }); | |
| 1183 helper.handleSuccessfulRequest(request); | |
| 1184 } | |
| 1185 // wait, has regions | 1169 // wait, has regions |
| 1186 return helper.waitForTasksFinished().then((_) { | 1170 return helper.waitForTasksFinished().then((_) { |
| 1187 var highlights = helper.getHighlights(helper.testFile); | 1171 var highlights = helper.getHighlights(helper.testFile); |
| 1188 expect(highlights, isNot(isEmpty)); | 1172 expect(highlights, isNot(isEmpty)); |
| 1189 }); | 1173 }); |
| 1190 }); | 1174 }); |
| 1191 }); | 1175 }); |
| 1192 } | 1176 } |
| OLD | NEW |