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/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 serverPlugin, | 48 serverPlugin, |
49 new AnalysisServerOptions(), | 49 new AnalysisServerOptions(), |
50 new MockSdk(), | 50 new MockSdk(), |
51 InstrumentationService.NULL_SERVICE); | 51 InstrumentationService.NULL_SERVICE); |
52 handler = new AnalysisDomainHandler(server); | 52 handler = new AnalysisDomainHandler(server); |
53 }); | 53 }); |
54 | 54 |
55 group('updateContent', testUpdateContent); | 55 group('updateContent', testUpdateContent); |
56 | 56 |
57 group('AnalysisDomainHandler', () { | 57 group('AnalysisDomainHandler', () { |
| 58 group('getReachableSources', () { |
| 59 test('valid sources', () async { |
| 60 String fileA = '/project/a.dart'; |
| 61 String fileB = '/project/b.dart'; |
| 62 resourceProvider.newFile(fileA, 'import "b.dart";'); |
| 63 resourceProvider.newFile(fileB, ''); |
| 64 |
| 65 server.setAnalysisRoots('0', ['/project/'], [], {}); |
| 66 |
| 67 await server.onAnalysisComplete; |
| 68 |
| 69 var request = |
| 70 new AnalysisGetReachableSourcesParams(fileA).toRequest('0'); |
| 71 var response = handler.handleRequest(request); |
| 72 |
| 73 var json = response.toJson()[Response.RESULT]; |
| 74 |
| 75 // Sanity checks. |
| 76 expect(json['sources'], hasLength(6)); |
| 77 expect(json['sources']['file:///project/a.dart'], |
| 78 unorderedEquals(['dart:core', 'file:///project/b.dart'])); |
| 79 expect(json['sources']['file:///project/b.dart'], ['dart:core']); |
| 80 }); |
| 81 |
| 82 test('invalid source', () async { |
| 83 resourceProvider.newFile('/project/a.dart', 'import "b.dart";'); |
| 84 server.setAnalysisRoots('0', ['/project/'], [], {}); |
| 85 |
| 86 await server.onAnalysisComplete; |
| 87 |
| 88 var request = |
| 89 new AnalysisGetReachableSourcesParams('/does/not/exist.dart') |
| 90 .toRequest('0'); |
| 91 var response = handler.handleRequest(request); |
| 92 expect(response.error, isNotNull); |
| 93 expect(response.error.code, |
| 94 RequestErrorCode.GET_REACHABLE_SOURCES_INVALID_FILE); |
| 95 }); |
| 96 }); |
| 97 |
58 group('setAnalysisRoots', () { | 98 group('setAnalysisRoots', () { |
59 Response testSetAnalysisRoots( | 99 Response testSetAnalysisRoots( |
60 List<String> included, List<String> excluded) { | 100 List<String> included, List<String> excluded) { |
61 Request request = new AnalysisSetAnalysisRootsParams(included, excluded) | 101 Request request = new AnalysisSetAnalysisRootsParams(included, excluded) |
62 .toRequest('0'); | 102 .toRequest('0'); |
63 return handler.handleRequest(request); | 103 return handler.handleRequest(request); |
64 } | 104 } |
65 | 105 |
66 group('excluded', () { | 106 group('excluded', () { |
67 test('excluded folder', () { | 107 test('excluded folder', () { |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 test_beforeAnalysis() async { | 775 test_beforeAnalysis() async { |
736 addTestFile('int V = 42;'); | 776 addTestFile('int V = 42;'); |
737 createProject(); | 777 createProject(); |
738 // subscribe | 778 // subscribe |
739 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); | 779 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); |
740 // wait for analysis | 780 // wait for analysis |
741 await waitForTasksFinished(); | 781 await waitForTasksFinished(); |
742 expect(filesHighlights[testFile], isNotEmpty); | 782 expect(filesHighlights[testFile], isNotEmpty); |
743 } | 783 } |
744 } | 784 } |
OLD | NEW |