| Index: pkg/analysis_server/test/domain_analysis_test.dart
|
| diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
|
| index fe0bc262d6eb0535a2b6610b832728352761a5e8..1b5ab845a9643d90e67a4e2fca58d5311620de1b 100644
|
| --- a/pkg/analysis_server/test/domain_analysis_test.dart
|
| +++ b/pkg/analysis_server/test/domain_analysis_test.dart
|
| @@ -34,6 +34,7 @@ main() {
|
| group('notification.errors', testNotificationErrors);
|
| group('notification.highlights', testNotificationHighlights);
|
| group('updateContent', testUpdateContent);
|
| + group('setSubscriptions', test_setSubscriptions);
|
|
|
| group('AnalysisDomainHandler', () {
|
| test('getFixes', () {
|
| @@ -100,20 +101,6 @@ main() {
|
| expect(response, isNull);
|
| });
|
|
|
| - test('setSubscriptions', () {
|
| - var request = new Request('0', METHOD_SET_SUBSCRIPTIONS);
|
| - request.setParameter(
|
| - SUBSCRIPTIONS,
|
| - {
|
| - AnalysisService.HIGHLIGHTS : ['project/a.dart', 'project/b.dart'],
|
| - AnalysisService.NAVIGATION : ['project/c.dart'],
|
| - AnalysisService.OUTLINE : ['project/d.dart', 'project/e.dart']
|
| - });
|
| - var response = handler.handleRequest(request);
|
| - // TODO(scheglov) implement
|
| - expect(response, isNull);
|
| - });
|
| -
|
| test('updateOptions', () {
|
| var request = new Request('0', METHOD_UPDATE_OPTIONS);
|
| request.setParameter(
|
| @@ -183,6 +170,8 @@ class AnalysisTestHelper {
|
| AnalysisServer server;
|
| AnalysisDomainHandler handler;
|
|
|
| + Map<String, List<String>> analysisSubscriptions = {};
|
| +
|
| Map<String, List<AnalysisError>> filesErrors = {};
|
| Map<String, List<Map<String, Object>>> filesHighlights = {};
|
|
|
| @@ -209,6 +198,21 @@ class AnalysisTestHelper {
|
| });
|
| }
|
|
|
| + void addAnalysisSubscriptionHighlight(String file) {
|
| + var service = AnalysisService.HIGHLIGHTS;
|
| + // add file to subscription
|
| + var files = analysisSubscriptions[service.name];
|
| + if (files == null) {
|
| + files = <String>[];
|
| + analysisSubscriptions[service.name] = files;
|
| + }
|
| + files.add(file);
|
| + // set subscriptions
|
| + Request request = new Request('0', METHOD_SET_SUBSCRIPTIONS);
|
| + request.setParameter(SUBSCRIPTIONS, analysisSubscriptions);
|
| + handleSuccessfulRequest(request);
|
| + }
|
| +
|
| /**
|
| * Returns a [Future] that completes when this this helper finished all its
|
| * scheduled tasks.
|
| @@ -258,13 +262,23 @@ class AnalysisTestHelper {
|
| }
|
|
|
| /**
|
| + * Creates an empty project `/project/`.
|
| + */
|
| + void createEmptyProject() {
|
| + resourceProvider.newFolder('/project');
|
| + Request request = new Request('0', METHOD_SET_ANALYSIS_ROOTS);
|
| + request.setParameter(INCLUDED, ['/project']);
|
| + request.setParameter(EXCLUDED, []);
|
| + handleSuccessfulRequest(request);
|
| + }
|
| +
|
| + /**
|
| * Creates a project with a single Dart file `/project/bin/test.dart` with
|
| * the given [code].
|
| */
|
| void createSingleFileProject(code) {
|
| this.testCode = _getCodeString(code);
|
| resourceProvider.newFolder('/project');
|
| - resourceProvider.newFile('/project/pubspec.yaml', 'name: project');
|
| resourceProvider.newFile(testFile, testCode);
|
| Request request = new Request('0', METHOD_SET_ANALYSIS_ROOTS);
|
| request.setParameter(INCLUDED, ['/project']);
|
| @@ -340,6 +354,7 @@ class NotificationHighlightHelper extends AnalysisTestHelper {
|
| List<Map<String, Object>> regions;
|
|
|
| Future prepareRegions(then()) {
|
| + addAnalysisSubscriptionHighlight(testFile);
|
| return waitForTasksFinished().then((_) {
|
| regions = getTestHighlights();
|
| then();
|
| @@ -1125,3 +1140,53 @@ testUpdateContent() {
|
| });
|
| });
|
| }
|
| +
|
| +
|
| +void test_setSubscriptions() {
|
| + test('before analysis', () {
|
| + AnalysisTestHelper helper = new AnalysisTestHelper();
|
| + // subscribe
|
| + {
|
| + var request = new Request('0', METHOD_SET_SUBSCRIPTIONS);
|
| + request.setParameter(
|
| + SUBSCRIPTIONS,
|
| + {
|
| + AnalysisService.HIGHLIGHTS.name : [helper.testFile],
|
| + });
|
| + helper.handleSuccessfulRequest(request);
|
| + }
|
| + // create project
|
| + helper.createSingleFileProject('int V = 42;');
|
| + // wait, there are highlight regions
|
| + helper.waitForTasksFinished().then((_) {
|
| + var highlights = helper.getHighlights(helper.testFile);
|
| + expect(highlights, isNot(isEmpty));
|
| + });
|
| + });
|
| +
|
| + test('after analysis', () {
|
| + AnalysisTestHelper helper = new AnalysisTestHelper();
|
| + // create project
|
| + helper.createSingleFileProject('int V = 42;');
|
| + // wait, no regions initially
|
| + return helper.waitForTasksFinished().then((_) {
|
| + var highlights = helper.getHighlights(helper.testFile);
|
| + expect(highlights, isEmpty);
|
| + // subscribe
|
| + {
|
| + var request = new Request('0', METHOD_SET_SUBSCRIPTIONS);
|
| + request.setParameter(
|
| + SUBSCRIPTIONS,
|
| + {
|
| + AnalysisService.HIGHLIGHTS.name : [helper.testFile],
|
| + });
|
| + helper.handleSuccessfulRequest(request);
|
| + }
|
| + // wait, has regions
|
| + return helper.waitForTasksFinished().then((_) {
|
| + var highlights = helper.getHighlights(helper.testFile);
|
| + expect(highlights, isNot(isEmpty));
|
| + });
|
| + });
|
| + });
|
| +}
|
|
|