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

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

Issue 304273007: Use 'analysis.setSubscriptions' HIGHLIGHTS in Editor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use addAnalysisSubscription/removeAnalysisSubscription Created 6 years, 6 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
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 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
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
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 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_server.dart ('k') | pkg/analysis_server/test/domain_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698